[Example] Using a DLL to unlock researchable recipes all defined in XML

Started by 1000101, April 06, 2015, 05:50:29 PM

Previous topic - Next topic

1000101

tbh, I have a background in programming but I am unfamiliar with RimWorld.  This has been my first foray into it.  I looked at the dll tutorial mod (the dark-matter generator) as well as other mods code.  You know far more about it than I do I'm sure.  :)
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

soltysek

research mod adding recipe to "work_table"  is save compatible ? I mean after game load is puting recip again or you neeed to custom exposedata() owerwrite on worktable  ?

skullywag

all researchmods run when game is loaded and when a research is completed, so you need to add a check to ensure it doesnt run everytime one is completed, see my omniturret for an example.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

1000101

The particular example in my OP does not expose and save the data but there really isn't anything worth saving, it's simply checking what research you have completed and makes sure the recipes are available.  Every rare-tick the MapComponent ticks and checks for research completion, enabling the recipes.  I've also short-cut the first check to happen immediately so at most there would be a single tick which the recipes may not be available.

I have tested this code a bit and it's the basis for my own mods research tree.  It seems to work without issue (for me) after loading games with complex research and recipe trees.

The updated code in a later post makes use of a bool flag for faster processing after an AdvancedRecipeDef is complete.  This is about the only thing which would be exposed and saved.  However, checking for the research to be done is only done once ever 250 ticks (one rare tick) and is fast enough that to save an array of "isEnabled" flags is just not worth it though.  That is, the research check happens so quickly it won't ever be an issue as far is game performance.
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

mrofa

All i do is clutter all around.

soltysek

skullywag - thx for info in this way its childis easy .

1000101 - its a one way to do it but its have strong minus one more RareTick() event more .imagine ther is 10 mod's that make it same way and checking 50 reserch each so every 250 Tick() you get 500 if's ... beter is to call Class on EventBase like  IsLoading or ResearchIsFinish . Minecraft big mods/modspack have this problem : lag spikes , Fps drop .

1000101

You would need several hundred mods each checking several thousand research with dozens of complex AdvancedRecipeDef per mod.

Unless you are going to mod in about 10,000 AdvancedRecipeDefs, I think you're safe.

My mod I am working on makes more than 4x the changes to the game as all *68* of the mods I have installed, including several big mods (MD2, ED, Clutter, Miscellaneous), and I have only re-defined the core, I haven't really added anything to the game and there is 0 impact.


Edit:  You do make a valid point about needless code execution, I'm just saying it's not something to worry about right now.
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

soltysek

i know i just point that mods are geting biger and game is growin needs of opti will be need in future especialy for old spec pc users

1000101 I pm you yesterday did you get it ?

1000101

I agree 100% about optimization.  This is more of "get it work."  Slow working code is better than fast broken code.  :)

re: PM - Didn't even notice, :)  Replied.
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By