Difference between revisions of "Modding Tutorials/Decompiling source code"

From RimWorld Wiki
Jump to navigation Jump to search
(BackToTutorials added)
(Added MonoDevelop info)
Line 1: Line 1:
 
{{BackToTutorials}}
 
{{BackToTutorials}}
  
The base game provides a bunch of code snippets in ''../Source/'', relative to your Rimworld installation. Since this isn't a lot, one might want to take a look at the game's full source code;
+
The base game provides a bunch of code snippets in ''../Source/'', relative to your Rimworld installation. Since this isn't a lot, one might want to take a look at the game's full source code:<br/><br/>
 +
 
 +
===ILSpy===
 +
 
 +
One method is to use ILSpy. This software is recommended because its settings are correct on a clean install. It is Windows only, though.<br/>
  
 
# Download [http://ilspy.net/ ILSpy] (Download Binaries) and extract it to a directory of your choosing. Optionally create a desktop shortcut;
 
# Download [http://ilspy.net/ ILSpy] (Download Binaries) and extract it to a directory of your choosing. Optionally create a desktop shortcut;
# '''Either''': associate the .dll extension with ILSpy;
+
# '''Either''': associate the .dll extension with ILSpy:
 
## Navigate to ''Assembly-CSharp.dll'' in ''../Rimworld***_Data/Managed/'', relative to your Rimworld installation and with *** being a version number;
 
## Navigate to ''Assembly-CSharp.dll'' in ''../Rimworld***_Data/Managed/'', relative to your Rimworld installation and with *** being a version number;
 
## Right-click "Open with" and select a standard program. Navigate to your ILSpy installation and double-click ''ILSpy.exe'', tick the checkbox and accept;
 
## Right-click "Open with" and select a standard program. Navigate to your ILSpy installation and double-click ''ILSpy.exe'', tick the checkbox and accept;
 
## Double-click ''Assembly-CSharp.dll'',
 
## Double-click ''Assembly-CSharp.dll'',
# '''Or''': open ILSpy and open a .dll;
+
# '''Or''': open ILSpy and open a .dll:
 
## Open ILSpy;
 
## Open ILSpy;
 
## Go to File -> Open or press Ctrl+O, navigate to ''../Rimworld***_Data/Managed/'', relative to your Rimworld installation and with *** being a version number;
 
## Go to File -> Open or press Ctrl+O, navigate to ''../Rimworld***_Data/Managed/'', relative to your Rimworld installation and with *** being a version number;
 
## Select ''Assembly-CSharp.dll'' and confirm,
 
## Select ''Assembly-CSharp.dll'' and confirm,
 
# Click the "+" next to ''Assembly-CSharp (***)'', you will now see a list including the items ''Rimworld'' and ''Verse'';
 
# Click the "+" next to ''Assembly-CSharp (***)'', you will now see a list including the items ''Rimworld'' and ''Verse'';
# Take your time to look through the source code, to make yourself familiar. If you ever need the source code, open ILSpy again.
+
# Take your time to look through the source code, to make yourself familiar. If you ever need the source code, open ILSpy again.<br/><br/>
 +
 
 +
===MonoDevelop===
 +
 
 +
MonoDevelop is capable of decompiling DLLs, albeit using clumsy initial settings. It is Linux only, otherwise you have to download Xamarin Studio which doesn't have a decompiler.<br/>
  
 +
# Download [http://www.monodevelop.com/download/ MonoDevelop] and install it;
 +
# '''Either''': associate the .dll extension with MonoDevelop:
 +
## Navigate to ''Assembly-CSharp.dll'' in ''../Rimworld***_Data/Managed/'', relative to your Rimworld installation and with *** being a version number;
 +
## Right-click "Open with" and select MonoDevelop as standard program;
 +
## Double-click ''Assembly-CSharp.dll'',
 +
# '''Or''': open MonoDevelop and open a .dll:
 +
## Open MonoDevelop;
 +
## Go to File -> Open, navigate to ''../Rimworld***_Data/Managed/'', relative to your Rimworld installation and with *** being a version number;
 +
## Select ''Assembly-CSharp.dll'' and confirm,
 +
# '''Very important''': search for a dropdown called "Visibility" and change it from "Only public members" to "All members";
 +
# '''Very important''': search for a dropdown called "Language" and change it from "Summary" to "C#";
 +
# Click the "+" next to ''Assembly-CSharp (***)'', you will now see a list including the items ''Rimworld'' and ''Verse'';
 +
# Take your time to look through the source code, to make yourself familiar. If you ever need the source code, open ''Assembly-CSharp.dll'' again.<br/><br/>
  
 
[[Category:Modding tutorials]]
 
[[Category:Modding tutorials]]

Revision as of 09:52, 22 August 2015

Modding Tutorials

The base game provides a bunch of code snippets in ../Source/, relative to your Rimworld installation. Since this isn't a lot, one might want to take a look at the game's full source code:

ILSpy

One method is to use ILSpy. This software is recommended because its settings are correct on a clean install. It is Windows only, though.

  1. Download ILSpy (Download Binaries) and extract it to a directory of your choosing. Optionally create a desktop shortcut;
  2. Either: associate the .dll extension with ILSpy:
    1. Navigate to Assembly-CSharp.dll in ../Rimworld***_Data/Managed/, relative to your Rimworld installation and with *** being a version number;
    2. Right-click "Open with" and select a standard program. Navigate to your ILSpy installation and double-click ILSpy.exe, tick the checkbox and accept;
    3. Double-click Assembly-CSharp.dll,
  3. Or: open ILSpy and open a .dll:
    1. Open ILSpy;
    2. Go to File -> Open or press Ctrl+O, navigate to ../Rimworld***_Data/Managed/, relative to your Rimworld installation and with *** being a version number;
    3. Select Assembly-CSharp.dll and confirm,
  4. Click the "+" next to Assembly-CSharp (***), you will now see a list including the items Rimworld and Verse;
  5. Take your time to look through the source code, to make yourself familiar. If you ever need the source code, open ILSpy again.

MonoDevelop

MonoDevelop is capable of decompiling DLLs, albeit using clumsy initial settings. It is Linux only, otherwise you have to download Xamarin Studio which doesn't have a decompiler.

  1. Download MonoDevelop and install it;
  2. Either: associate the .dll extension with MonoDevelop:
    1. Navigate to Assembly-CSharp.dll in ../Rimworld***_Data/Managed/, relative to your Rimworld installation and with *** being a version number;
    2. Right-click "Open with" and select MonoDevelop as standard program;
    3. Double-click Assembly-CSharp.dll,
  3. Or: open MonoDevelop and open a .dll:
    1. Open MonoDevelop;
    2. Go to File -> Open, navigate to ../Rimworld***_Data/Managed/, relative to your Rimworld installation and with *** being a version number;
    3. Select Assembly-CSharp.dll and confirm,
  4. Very important: search for a dropdown called "Visibility" and change it from "Only public members" to "All members";
  5. Very important: search for a dropdown called "Language" and change it from "Summary" to "C#";
  6. Click the "+" next to Assembly-CSharp (***), you will now see a list including the items Rimworld and Verse;
  7. Take your time to look through the source code, to make yourself familiar. If you ever need the source code, open Assembly-CSharp.dll again.