Guidance on developing a mod

Started by ProtoBob, September 15, 2022, 10:22:46 AM

Previous topic - Next topic

ProtoBob

I have CS degree, decent experience coding with C# and working in Visual Studio. Want to create a mod for myself that shows quantity of tattered apparel on my colonists similar to the way the resource list looks. I have my mod environment set up and was able to post a hello world log message with no warnings.

I have decompiled the rimworld code with dnspy and also looked at some other UI mods to see where I need to start but still a little lost. I've looked at the tutorials and wiki as well.

Guess my first question is how should I be setting up my solution classes to retrieve the status of pawn apparel then display it on the game screen? I know that's a vague question, just looking for guidance. Thanks!

AnimateDream

#1
Not very experienced, but it sounds like you may want a map component.
https://rimworldwiki.com/wiki/Modding_Tutorials/GameComponent

Search around GitHub for RimWorld mods with MapComponents and you will likely find some good examples. There is an OnTick override though you probably want to avoid checking all your pawns every single tick.

LWM

You might think about where/how you want the information displayed.  If you want to add it to the resource bar at the left, for example, you would want to look through code until you figured out what it's called and then find a way to hijack it. You might also just have a MapComponent that periodically updates and adds a notification above the Letters on the right - there are certainly other mods that do that! (For example, to show deterioration? Or there's one gives a notice if you have any prisoners with No Interaction selected?) Or you can look thru the vanilla code for something that already shows up there...for example, heat stroke. If you search the english language data directory for "heat stroke" you can figure out what the text key is that the code uses (probably something like "HeatStrokeWarning") and then you can search the code for that phrase and look around to figure out how they do it in vanilla.
That last is something I do a lot - backtrack from an english phrase to the text key to locating that in the code itself.  It's often a helpful approach.
HTH!