StatBarVisibilityGroup
A class in Root.Township, Alta.StatSystem.
Client: a group of stat bars on the local player's body that turns to face the camera and fades in when looked at. Forced visible in combat and hidden while downed; destroyed on remote players and on death.
- Listed in Stats, effects, heat and liquid
- Inherits or implements
MonoBehaviour
Constructors
| Member | What it is |
|---|---|
StatBarVisibilityGroup() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
18 private and internal fields
| Member | What it is |
|---|---|
private readonly int _AlphaLimit | Shader property ID for _AlphaLimit. |
private float alpha | Backing field for Alpha. |
private float alphaLerpSpeed | How fast alpha fades per second. |
private StatBarBase[] bars | Stat bars in this group. |
private Transform barsParent | Runtime parent object the bars are moved under. |
private Transform[] bodyTypeScaling | Transforms scaled to match the character's body type. |
private Transform cachedTransform | Cached transform of this object. |
private Transform cameraTarget | The local player's camera transform. |
private float gauntletOffset | Serialized forward offset for the bars. Not used by UpdateGauntlet in this build. |
private bool isDowned | True while the player is in the downed state. |
private bool isInCombat | True while the player is in the combat state. |
private bool isLookingAt | Whether the player is currently looking at the bars. |
private float lookAtLeniency | Dot threshold above which the bars count as looked at. |
private float lookAwayLeniency | Dot threshold below which the bars stop counting as looked at. |
private Material notchesBaseMaterial | Notch material cloned on Android so its alpha can be set. |
private Material notchesMaterial | Android-only clone of the notch material. |
private PlayerController player | The player controller these bars belong to. |
private float rotationSpeed | Maximum rotation step per frame toward the camera. 0 turns facing off. |
Properties
| Member | What it is |
|---|---|
float Alpha { get; set; } | Group opacity, pushed to every bar. Ignored while in combat or downed. |
StatManager StatManager { get; } | Stat manager of the player's health object. |
1 private and internal property
Methods
| Member | What it is |
|---|---|
void PingStatBars(float duration) | Pings every bar for the given duration. |
15 private and internal methods
| Member | What it is |
|---|---|
private void AlignWithVision(bool isLerping, Vector3 right, Quaternion currentRotation) | Rotates the group around its right axis to face the camera, optionally limited by rotationSpeed. |
private void Awake() | Hides the group and waits for the local player to be set before initializing. |
private void CheckCombatState(IPlayerState playerState) | On entering the combat state, shows the bars fully and locks alpha. |
private void CheckDownedState(IPlayerState playerState) | On entering the downed state, hides the bars and locks alpha. |
private void Initialize(PlayerController controller) | Once the local player is set: destroys itself if not on the local player, otherwise parents and initializes the bars and hooks death, player state and body type events. |
private bool IsSkippingUpdateDueToLackOfInputFocusOnQuest() | On Quest, hides the bars and skips the update when the app has lost input focus. |
private void LateUpdate() | Faces the camera and fades alpha in or out depending on whether the player is looking at the bars. |
private void OnDestroy() | Unhooks the local player, death and player state events. |
private void OnEnable() | Grabs the local camera, snaps to face it and resets alpha. Disables itself if there is no camera. |
private void OnStateActivated(IPlayerState playerState) | Player state handler that runs the combat and downed checks. |
private void OnStateDeactivated(IPlayerState playerState) | Clears the combat or downed flag when that state ends. |
private void PlayerDeath(HealthObject health) | Disables all bars and destroys the group. |
private void SetupScaling(float scaleFactor) | Scales the body type transforms by the body type's stat bar distance ratio. |
private void UpdateGauntlet() | Resets the bars parent's forward offset. The offset is always 0 in this build. |
private void UpdateVisibility(bool isVisible) | Bar visibility handler: enables the group when any bar shows, disables it when none are enabled. |
Used in
Members of other types that take, return or hold a StatBarVisibilityGroup: