Is there a better way to adjust body addon offsets?

Started by Vhaeryl, September 28, 2020, 04:52:38 AM

Previous topic - Next topic

Vhaeryl

Hey guys,

I'm fairly new to modding Rimworld. My ultimate goal is to create a custom race with body addons (wings, tails) and so on. But for now I'm content enough to learn how the xml coding works by adding body implants.

Anyway, I'm at the point where the body parts are added correctly via surgery or dev mode, just the correct position of the visuals is driving me nuts (I already added the offset codes for the body types).

Is there a way to adjust the position of the body addons besides messing with the x/y offsets in the xml code and reloading Rimworld everytime to check if I finally found the right offset?

GhostData

There are probably more elegant solutions, but to test offsets with CNP, I slapped together a dev tool debug window in my mod settings. Defs are stored in memory, so if you modify the offset values in the def, the next render cycle will use the adjusted offset immediately, so you can tweak in real time and then take your final values.
https://gitlab.com/Tragix/children-and-pregnancy-collab/-/blob/master/Source/RimWorld-Children/UI/AlignmentUtilityWindow.cs
There are definitely better ways to handle this than copy pasting each element, though. Don't take this as an example of proper coding, just how you can setup a quick and dirty UI.

Vhaeryl

After some more messing with xml coding, I scratched the idea of adding body addons via surgery and instead went straight to create a custom race as I found it to be a lot easier to add the body addons directly to the pawn inside the race def.

While doing some testing in game, I stumbled upon a simple solution to adjust the alignments of the body addons:

With dev mode on, there's the option called "Tweak Values" (second button from the left) which opens a list of various defs with sliders next to them. Scroll down that list until you found your body addon defs (for instance CustomRace_Tail) and then you can adjust the sliders of the x/y postion for each direction. The best part is that the adjustments happen instantly, you don't need to wait for something to refresh. Afterwards you just need to write down the numbers and then add add them to your code.