ThresholdStat
A class in Root.Township, Alta.StatSystem.
A StatDefinition split into named levels by threshold. While the stat's value is above a level's threshold, that level's stat modifiers apply.
- Listed in Stats, effects, heat and liquid
- Inherits or implements
StatDefinition - Derived types
FullnessStat,HungerStat - Nested types
ThresholdLevel - Documented in Stats
Constructors
| Member | What it is |
|---|---|
ThresholdStat() | Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets. |
Fields
| Member | What it is |
|---|---|
protected ThresholdStat.ThresholdLevel[] levels | Backing field for Levels: each level's name, minimum value, modifiers and whether it shows a notch. |
1 private and internal field
Properties
| Member | What it is |
|---|---|
ThresholdStat.ThresholdLevel[] Levels { get; } | The levels, lowest first. Defaults to "empty" at 0 and "full" at 0.3. |
Methods
| Member | What it is |
|---|---|
override void Applied(StatManager manager, Stat stat) | Binds to the stat so each value change switches on the modifier set of the highest level it is above, or none while the stat is disabled. |
int GetLevel(float value) | Index of the highest level whose MinThreshold the value is strictly above, or 0. |
override int GetNotchesCount(float statMaximum) | Number of levels (after the first) marked to show a notch, as counted in OnValidate. |
override void GetNotchesPosition(int notchesCount, float statMaximum, out float[] positions, out bool[] isMajor) | One major notch at each notched level's threshold, as a fraction of the stat maximum. |
protected virtual ModifierSet[] GetSets(StatManager manager, Stat stat) | Builds one ModifierSet per level from that level's modifier constructors. |
protected override void OnValidate() | Editor: recounts the notched levels. |