Ludeon Forums

RimWorld => Mods => Help => Topic started by: Gabe C on May 23, 2014, 11:19:33 PM

Title: How do you write assemblies
Post by: Gabe C on May 23, 2014, 11:19:33 PM
I want to know how to write assemblies because I would create new stuff like aliens that don't stand still and have super abilities or potions or something. ;)
Title: Re: How do you write assemblies
Post by: ItchyFlea on May 24, 2014, 01:03:30 AM
I use ILSpy (http://ilspy.net/) to read the \RimWorld413Win_Data\Managed\Assembly-CSharp.dll file to see the code Tynan has used to do certain things, then I modify that code with MonoDevelop (http://monodevelop.com/) and go from there.

Both programs are free to download and use. As for learning C#, I haven't a clue. I've basically been trying different things to see what works.

When compiling an assembly with MonoDevelop (Called Xamarin Studio when installed) make sure that you tell it to include references to "Assembly-CSharp.dll" and "UnityEngine.dll" Screenshot: http://i.imgur.com/LO7Asfm.jpg
You also need to tell it that the 'Target framework' is for .NET 3.5. Screenshot: http://i.imgur.com/P8hj3WS.jpg This step is extremely important, as the game may fail to load your assembly otherwise.
Title: Re: How do you write assemblies
Post by: Haplo on May 24, 2014, 02:30:23 AM
I've also made a small tutorial for it,  which can be found here (http://ludeon.com/forums/index.php?topic=3408.0).
Unfortunately it is dropped to page 3 now so not easy to find.
Title: Re: How do you write assemblies
Post by: Crimsonknight3 on May 24, 2014, 07:30:08 PM
Quote from: Haplo on May 24, 2014, 02:30:23 AM
I've also made a small tutorial for it,  which can be found here (http://ludeon.com/forums/index.php?topic=3408.0).
Unfortunately it is dropped to page 3 now so not easy to find.

I think your tutorial should include at least a few small steps on HOW to use Visual Studio... I am usually pretty good at figuring things out and common sense and VS still overwhelmed me!! :) Otherwise I looked through your tutorial and again, it is a pretty good example, but I think it needs just a bit more commenting to say what each piece of code is doing, again to help beginners understand how the language works etc :) - Maybe link a decent c# tutorial aswell. I'm reading http://www.homeandlearn.co.uk/csharp/csharp.html at the moment :)
Title: Re: How do you write assemblies
Post by: mrofa on May 24, 2014, 07:42:12 PM
Start Visual
File -> New Project-> Templates-> Visual C# -> Class Library
Write a name and location where the project will be, no idea what solutions are so dont change them :D
And press Ok.
It will create that stuff and open editor and you will get stuff similar to this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary4
{
    public class Class1
    {
    }
}


So now look on the right side of the window and you will see solution explorer.
Click RMB on reference and on add reference.
Now Click browse and go to RimWorld\RimWorld413Win_Data\Managed
Select Assembly-CSharp.dll and UnityEngine.dll.
Press ok and your done.

Oh and F7 will compile and create .dll.


Title: Re: How do you write assemblies
Post by: Crimsonknight3 on May 24, 2014, 08:11:09 PM
/\
Should add that to your guide Haplo and thanks mrofa :)