Skip to main content

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.

Constructors​

MemberWhat it is
ThresholdStat()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

MemberWhat it is
protected ThresholdStat.ThresholdLevel[] levelsBacking field for Levels: each level's name, minimum value, modifiers and whether it shows a notch.
1 private and internal field
MemberWhat it is
private int notchesCountNumber of levels (past the first) that show a notch. Worked out in OnValidate.

Properties​

MemberWhat it is
ThresholdStat.ThresholdLevel[] Levels { get; }The levels, lowest first. Defaults to "empty" at 0 and "full" at 0.3.

Methods​

MemberWhat 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.