Patch operations to Core thingdef to use modded def functionality

Started by yadaptor, May 31, 2019, 04:22:56 PM

Previous topic - Next topic

yadaptor

Hey, I require some assistance (this might not be the right place tho, pretty new to the forum :v)
I've been trying to patch a thingdef from the Core, to instead of being a normal thingdef, it instead be the Custom def from a mod (more specifically, Core humans, to alienrace.thingdef_alienrace, I want to make the humans an alien race so I can use the mod's functionality), but after a lot of attempts, I wasn't able to figure out how to do this.
Someone I know told me to instead of xml, make C# assembly to redirect humans to the custom alienrace.thingdef, but my C# knowledge is almost null, so I'm trying to get this working some other way.
Is it possible with patching operations? If so, how could I minimize compatibility problems? If C# is really the best option...could you help me with some code? im noob  :-[

Mehni

https://rimworldwiki.com/wiki/Modding_Tutorials/Def_classes#Further_Example

combined with

https://rimworldwiki.com/wiki/Modding_Tutorials/PatchOperations#PatchOperationAttributeSet

That oughta do it. If that doesn't make sense, tell us what parts you don't understand.

If it does make sense but doesn't work, tell us what you did and what doesn't work. Preferably with the exact code/xml of what you did.

yadaptor

Oh my, thank you Mehni! Managed to make it work, although i'm worried about mod compatibility, is there a way to minimize problems? Maybe keeping it low on the load order?

Mehni

I can't think of any immediate causes for concern regarding compatibility. XML mods will continue to work just fine. XPath mods aren't effected either by your change. All common C# operations will continue to work just fine as well.

The type of mod that might error is the type of mod that has explicit support for Alien Races. Mods like Prepare Carefully, that Alien Facial Stuff thing, Alien Pregnancy. I'm not familiar enough with any of them to know for sure, but if there's any edge-case regarding compatibility it's probably there. Ask, test, or dig through the source.

If those C# mods run into issues, mod load order will not help. C# happens separately from XML/XPath, no amount of load order will change that.