Skip to main content

StatTrigger

A class in Root.Township, Alta.StatSystem.

Fires events when a stat crosses a threshold into the active side. Server event on the server, visual event on non headless builds.

Constructors​

MemberWhat it is
StatTrigger()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

8 private and internal fields
MemberWhat it is
private bool isAbsoluteValueCompare the raw value instead of a fraction of the maximum.
private UnityEvent onTriggeredServer event when the threshold is crossed.
private TransformEvent onTriggeredVisualVisual event (given this transform) when the threshold is crossed. Not on headless builds.
private StatManager targetManagerThe stat manager to watch.
private StatDefinition targetStatThe stat to watch.
private float thresholdValueThe threshold, as a fraction of the maximum unless isAbsoluteValue is on.
private bool triggerOnAboveTheThresholdActive at or above the threshold when on, at or below when off.
private bool wasActiveWhether the stat was active last time.

Methods​

3 private and internal methods
MemberWhat it is
private bool IsActive(Stat trackedStat)Whether the value (or value over maximum, unless isAbsoluteValue) is past the threshold on the chosen side.
private void OnStatChanged(Stat trackedStat)Fires the events when the stat goes from inactive to active. Going back does nothing.
private void Start()Reads the starting state and watches the stat.