Create a stat and have a statdefof to rely on

Started by ethouiche, December 23, 2017, 10:17:39 AM

Previous topic - Next topic

ethouiche

Hello,

I am working on a mod : http://steamcommunity.com/sharedfiles/filedetails/?id=1240656304

I want to create a stat for my shield that is not the vanilla one. ( StatDefOf.EnergyShieldEnergyMax / StatDefOf.EnergyShieldRechargeRat )

Therefor i need to declare something like that : https://github.com/josh-m/RW-Decompile/blob/3a7cd955b574c183405cc8065b15f1c231c7da08/RimWorld/StatDefOf.cs

But when i declare my own thing i end up overwriting the vanilla declarations which is bad(!)
I guess that's when i should use something like patching. Is that it ? I am a poo OOP coder ???, i could need some help.

Thank you.



jamaicancastle

You should be able to grab the stat by using StatDef.Named("statName") instead of a StatDefOf. The only problem AFAIK is that it won't autocomplete or detect a typo on compile. (I assume Rimworld will very quickly detect it when it tries to load...)

ethouiche

It worked fined. I realized i already used that way to call a stat but forgot. Thank you.