Stat
A class in Root.Township, Alta.StatSystem.
One stat's live value on a StatManager. The value is (base plus extras, clamped to min and max) times the multipliers. Changes raise Changed and, past the definition's threshold, NetworkChanged.
- Listed in Stats, effects, heat and liquid
- Attributes
TypeConverter - Documented in Stats
Constructors
| Member | What it is |
|---|---|
Stat(float value, float minimum, float maximum) | Creates a Stat from application. |
Stat(StatDefinitionApplication application) | Creates a Stat from application. |
Fields
9 private and internal fields
Properties
| Member | What it is |
|---|---|
StatDefinitionApplication Application { get; private set; } | The StatDefinitionApplication this stat came from, holding its defaults. |
float Base { get; set; } | The stat's own value. Setting it clamps to Minimum and Maximum. This is the part that is saved. |
float BuffMultiplier { get; set; } | Multiplier from buffs. Part of Multiplier. |
object ChangeData { get; set; } | Context for the change that is about to happen (for example the damage), read by Changed handlers. Cleared after each change. |
StatDefinition Definition { get; private set; } | The StatDefinition this stat is for. |
float Extra { get; set; } | Flat bonus added to Base. Reading gives the buff extra plus NonBuffExtra; setting sets only the buff extra. |
bool IsChanged { get; private set; } | True after a change until the next OnChangedExternal. |
bool IsEnabled { get; set; } | Whether the stat is enabled. Setting it forces a network update. |
float LastValue { get; private set; } | The value at the previous change. |
float Maximum { get; set; } | Upper limit for Base plus extras. Lowering it pulls Base down. |
float Minimum { get; set; } | Lower limit for Base plus extras. Raising it pushes Base up. |
float Multiplier { get; } | Total multiplier, BuffMultiplier times NonBuffMultiplier. |
float NonBuffExtra { get; set; } | Flat bonus that does not come from buffs. |
float NonBuffMultiplier { get; set; } | Multiplier that does not come from buffs. |
float Value { get; private set; } | The final calculated value. |
Events
| Member | What it is |
|---|---|
event StatHandler Changed | Raised whenever Value changes. |
event StatHandler ChangedExternal | Raised on the stat manager's tick for stats that changed since the last tick. |
event StatHandler DefinitionEvent | Raised by RunEvent; burn uses it to signal stat-specific events. |
event StatHandler NetworkChanged | Raised when a change passes the definition's sync threshold. The server's stat manager sends the stat to clients on it. |
Methods
| Member | What it is |
|---|---|
void Bind(StatHandler handler) | Calls the handler once now, then on every Changed. |
void ForceServerUpdate() | Recalculates and raises both Changed and NetworkChanged even if nothing changed. |
void Load(StatManagerSaveDataStat data) | Restores Base from save data, rounded to 2 decimals. |
void OnChangedExternal() | Clears IsChanged and raises ChangedExternal. The stat manager calls it on its tick. |
void Reset() | Sets min, max and base back to the defaults from Application. |
void RunEvent() | Raises DefinitionEvent. |
StatManagerSaveDataStat Save() | Returns save data holding the definition and Base only. |
void Serialize(Stream stream, bool isWritingFull) | Reads or writes the stat. Full writes include range, extras and multipliers. Values are packed to fixed ranges (base and range 0 to 127) and rounded to 0.01. |
void SetRange(float minimum, float maximum) | Sets Minimum and Maximum together and forces a network update. |
override string ToString() | The value with at most one decimal. |
1 private and internal method
Used in
Members of other types that take, return or hold a Stat:
BurnEffect.burningManager, StatChangeEffect.ModifyStat, StatEffect.ModifyStat, StatSetEffect.ModifyStat, FixedImpactor.damageStat, Phantom.SpeedStat, Phantom.visibilityStat, ProgressStatChangeHook.TopicProgress.affectedStat, StatChangeHook.affectedStats, HealthBar.HealthBar, HealthBar.healthStat, HealthBar.UpdateHealthBar, ToggleEnemyHealthBars.CheckEnemyNeedsHealthBar, BurnStat.Applied, ControlledStat.Applied, DiscreteStatBar.OnStatChanged, FullEmptyStatTrigger.OnStatChanged, FullEmptyUpdateModifier.affectedStat, FullEmptyUpdateModifier.CheckApply, FullEmptyUpdateModifier.FullEmptyUpdateModifier, FullEmptyUpdateModifier.trackedStat, FullnessStat.Applied, HungerStat.Applied, HungerStat.GetSets, HungerStat.ProcessHealthRegen, HungerStat.ProcessStarveDamage, IncrementingStat.Applied, IndirectStatModifier.IndirectStatModifier, IndirectStatModifier.targetStat, LevelStatModifier.affectingStat, MaxStatDefinition.Applied, MaxStatDefinition.endOfFrameBuffer, MaxStatDefinition.UpdateManager, OnFullAffectTargetStatDefinition.Applied, PlayerWeightStat.Applied, PoisonStat.Applied, StaminaBarVisibility.HandStaminaView.handStaminaStat, StatAffectingArea.affectedStats, StatAppliedHandler.BeginInvoke, StatAppliedHandler.Invoke, StatBar.OnStatChanged, StatBar.SetupNotches, StatBarBase.OnStatChanged, StatBarBase.Stat, StatBarBase.trackedStat, StatBarSimple.OnStatChanged, StatBarSimple.UpdateValue, StatConverter.Last, StatDefinition.Applied, StatDefinition.GetStatOnPlayer, StatHandler.BeginInvoke, StatHandler.Invoke, StatListConverter.LastList, StatManager.ApplyIndirectModifier, StatManager.GetStat, StatManager.indirectModifiers, StatManager.Stats, StatManager.SyncStat, StatModifier.Stat, StatModifier.StatModifier and 38 more.