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.
- Listed in Stats, effects, heat and liquid
- Inherits or implements
MonoBehaviour - Documented in Stats
Constructors
| Member | What it is |
|---|---|
StatTrigger() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
8 private and internal fields
| Member | What it is |
|---|---|
private bool isAbsoluteValue | Compare the raw value instead of a fraction of the maximum. |
private UnityEvent onTriggered | Server event when the threshold is crossed. |
private TransformEvent onTriggeredVisual | Visual event (given this transform) when the threshold is crossed. Not on headless builds. |
private StatManager targetManager | The stat manager to watch. |
private StatDefinition targetStat | The stat to watch. |
private float thresholdValue | The threshold, as a fraction of the maximum unless isAbsoluteValue is on. |
private bool triggerOnAboveTheThreshold | Active at or above the threshold when on, at or below when off. |
private bool wasActive | Whether the stat was active last time. |
Methods
3 private and internal methods
| Member | What 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. |