Skip to main content

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.

Constructors​

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

Fields​

8 private and internal fields
MemberWhat it is
private static readonly int _AlphaLimitShader property id for _AlphaLimit. Unused here.
private float angleRangeDegrees the segments are spread across.
private DiscreteStatBarVisual barPrefabThe segment visual to spawn.
private float currentAlphaLast alpha set.
private float intervalPerBarStat value each segment stands for.
private int lastValueLast whole number of segments shown.
private DiscreteStatBarVisual[] spawnedBarsThe spawned segments.
private StatBar visibilityDecidorThe StatBar whose visibility this bar follows.

Methods​

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