diff --git a/.envrc b/.envrc
new file mode 100644
index 0000000..8392d15
--- /dev/null
+++ b/.envrc
@@ -0,0 +1 @@
+use flake
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 7c62ffc..13b192f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,3 @@
/.vscode/obj
-
-# /*/Assemblies
-# /*/Assemblies/*.pdb
-# /.vscode
-# /Source
\ No newline at end of file
+/.direnv/
+/log/rimworld.log
\ No newline at end of file
diff --git a/.vscode/about.xml.xslt b/.vscode/about.xml.xslt
new file mode 100644
index 0000000..b2502a8
--- /dev/null
+++ b/.vscode/about.xml.xslt
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.vscode/build.bat b/.vscode/build.bat
deleted file mode 100644
index cb21c5f..0000000
--- a/.vscode/build.bat
+++ /dev/null
@@ -1,7 +0,0 @@
-echo off
-
-REM remove unnecessary assemblies
-DEL .\*\Assemblies\*.*
-
-REM build dll
-dotnet build .vscode
\ No newline at end of file
diff --git a/.vscode/build.sh b/.vscode/build.sh
new file mode 100755
index 0000000..74b8817
--- /dev/null
+++ b/.vscode/build.sh
@@ -0,0 +1,15 @@
+set -e
+
+script_dir=$(dirname $(readlink -f $0))
+mod_dir=$(dirname $script_dir)
+pushd $script_dir
+
+# build dll
+rm -f ../1.4/Assemblies/*
+dotnet build mod.csproj
+
+# generate About.xml
+rm -f ../About/About.xml
+xsltproc -o ../About/About.xml ./about.xml.xslt ./mod.csproj
+
+popd
\ No newline at end of file
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
deleted file mode 100644
index f00e1dd..0000000
--- a/.vscode/extensions.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "recommendations": [
- "ms-dotnettools.csharp"
- ]
-}
\ No newline at end of file
diff --git a/.vscode/fmt.sh b/.vscode/fmt.sh
new file mode 100644
index 0000000..c6ff51c
--- /dev/null
+++ b/.vscode/fmt.sh
@@ -0,0 +1,9 @@
+set -e
+
+script_dir=$(dirname $(readlink -f $0))
+mod_dir=$(dirname $script_dir)
+pushd $mod_dir
+
+nix fmt
+
+popd
\ No newline at end of file
diff --git a/.vscode/launch.json b/.vscode/launch.json
deleted file mode 100644
index 36a7a76..0000000
--- a/.vscode/launch.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- // Use IntelliSense to learn about possible attributes.
- // Hover to view descriptions of existing attributes.
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
- "version": "0.2.0",
- "configurations": [
- {
- "name": "Rimworld Mod Project",
- "type": "clr",
- "request": "launch",
- "preLaunchTask": "build dll",
- "args": [],
- "program": "../../RimWorldWin64.exe",
- "cwd": "${workspaceFolder}",
- "console": "internalConsole",
- "internalConsoleOptions":"neverOpen",
- "stopAtEntry": true
- }
- ]
-}
\ No newline at end of file
diff --git a/.vscode/launch.sh b/.vscode/launch.sh
new file mode 100755
index 0000000..2caaa50
--- /dev/null
+++ b/.vscode/launch.sh
@@ -0,0 +1,9 @@
+set -e
+
+script_dir=$(dirname $(readlink -f $0))
+mod_dir=$(dirname $script_dir)
+pushd $script_dir
+
+LC_ALL=C steam-run ~/.steam/steam/steamapps/common/RimWorld/RimWorldLinux -logfile $mod_dir/log/rimworld.log -popupwindow $@
+
+popd
\ No newline at end of file
diff --git a/.vscode/mod.csproj b/.vscode/mod.csproj
index 19d1628..2a008aa 100644
--- a/.vscode/mod.csproj
+++ b/.vscode/mod.csproj
@@ -1,34 +1,60 @@
-
- Library
- net480
- x64
-
-
- Template
- Template
- ../1.4/Assemblies
- 0.1.0.0
-
-
- none
-
- false
- false
-
-
-
-
-
-
-
-
- False
-
-
-
-
-
-
+
+ Library
+ net480
+ x64
+
+ Template
+ Template
+ ../1.4/Assemblies
+ latest
+ 0.1.0.0
+
+ none
+ false
+ false
+
+
+ dev.tobot.mod-template
+ Mod Template
+
+ Toby
+
+ A mod template.\nReady to build on NixOS.
+
+ 1.4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..bd5f9c4
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,10 @@
+{
+ // "explorer.excludeGitIgnore": true,
+ "files.exclude": {
+ ".direnv": true,
+ ".vscode/obj": true
+ },
+ "files.readonlyInclude": {
+ "log/rimworld.log": true
+ }
+}
\ No newline at end of file
diff --git a/.vscode/setup.sh b/.vscode/setup.sh
new file mode 100755
index 0000000..2fcf8ad
--- /dev/null
+++ b/.vscode/setup.sh
@@ -0,0 +1,12 @@
+set -e
+
+script_dir=$(dirname $(readlink -f $0))
+mod_dir=$(dirname $script_dir)
+pushd $script_dir
+
+mod_name="${mod_dir##*/}"
+
+# Try to create symlink in RimWorld mod directory
+ln -s $mod_dir -t "$(readlink -f ~/.steam/steam/steamapps/common/RimWorld/Mods)" -v || echo "Target directory already exists. This is expected on re-runs"
+
+popd
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 1d80d19..cc2c417 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -2,13 +2,60 @@
"version": "2.0.0",
"tasks": [
{
- "label": "build dll",
+ "label": "format",
+ "type": "shell",
+ "group": "none",
+ "command": ".vscode/fmt.sh",
+ "problemMatcher": []
+ },
+ {
+ "label": "build mod",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
- "command": ".vscode/build.bat",
+ "command": ".vscode/build.sh",
+ "problemMatcher": [
+ "$msCompile"
+ ]
},
+ {
+ "label": "run game",
+ "type": "shell",
+ "group": {
+ "kind": "none",
+ "isDefault": true
+ },
+ "command": ".vscode/launch.sh",
+ "problemMatcher": [],
+ "dependsOn": [
+ "link mod directory",
+ "build mod"
+ ]
+ },
+ {
+ "label": "run game (quicktest)",
+ "type": "shell",
+ "group": {
+ "kind": "none",
+ "isDefault": true
+ },
+ "command": ".vscode/launch.sh -quicktest",
+ "problemMatcher": [],
+ "dependsOn": [
+ "link mod directory",
+ "build mod"
+ ]
+ },
+ {
+ "label": "link mod directory",
+ "type": "shell",
+ "group": {
+ "kind": "none"
+ },
+ "command": ".vscode/setup.sh",
+ "problemMatcher": []
+ }
]
}
\ No newline at end of file
diff --git a/1.4/Assemblies/Template.dll b/1.4/Assemblies/Template.dll
new file mode 100644
index 0000000..1533143
Binary files /dev/null and b/1.4/Assemblies/Template.dll differ
diff --git a/1.4/Defs/LetterDef.xml b/1.4/Defs/LetterDef.xml
index f392053..9e746ff 100644
--- a/1.4/Defs/LetterDef.xml
+++ b/1.4/Defs/LetterDef.xml
@@ -1,12 +1,12 @@
-
- success_letter
- (65, 200, 65)
- (85, 255, 85)
- 6
- false
- LetterArrive_Good
- If you can see this letter, then mod template is set up correctly.
-
-
+
+ success_letter
+ (65, 200, 65)
+ (85, 255, 85)
+ 6
+ false
+ LetterArrive_Good
+ If you can see this letter, then mod template is set up correctly.
+
+
\ No newline at end of file
diff --git a/1.4/Languages/English/Data.xml b/1.4/Languages/English/Data.xml
index ff3d55b..7f5e605 100644
--- a/1.4/Languages/English/Data.xml
+++ b/1.4/Languages/English/Data.xml
@@ -1,3 +1,2 @@
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/1.4/Patches/Patches.xml b/1.4/Patches/Patches.xml
index 1646ae9..b7a1ae5 100644
--- a/1.4/Patches/Patches.xml
+++ b/1.4/Patches/Patches.xml
@@ -1,3 +1,2 @@
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/About/About.xml b/About/About.xml
index ece09ff..db0c7f3 100644
--- a/About/About.xml
+++ b/About/About.xml
@@ -1,24 +1,33 @@
-
+
- username.modname
- Mod Template
- username
-
- 1.4
-
-
-
-
-
-
-
-
-
-
- Template
-
\ No newline at end of file
+ dev.tobot.mod-template
+ Mod Template
+
+ Toby
+
+ A mod template.\nReady to build on NixOS.
+
+ 1.4
+
+ 0.1.0.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..057f068
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2024 Tobias Berger
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
index b736d47..a82555f 100644
--- a/README.md
+++ b/README.md
@@ -1,23 +1,19 @@
-# Rimworld Mod Template
+# RimWorld Mod Template
-This template is created for Rimworld modders who use [Visual Studio Code](https://code.visualstudio.com/) instead of Visual Studio IDE.
-
-* __No virtual folders__. Easy to manage and edit both `xml` and `cs` files.
-
-* __Lightweight__. Visual Studio Code only takes up to 200 MB of storage space and is lighting fast.
-
-* __Automated__. Integrated build, scripting and management tools to perform common tasks making everyday workflows faster.
-
-* __Customizable__. Almost every feature can be changed, whenever it is editor UI, keybinds or folder structure.
+This template is created for creating RimWorld mods in [VSCodium/Visual Studio Code](https://vscodium.com/)
## Setup
-1. Download and install [.NET Core SDK](https://dotnet.microsoft.com/download/dotnet-core) and [.Net Framework 4.8 Developer Pack](https://dotnet.microsoft.com/download/dotnet-framework/net48). This step can be skipped if you already have required C# packages from Visual Studio IDE.
-2. Install [C# extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp).
-3. Clone, pull or download this template into your Rimworld `Mods` folder.
+
+1. Ensure the extension `ms-dotnettools.csharp` (a.k.a. [C#](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp)) is installed
+1. Run the task `link mod directory`.
+ - This should symlink the mod directory to RimWorld's mod folder.
+ - The script won't work if you have installed RimWorld anywhere else than the default steam install.
+1. Run the task `build mod` to compile assemblies and About.xml
+1. Run the task `run game` to launch the game
+ - The script won't work if you have installed RimWorld anywhere else than the default steam install.
## Additional notes
-* By pressing `F5` key VS Code will perform 2 operations: build assembly file and launch Rimworld executable.
-* All intermediate files are kept inside `.vscode` folder.
-* For XML only modders remove preLaunchTask line from `.vscode/launch.json` file.
-* Modify `.vscode/mod.csproj` and `About/About.xml` according to your needs.
-
+
+- All attributes for `About.xml` are kept in `.vscode/mod.csproj`, `About.xml` will get overriden each build.
+- You can run `nix fmt` to format all code in the repository.
+- While this template is designed for VSCodium, it works just as well with any other editor, simply launch the scripts manually
diff --git a/Source/Main.cs b/Source/Main.cs
deleted file mode 100644
index d2b9cb9..0000000
--- a/Source/Main.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-
-using UnityEngine;
-using Verse;
-using Verse.AI;
-using Verse.AI.Group;
-using Verse.Sound;
-using Verse.Noise;
-using Verse.Grammar;
-using RimWorld;
-using RimWorld.Planet;
-
-// using System.Reflection;
-// using HarmonyLib;
-
-namespace Template
-{
- [DefOf]
- public class TemplateDefOf
- {
- public static LetterDef success_letter;
- }
-
- public class MyMapComponent : MapComponent
- {
- public MyMapComponent(Map map) : base(map){}
- public override void FinalizeInit()
- {
- Messages.Message("Success", null, MessageTypeDefOf.PositiveEvent);
- Find.LetterStack.ReceiveLetter("Success", TemplateDefOf.success_letter.description, TemplateDefOf.success_letter, null);
- }
- }
-
- [StaticConstructorOnStartup]
- public static class Start
- {
- static Start()
- {
- Log.Message("Mod template loaded successfully!");
- }
- }
-
-}
diff --git a/Source/Startup.cs b/Source/Startup.cs
new file mode 100644
index 0000000..a124d49
--- /dev/null
+++ b/Source/Startup.cs
@@ -0,0 +1,16 @@
+#nullable enable
+
+using Verse;
+
+// using HarmonyLib;
+
+namespace Template;
+
+[StaticConstructorOnStartup]
+public static class Startup
+{
+ static Startup()
+ {
+ Log.Message("Mod template loaded successfully!");
+ }
+}
diff --git a/Source/TemplateDefOf.cs b/Source/TemplateDefOf.cs
new file mode 100644
index 0000000..d2f1d76
--- /dev/null
+++ b/Source/TemplateDefOf.cs
@@ -0,0 +1,13 @@
+#nullable disable // Populated at runtime ; Will error if Def isn't added in Defs
+
+using RimWorld;
+using Verse;
+
+namespace Template;
+
+[DefOf]
+public class TemplateDefOf
+{
+ public static LetterDef success_letter;
+}
+#nullable enable
diff --git a/Source/TemplateMapComponent.cs b/Source/TemplateMapComponent.cs
new file mode 100644
index 0000000..cd0e0a3
--- /dev/null
+++ b/Source/TemplateMapComponent.cs
@@ -0,0 +1,25 @@
+#nullable enable
+
+using RimWorld;
+using Verse;
+
+// using HarmonyLib;
+
+namespace Template;
+
+public class TemplateMapComponent : MapComponent
+{
+ public TemplateMapComponent(Map map)
+ : base(map) { }
+
+ public override void FinalizeInit()
+ {
+ Messages.Message("Success", null, MessageTypeDefOf.PositiveEvent);
+ Find.LetterStack.ReceiveLetter(
+ "Success",
+ TemplateDefOf.success_letter.description,
+ TemplateDefOf.success_letter,
+ null
+ );
+ }
+}
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..75f06eb
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,115 @@
+{
+ "nodes": {
+ "flake-parts": {
+ "inputs": {
+ "nixpkgs-lib": "nixpkgs-lib"
+ },
+ "locked": {
+ "lastModified": 1706830856,
+ "narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=",
+ "owner": "hercules-ci",
+ "repo": "flake-parts",
+ "rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f",
+ "type": "github"
+ },
+ "original": {
+ "owner": "hercules-ci",
+ "repo": "flake-parts",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1707546158,
+ "narHash": "sha256-nYYJTpzfPMDxI8mzhQsYjIUX+grorqjKEU9Np6Xwy/0=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "d934204a0f8d9198e1e4515dd6fec76a139c87f0",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs-lib": {
+ "locked": {
+ "dir": "lib",
+ "lastModified": 1706550542,
+ "narHash": "sha256-UcsnCG6wx++23yeER4Hg18CXWbgNpqNXcHIo5/1Y+hc=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "97b17f32362e475016f942bbdfda4a4a72a8a652",
+ "type": "github"
+ },
+ "original": {
+ "dir": "lib",
+ "owner": "NixOS",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs_2": {
+ "locked": {
+ "lastModified": 1705856552,
+ "narHash": "sha256-JXfnuEf5Yd6bhMs/uvM67/joxYKoysyE3M2k6T3eWbg=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "612f97239e2cc474c13c9dafa0df378058c5ad8d",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "flake-parts": "flake-parts",
+ "nixpkgs": "nixpkgs",
+ "systems": "systems",
+ "treefmt-nix": "treefmt-nix"
+ }
+ },
+ "systems": {
+ "locked": {
+ "lastModified": 1681028828,
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+ "owner": "nix-systems",
+ "repo": "default",
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "default",
+ "type": "github"
+ }
+ },
+ "treefmt-nix": {
+ "inputs": {
+ "nixpkgs": "nixpkgs_2"
+ },
+ "locked": {
+ "lastModified": 1707300477,
+ "narHash": "sha256-qQF0fEkHlnxHcrKIMRzOETnRBksUK048MXkX0SOmxvA=",
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "rev": "ac599dab59a66304eb511af07b3883114f061b9d",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..ac466c3
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,37 @@
+{
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
+ flake-parts.url = "github:hercules-ci/flake-parts";
+ systems.url = "github:nix-systems/default";
+ # Dev tools
+ treefmt-nix.url = "github:numtide/treefmt-nix";
+ };
+
+ outputs = inputs:
+ inputs.flake-parts.lib.mkFlake { inherit inputs; } {
+ systems = import inputs.systems;
+ imports = [ inputs.treefmt-nix.flakeModule ];
+ perSystem = { config, self', pkgs, lib, system, ... }: {
+ # Rust dev environment
+ devShells.default = pkgs.mkShell {
+ inputsFrom = [ config.treefmt.build.devShell ];
+ nativeBuildInputs = with pkgs; [ dotnet-sdk mono libxslt ];
+ shellHook = ''
+ DOTNET_ROOT="${pkgs.dotnet-sdk}";
+ '';
+ };
+
+ # Add your auto-formatters here.
+ # cf. https://numtide.github.io/treefmt/
+ treefmt.config = {
+ projectRootFile = "flake.nix";
+ programs = {
+ nixpkgs-fmt.enable = true;
+ csharpier.enable = true;
+ prettier.enable = true;
+ nixfmt.enable = true;
+ };
+ };
+ };
+ };
+}