StatDefinition
A class in Root.Township, Alta.StatSystem.
A stat asset (health, hunger, speed and so on), a hashed value looked up by hash or name. Each StatManager makes a Stat per definition. Subclasses add special behaviour for some stats.
- Listed in Stats, effects, heat and liquid
- Inherits or implements
HashedGeneralValue<StatDefinition> - Derived types
StatDefinitionConverter,ControlledStat,IncrementingStat,MaxStatDefinition,OnFullAffectTargetStatDefinition,PlayerWeightStat,PoisonStat,StatDefinition,StatDefinition.Create,ThresholdStat,CrippleStatDefinition - Nested types
Create,MinimumAndMaximumValues - Attributes
TypeConverter,CreateAssetMenu - Documented in Stats, Arguments and results
Constructors
| Member | What it is |
|---|---|
StatDefinition() | Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets. |
Fields
10 private and internal fields
| Member | What it is |
|---|---|
private float changeToSync | How much the value must change (default 0.1) before CheckSerialize sends the stat to clients. |
private StatDefinition.MinimumAndMaximumValues commandMinimumAndMaximumValues | Optional range that commands may set the stat to; checked by IsValueValidForCommands. |
private float duration | Backing field for Duration: how long the upgrade effect plays when this stat is upgraded. |
private AnimationCurve indirectModificationCurve | Curve that turns the total of indirect modifiers into the amount applied to the stat; exposed as IndirectModificationCurve. |
private bool isIndirectUsageMultiplier | Whether indirect modifiers apply to this stat as a multiplier rather than a flat amount; exposed as IsIndirectUsageMultiplier. |
private bool isSaveSerialized | Backing field for IsSaveSerialized: whether the stat's base value is saved with the player. |
private int majorNotchEveryXNotches | Every this many notches on the wrist band is a major notch. 0 makes every notch major. |
private float notchValue | Stat amount (default 0.25) per notch on the wrist band; used by GetNotchesCount. |
private Color particlesColor | Backing field for ParticlesColor: colour of the upgrade effect particles. |
private string statName | Backing field for Name, the name used to look the stat up with StatManager.GetStat. |
Properties
| Member | What it is |
|---|---|
float Duration { get; } | How long the upgrade particle effect plays when this stat is raised by an upgrade. |
AnimationCurve IndirectModificationCurve { get; } | Curve used by indirect stat modifiers to turn an input value into a modifier for this stat. |
bool IsIndirectUsageMultiplier { get; } | Whether indirect modifiers on this stat are applied as multipliers rather than added. |
bool IsSaveSerialized { get; } | Whether the stat's value is written to the player save. |
string Name { get; } | The stat's name as set on the asset. Used by StatManager.GetStat and console commands. |
Color ParticlesColor { get; } | Colour of the upgrade particle effect for this stat. |
Methods
| Member | What it is |
|---|---|
virtual void Applied(StatManager manager, Stat stat) | Virtual hook the StatManager calls for each stat after setting them up. Empty in the base; subclasses like hunger use it. |
virtual bool CheckSerialize(float oldValue, float newValue) | Decides if a value change is big enough to send over the network. Default is a change greater than the asset's changeToSync (0.1). |
virtual int GetNotchesCount(float statMaximum) | How many notches the wrist band bar shows for a given maximum, from the asset's notch spacing. |
virtual void GetNotchesPosition(int notchesCount, float statMaximum, out float[] positions, out bool[] isMajor) | Works out evenly spaced notch positions (0 to 1) and which of them are major notches. |
Stat GetStatOnPlayer(IPlayer player) | Finds this stat on a player's health stat manager. Logs an error and returns null if missing. |
bool IsValueValidForCommands(float value) | Checks a value against the optional min and max allowed when setting this stat by console command. |
Used in
Members of other types that take, return or hold a StatDefinition:
StatEffect.statToAffect, StatEffect.StatToAffect, StatMultiplierEffect.statToAffect, ImpactModifierStatAffect.targetStat, CreateTargetOperation.Stat, Phantom.materializedStatDefinition, Phantom.visibilityStatDefinition, StatChangeHook.targetStat, StatOperation.statDefinition, StatValue.statDefinition, StatValue.StatValue, StatEffectHolder.statDefinition, StatEffectHolder.StatDefinition, StatEffectHolder.StatEffectHolder, DeadStateSettings.statsToResetOnDeath, DeadStateSettings.StatsToResetOnDeath, SpiritStateSettings.hungerStat, SpiritStateSettings.HungerStat, StatThresholdValue.secondaryStatDefinition, StatThresholdValue.statDefinition, ToggleEnemyHealthBars.statDefinition, StatDefinitionConverter.GetFromString, ControlledStat.controlledDefinition, FullEmptyStatTrigger.targetStat, HealthValidation.healthStat, HungerStat.fullnessStatDefinition, HungerStat.healthDefinition, HungerStat.recentDamageDefinition, IndirectStatModifierDefinition.targetStat, IndirectStatModifierDefinition.TargetStat, Instance.Apply, LevelStatModifier.targetStat, MaxStatDefinition.controlDefinitions, OnFullAffectTargetStatDefinition.affectedStatDefinition, PlayerStatManager.definitionsToKeepOnDeath, PoisonStat.poisonedStatDefinition, Stat.Definition, StatAffectingArea.targetStat, StatBar.DebugNotchVisibility, StatBarBase.trackedStatDefinition, StatDefinitionApplication.definition, StatDefinitionApplication.Definition, StatDefinitionApplication.StatDefinitionApplication, StatManager.ApplyIndirectModifier, StatManager.DeathReset, StatManager.GetStat, StatManager.Stats, StatManagerSaveData.IndirectStatModifier.definition, StatManagerSaveData.TimedModifier.definition, StatManagerSaveData1.IndirectStatModifier.definition, StatManagerSaveData1.TimedModifier.definition, StatManagerSaveDataStat.definition, StatModifier.StatDefinition, StatModifier.StatModifier, StatModifierConstructor.targetStat, StatTrigger.targetStat, StatUpgradeTarget.baseStat, StatUpgradeTarget.targetStat, DownedStateSettings.healthStat, DownedStateSettings.HealthStat and 37 more.