I was thinking of making a mod that adds a new workbench, and to add some replay value I wanted to try have it randomize it's recipes at the start of each game. The idea would be to have it pick X recipes randomly from a larger pool.
Any ideas on how I might achieve this?
you already have answer, pick X recipes randomly from larger pool.
due to logic of database loader, it's better to remove Y recipes of type Z from pool.
in addition you may have workbench in pure C# that can draw recipes from pool using custom logic.
in all cases, this done via CLI\C#\DLL and not possible by XML.
Thanks! Yup, I'm fine with using C#. Got a follow up question if you don't mind. After poking around the game's dll, it seems a Building_WorkTable instance gets the available recipes from its own ThingDef.AllRecipes property, which in turn gets its recipes from the DefDatabase<RecipeDef>.AllDefsListForReading list before caching them. I was wondering if I could make a new RecipeDef programatically at runtime (to give it random properties instead of specifying them on an XML template) and add it to the database through DefDatabase<RecipeDef>.Add(myNewRecipe), then perhaps clearing the cached AllRecipes list of the Building_MySpecialWorkTable def so it gets populated again but now with my new recipe. If this is fine to do and doesn't make the game explode, then how can I make my programatically generated RecipeDefs persist through save game reloads? Will the game save anything it has on DefDatabase<RecipeDef>.AllDefsListForReading itself or must I save the RecipeDef somewhere on the save file?
Thanks for the help!