Plague Gun/Csharp Assembly Setup
|Plague Gun/Csharp Assembly Setup has been deprecated or removed completely from the game; it is no longer applicable to current versions|
|This page is suggested to be moved. Destination: Please suggest a target page. Reason: move to Modding Tutorials, also consider merging into single page.|
This page is obsolete for the current version of RimWorld and is kept as a resource for modders of previous versions. For the current version see: Plague Gun (1.1) This tutorial was originally written by Jecrell. Thread.
Setting up the C# Assembly
- Open your compiler of choice for C#.
- I use Visual Studio Community edition, a free Windows-based compiler for C# code.
- This part of the tutorial will assume you will use the same.
- Make a new Visual C# Class Library .NET Framework project. Name it PlagueGun. Make its directory RimWorld>Mods>PlagueGun>Source
- File => New => Project => Class Library (.NET Framework).
- Don't get this confused with "Class Library (.NET Standard)"!
- Go into the project properties.
- Project => PlagueGun Properties.
- In the Application tab, Make sure the assembly names and namespace match your XML assembly name.
- Earlier we used Plague.ThingDef_PlagueBullet. Plague should be our assembly namespace and assembly name.
- In that same window, change the Target Framework version to .NET Framework 4.7.2
- Forgetting to do this will cause lots of errors.
- Select Yes when it asks you if you're sure to change the framework.
- Go to the Build tab in the project properties.
- Change the output path to be RimWorld\Mods\PlagueGun\Assemblies
- All .dll files will go into this directory when we "build" our code library.
- In that same window, click the Advanced... button.
- Change Debugging information to none.
- This prevents a simple error that occurs when RimWorld doesn't know what to do with the debug .pdb files.
- In Solution Explorer. Go into Properties and edit AssemblyInfo.cs. Change the name of your assembly and assembly file version number as you like.
- This doesn't have to all be the same as your namespace, but it doesn't hurt to be consistent.
- In the main option bar at the top of the visual studio (File, Edit, View...), click Project, and click Add Reference.
- Click Browse and go to RimWorld\RimWorldWin_Data\Managed
- Add references to Assembly-CSharp.dll and UnityEngine.dll
- In the Solution Explorer (typically on the right side of the application), look at the references drop down list.
- Select Assembly-CSharp. Check the Properties section (usually under Solution Explorer). Make sure the properties section has Copy Local set to FALSE.
- Do this (Copy Local to FALSE) for UnityEngine as well.
- By doing this, we prevent the project from causing one million hash conflicts by copying the entire game's code twice!
- Go into the References; Delete the yellow triangle references, and click the Build button and Build Solution.
- If there are errors, be sure to delete unused References and delete lines for #using that aren't in use like #using System.Threading.Tasks
Now the workspace setup is complete and we can add C# code to RimWorld.
Editors note: Exact folder names might differ between installs. The naming scheme differs slightly between the DRM-free and Steam version of the mod.
- Required Items
- XML Stage
- Connecting XML and C#
- C# Assembly Setup <- You are here.
- C# Coding