Skip to main content

StatBarBase

A class in Root.Township, Alta.StatSystem.

Base for a bar that shows one stat (such as on the player's wrist). Hides itself while the hand camera takes a photo. Client side.

Constructors​

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

Fields​

MemberWhat it is
protected bool isTakingPhotoTrue while the hand camera is rendering a photo.
protected Stat trackedStatThe stat instance being shown.
protected StatDefinition trackedStatDefinitionThe stat to look up and show.
protected StatBarVisibilityGroup visibilityGroupThe group that holds the stat manager and controls visibility.

Properties​

MemberWhat it is
Stat Stat { get; }The stat being shown.

Events​

MemberWhat it is
event Action<bool> UpdatedVisibilityRaised when the bar becomes visible or hidden.

Methods​

MemberWhat it is
void Disable()Stops listening to the stat and the camera.
virtual void Initialize()Finds the tracked stat in the visibility group's stat manager and listens for changes. Hides the bar if the stat is missing.
virtual void Ping(float duration)Asks the bar to draw attention for a duration. Empty in the base class.
virtual void SetAlpha(float alphaMultiplier)Fades the bar. Empty in the base class.
protected void OnBecameVisibleChanged(bool isVisible)Raises UpdatedVisibility for subclasses.
protected virtual void OnDestroy()Stops listening to the hand camera.
protected virtual void OnStatChanged(Stat stat)Called when the stat changes, and once after initialising. Empty in the base class.
protected virtual void SetRenderersEnabled(bool isEnabled)Shows or hides the bar's renderers. Empty in the base class.
3 private and internal methods
MemberWhat it is
private void DelayInitialize()Runs one frame later to show the tracked stat's starting value.
private void OnTakingPhoto(HandCamera handCamera, HandCameraEvent cameraEvent)Hides the bar while a hand camera photo is rendered.
private void OnTookPhoto(HandCamera handCamera, HandCameraEvent cameraEvent)Shows the bar again after the photo, if its visibility group is on.

Used in​

Members of other types that take, return or hold a StatBarBase: