Ludeon Forums

RimWorld => Mods => Help => Topic started by: Fafn1r on April 14, 2016, 06:53:35 AM

Title: Learning modding by understanding the game
Post by: Fafn1r on April 14, 2016, 06:53:35 AM
I want to understand how the game works (and learn modding by the way). However I am not very compatible with usual learning methods such as reading theory and doing tutorials. I need to plunge into a system and attempt to understand it just by looking at it. What I can't understand, I have to ask about. I am going to have lots of questions.

So far I'm using traits as a base to understand game mechanics. Using Masochist trait as an example:

<workerClass>ThoughtWorker_Pain</workerClass> - I can't find where this workerClass comes from. Is it hidden somewhere in C# files? Is there a piece of code that searches for defs with ThoughtWorker_Pain class whenever a pawn is injured, sick or scarred? Where is this file?

So, that piece of code finds the def and a mood effect is triggered with Thoughts_TraitsConditional.xml or Thoughts_ConditionsSpecial.xml. Both of those check for <requiredTraits>, which is a... command (?) coded in C# files searching Traits_Singular.xml and Traits_Spectrum.xml for a specific def name. Is this correct?
Title: Re: Learning modding by understanding the game
Post by: skullywag on April 14, 2016, 06:56:29 AM
you will need a decompiler (ilspy or dotpeek) to look at the classes in the assembly file.
Title: Re: Learning modding by understanding the game
Post by: Fafn1r on April 14, 2016, 08:31:35 AM
Quote from: skullywag on April 14, 2016, 06:56:29 AM
you will need a decompiler (ilspy or dotpeek) to look at the classes in the assembly file.

Do you mean the Assembly-CSharp.dll file? It seems to be the only file that has understandable game data. I opened it with MonoDevolop (I'm running Linux Mint), but I couldn't find ThoughtWorker_Pain anywhere.
Title: Re: Learning modding by understanding the game
Post by: skullywag on April 14, 2016, 08:42:46 AM
yes I do and Ilspy shows it perfectly fine.
Title: Re: Learning modding by understanding the game
Post by: Fafn1r on April 14, 2016, 09:17:18 AM
I found it. I guess the 'search in file' tool is not working. But now things become much less intuitive. This is going to keep me busy for a while.
Title: Re: Learning modding by understanding the game
Post by: skullywag on April 14, 2016, 09:18:48 AM
if you just wanna read source, use ilspy, its simple and the search works, you can search for types, members and constants. Its a tiny download. Just point it at the assembly and go.
Title: Re: Learning modding by understanding the game
Post by: Alistaire on April 14, 2016, 09:29:14 AM
Quote from: http://rimworldwiki.com/wiki/Modding_Tutorials/Decompiling_source_codeCtrl+Shift+F or Ctrl+E opens the search bar which can be used to search through all loaded assemblies;
Title: Re: Learning modding by understanding the game
Post by: Fafn1r on April 22, 2016, 06:52:51 AM
I'm probably gonna regret it, but I replaced Linux Mint with Windows 10 just so I can use ILSpy. Hopefully it's find text tool works better than MonoDev's.
Title: Re: Learning modding by understanding the game
Post by: 1000101 on April 22, 2016, 12:00:34 PM
You should have just installed a virtual machine instead.  That way you wouldn't have had to downgrade to Windows 8/9/10, you could have installed Windows in the VM.

Also, mono develop comes with a decompiler, you didn't even "need" IlSpy.  Although, having a GUI and per-class decompiling instead of "DO ALL" is nice.