DiscreteStatBar
A class in Root.Township, Alta.StatSystem.
A stat bar drawn as separate segments spread over an arc, one segment per intervalPerBar of the stat. Shows and hides with another StatBar.
- Listed in Stats, effects, heat and liquid
- Inherits or implements
StatBarBase - Documented in Stats
Constructors
| Member | What it is |
|---|---|
DiscreteStatBar() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
8 private and internal fields
| Member | What it is |
|---|---|
private static readonly int _AlphaLimit | Shader property id for _AlphaLimit. Unused here. |
private float angleRange | Degrees the segments are spread across. |
private DiscreteStatBarVisual barPrefab | The segment visual to spawn. |
private float currentAlpha | Last alpha set. |
private float intervalPerBar | Stat value each segment stands for. |
private int lastValue | Last whole number of segments shown. |
private DiscreteStatBarVisual[] spawnedBars | The spawned segments. |
private StatBar visibilityDecidor | The StatBar whose visibility this bar follows. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Spawns the segments, shows the current value and follows the visibility of visibilityDecidor. |
override void Ping(float duration) | Pings the bar and every segment for a duration. |
override void SetAlpha(float alpha) | Sets the alpha on every segment. |
protected override void OnDestroy() | Only calls the base. |
protected override void OnStatChanged(Stat stat) | Turns on as many segments as whole intervals in the stat value. |
protected override void SetRenderersEnabled(bool isEnabled) | Turns segment renderers on only when enabled and alpha is above 0.01. |
3 private and internal methods
| Member | What it is |
|---|---|
private void SetupAllBars() | Spawns one segment per interval. The count works out as Maximum - Minimum / intervalPerBar because of missing brackets. |
private DiscreteStatBarVisual SpawnBar(int i, int barCount) | Spawns one segment as a child and rotates it to its place in angleRange. |
private void UpdateBars() | Activates segments below the current whole value and hides the rest. |