Skip to main content

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.

Constructors​

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

Fields​

18 private and internal fields
MemberWhat it is
private readonly int _AlphaLimitShader property ID for _AlphaLimit.
private float alphaBacking field for Alpha.
private float alphaLerpSpeedHow fast alpha fades per second.
private StatBarBase[] barsStat bars in this group.
private Transform barsParentRuntime parent object the bars are moved under.
private Transform[] bodyTypeScalingTransforms scaled to match the character's body type.
private Transform cachedTransformCached transform of this object.
private Transform cameraTargetThe local player's camera transform.
private float gauntletOffsetSerialized forward offset for the bars. Not used by UpdateGauntlet in this build.
private bool isDownedTrue while the player is in the downed state.
private bool isInCombatTrue while the player is in the combat state.
private bool isLookingAtWhether the player is currently looking at the bars.
private float lookAtLeniencyDot threshold above which the bars count as looked at.
private float lookAwayLeniencyDot threshold below which the bars stop counting as looked at.
private Material notchesBaseMaterialNotch material cloned on Android so its alpha can be set.
private Material notchesMaterialAndroid-only clone of the notch material.
private PlayerController playerThe player controller these bars belong to.
private float rotationSpeedMaximum rotation step per frame toward the camera. 0 turns facing off.

Properties​

MemberWhat 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
MemberWhat it is
private bool CanUpdateAlpha { get; }True unless the player is in combat or downed.

Methods​

MemberWhat it is
void PingStatBars(float duration)Pings every bar for the given duration.
15 private and internal methods
MemberWhat 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: