Zlepper.RimWorld.ModSdk
0.0.5
See the version list below for details.
<Sdk Name="Zlepper.RimWorld.ModSdk" Version="0.0.5" />
RimWorld ModSdk
This is a dotnet sdk that allows you to create mods for RimWorld with less messing with configurations.
Features
- Provides support for C# 10 (At least the feature .NetFramework can support).
- Allows multiple RimWorld versions to be supported at the same time.
- Automatically references common RimWorld assemblies.
- Provides an easy hook for referencing more assemblies.
- Easily reference HugsLib and Harmony if wanted.
- Automatically copies the mod to the RimWorld mods folder.
- Support for Rider + Visual Studio run buttons without additional configuration.
- Debugging is not yet magically supported and does require additional manual configuration.
- Implicit
using
s forRimWorld
,Verse
,System
,System.Collections.Generic
andSystem.Linq
.
Installation
This guide enables and uses HugsLib as I personally find it very useful. If you don't want to use it, you can replace the relevant parts with the standard RimWorld modding way of doing things: https://rimworldwiki.com/wiki/Modding_Tutorials.
A word of warning: I develop on Windows and have only tested this on Windows. It should be possible to tweak enough settings to get it working on other platforms, but I have not done so. If you are using Linux or Mac, please let me know if you want to help get it working for those platforms.
- Make sure you have at least a DotNet 6 SDK installed: https://dotnet.microsoft.com/en-us/download
- Open your IDE and create a new project, the specific project type does not matter, but I recommend a class library.
- Open the .csproj file and replace the content with the following:
<Project Sdk="Zlepper.RimWorld.ModSdk/0.0.4">
<PropertyGroup>
<IncludeHugsLib>true</IncludeHugsLib>
<RimWorldModName>Your mod name</RimWorldModName>
<RimWorldPackageId>Your.Mod.PackageId</RimWorldPackageId>
</PropertyGroup>
</Project>
- Create a new class and add the following code:
using HugsLib;
namespace MyName.MyFancyMod;
public class MyMod : ModBase
{
public override string ModIdentifier => " MyName.MyFancyMod";
public override void StaticInitialize()
{
Logger.Message("Hello from My fancy Mod!");
}
}
- If you get compile errors at this point, the SDK might not be able to locate your RimWorld installation, please see the "Optional configuration" section
and try setting
<RimWorldPath>
to the path to your RimWorld installation. - A file to your project called
About/About.xml
, with the following content:
<?xml version="1.0" encoding="utf-8"?>
<ModMetaData>
<name>Your mod name</name>
<author>Your name</author>
<packageId>Your.Mod.PackageId</packageId>
<supportedVersions>
<li>1.4</li>
</supportedVersions>
<description>This mod has a very good description, please make it even better</description>
<modDependencies>
<li>
<packageId>UnlimitedHugs.HugsLib</packageId>
<displayName>HugsLib</displayName>
<downloadUrl>https://github.com/UnlimitedHugs/RimworldHugsLib/releases/latest</downloadUrl>
<steamWorkshopUrl>steam://url/CommunityFilePage/818773962</steamWorkshopUrl>
</li>
</modDependencies>
<loadAfter>
<li>UnlimitedHugs.HugsLib</li>
</loadAfter>
</ModMetaData>
- Run the project and wait for RimWorld to load.
- Go into mod settings and enable your mod.
- Check the RimWorld dev tools for a message from your mod.
- Now, go and implement your mod! (Tip: Read the Tips and Tricks section)
Tip and tricks
- You don't need maintain your own structure for your mod, you can just add files to your project and
they will be copied to the mod folder for your current RimWorld version. For example: Add a
Defs
folder with aThingDefs
folder inside and add aMyThingDef.xml
file to it. It will be copied to the mod folder.- This also works for all the other "standard" folders RimWorld has:
About
,Defs
,Languages
,Textures
,Sounds
andPatches
. The "Assemblies" folder is generated automatically your assemblies when you build your project.
- This also works for all the other "standard" folders RimWorld has:
Configuration
The SDK contains several settings that can be configured in the .csproj file. Some of these are required to be set, while others are optional.
Required configuration:
<PropertyGroup>
<RimWorldModName>My Mod Name</RimWorldModName>
<RimWorldPackageId>My.Mod</RimWorldPackageId>
</PropertyGroup>
Optional configuration:
This shows the default values each parameter have, so if you are happy with those values, no need to tweak them.
<PropertyGroup>
<Nullable>enable</Nullable>
<LangVersion>10</LangVersion>
<IncludeHugsLib>false</IncludeHugsLib>
<HugsLibVersion>9.0.1</HugsLibVersion>
<OutputFolder>../Mods</OutputFolder>
<RimWorldImplicitUsings>enable</RimWorldImplicitUsings>
<RimWorldPath>C:\Program Files (x86)\Steam\steamapps\common\RimWorld</RimWorldPath>
<RimWorldVersion>(infered based on your installation)</RimWorldVersion>
</PropertyGroup>
Adding a reference to a RimWorld assembly
By default the SDK references Assembly-CSharp
and UnityEngine.CoreModule
for you. If you need to reference
another assembly, you can do so by adding a reference to it in the project file. For example, if you want to
reference UnityEngine.IMGUIModule
, you can add the following to your project file:
<ItemGroup>
<RimWorldAssemblyReference Include="UnityEngine.IMGUIModule" />
</ItemGroup>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.