DefDatabase and PatchOperationInsert (custom ThingCategoryDef after Root)

Started by Zaarjin, November 11, 2019, 04:47:57 PM

Previous topic - Next topic

Zaarjin

Hi everyone,

I've started experimenting with the modding functionalities of Rimworld to make my hack into a mod.

Before diving in c# to mark resources as favorites to show them at the top of the ResourceReadout, I'm trying doing it with a Patch.

My idea is to create a new ThingCategoryDef  ("DisplayFavoriteResources") and making sure it's at the top of the ThingCategoryDef  as the ResourceReadout code simply loops over the ThingCategoryDef with resourceReadoutRoot set to true.

Unfortunately it does not seem to work with PatchOperationInsert(order=Append) on Root or PatchOperationInsert(order=Prepend) on Foods. My custom category is always displayed after the ones from Core.

Writing this post I start to understand why... Looking at DefDatabase, it seems that the Mods's Defs are added after the game's ones. Is my assumption correct?
That would probably explain why the ResourceReadout hasn't been modded before...

Thanks!
Zaarjin