Ludeon Forums

RimWorld => Mods => Help => Topic started by: ethouiche on December 23, 2017, 10:17:39 AM

Title: Create a stat and have a statdefof to rely on
Post by: ethouiche on December 23, 2017, 10:17:39 AM
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.


Title: Re: Create a stat and have a statdefof to rely on
Post by: jamaicancastle on December 23, 2017, 02:03:45 PM
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...)
Title: Re: Create a stat and have a statdefof to rely on
Post by: ethouiche on December 25, 2017, 12:48:57 PM
It worked fined. I realized i already used that way to call a stat but forgot. Thank you.