Need guidance in creating a more advanced mod

Started by Nolan71, September 11, 2019, 04:56:56 PM

Previous topic - Next topic

Nolan71

I am currently working on a mod for RimWorld that gives a positive mood stat for a couple of days after Raids are defeated.
This is the second mod that I have created, so please understand my limited exposure to modding RiwmWorld which is as follows:

(I am proficient in c# and xml)
I read through the majority of the Modding Tutorials on the Wiki.
I completed the Plague Gun tutorial as well.

This is what I have done so far in attempting to create my mod:
I dug around a lot of files using the decompiler to try to understand how the defs work as well as the limitations within each function.
I created a mock-up .xml file using a thought def (can provide any files as necessary.)

.....and now? I'm simply unsure of what to do. I tried looking at the defs and the c# code to understand what approach I should take and I just felt like I was going in circles. I've looked at other tutorials out there but I really just need someone to give me a solid explanation of how the defs and dlls interact and work with each other.

I know this is kinda a shot in the dark but if anyone is willing to help me understand the structure better I would really appreciate it. Pm's are welcome!

Thanks!!

Mehni

Interesting mod idea.

QuoteI really just need someone to give me a solid explanation of how the defs and dlls interact and work with each other.

Since you're proficient in C#: Defs are simply classes, which get their fields filled using reflection. The values in these fields are in the XML files. Every Def is an instance, and there's one instance of the Def per Type of Def (e.g. there's one ThingDef named Beer). If you change the Beer ThingDef, you change it for all Things which share the single Beer ThingDef.

To create your mod, you'll need to find a way to lift along with the "raid was defeated" functionality. There's no clear cut "raid defeated" thing, but I'd wager LordToil_PanicFlee comes pretty close, with the caveat that it doesn't apply to mechanoids. Its UpdateAllDuties() method gets triggered when a human raid is defeated.

You can use Harmony to lift along with that method. Try a Postfix on the aforementioned method with a Log.Message as a start.

Nolan71

Thank you so much for that explanation in the first paragraph. Can you also explain how heddif works and how that interacts between the xml and c#?

If it's not too much to ask:
Could you look at my xml code and give me a start on the c#?
If it's too much of a hassle just point me to somewhere or someone who can.
I really appreciate it!

(Attached is xml)