StatBarSimple
A class in Root.Township, Alta.StatSystem.
A stat bar (such as health or hunger) drawn by one renderer's shader: a fill, a trailing change band that lerps after it, and optional corner notches. Client side.
- Listed in Stats, effects, heat and liquid
- Inherits or implements
StatBarBase - Derived types
StatBar - Nested types
IsLerping,MaterialValue - Attributes
RequireComponent - Documented in Stats
Constructors
| Member | What it is |
|---|---|
StatBarSimple() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
protected readonly int _AlphaLimit | Shader property ID for _AlphaLimit. |
protected StatBarSimple.MaterialValue fill | The animated fill value (_FillProgress). |
protected float lastMaximum | Starts at -1. Not changed in this class; for subclasses to track the stat maximum. |
9 private and internal fields
| Member | What it is |
|---|---|
private Renderer barRenderer | The bar's renderer; its material is copied per instance. |
private bool buildUpchange | If true, a drop doesn't reset the negative change marker to the last value. |
private AltaCoroutine changeAnimation | The running AnimateValues coroutine. |
private Renderer[] corners | Corner (notch) renderers that share CornerMaterial. |
private float decreaseLerpSpeed | Speed of the negative change marker. |
private float increaseLerpSpeed | Speed of the fill and positive change marker. |
private bool isUsingPositiveChange | If true, the bar shows a positive change marker; otherwise its shader value stays 0. |
private StatBarSimple.MaterialValue negativeChange | Shader value _NegativeChangeProgress, the trailing marker after a loss. |
private StatBarSimple.MaterialValue positiveChange | Shader value _PositiveChangeProgress, used only when isUsingPositiveChange is on. |
Properties
Events
| Member | What it is |
|---|---|
event StatBarSimple.IsLerping Lerping | Raised each frame while animating. Handlers set the flag to keep the animation going. |
Methods
| Member | What it is |
|---|---|
virtual void ForceNotchMaterial(Material notchesMaterial) | Puts a given material on all corner renderers. |
override void Initialize() | Copies the bar and corner materials and sets the fill and change values from the tracked stat. |
override void SetAlpha(float alphaMultiplier) | Sets _AlphaLimit on the bar and corner materials as well as the base alpha. |
protected override void OnStatChanged(Stat stat) | Updates the fill and change bands to the stat's new value and starts the animation. |
protected override void SetRenderersEnabled(bool isEnabled) | Shows or hides the bar and corner renderers. |
4 private and internal methods
| Member | What it is |
|---|---|
private IEnumerator AnimateValues() (iterator) | Coroutine that runs the Lerping handlers each frame until none of the material values is still moving. |
private void OnBecameInvisible() | Disables the bar when its renderer goes off screen, unless a photo is being taken. |
private void OnBecameVisible() | Re-enables the bar when its renderer comes on screen, unless a photo is being taken. |
private void UpdateValue(Stat stat) | Sets the fill and change shader values from the stat's new value; drops snap at once, gains lerp in. |
Used in
Members of other types that take, return or hold a StatBarSimple: