Inspirationbadge
Based on game build 714014 | Last updated: 2026-03-08
Overview
InspirationBadge is a UI widget component that renders Wathgrithr's Inspiration status panel. It extends Badge and manages two sets of animated slots (3 total): one for active Inspiration levels (depletion meter), and one for displayed buff icons. It handles client-side updates including animation transitions, sound feedback, and visual sync with server state, particularly to minimize perceived jitter during network lag.
Usage example
-- Typically instantiated automatically by Wathgrithr's prefab.
-- For modder reference:
local badge = InspirationBadge(owner, "inspiration_colour")
badge:OnUpdateSlots(2) -- Activate first 2 slots
badge:OnBuffChanged(1, "WATHGRITHR_INSPIRATION_BERSERK") -- Show berserk buff in slot 1
badge:EnableClientPredictedDraining(true) -- Start client-side meter countdown
Dependencies & tags
Components used: None identified
Tags: None identified
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
_clientpredicteddraining | boolean | false | Whether client-side meter draining is currently active. |
slots | table (array of UIAnim) | {} | Array of 3 UIAnim widgets representing the depletion meter slots. |
buffs | table (array of UIAnim) | {} | Array of 3 UIAnim widgets representing active buff icons. |
num_active_slots | number | 0 | Current number of active (lit) meter slots displayed. |
percent | number | undefined | Current Inspiration meter percentage (used in OnUpdate). |
Main functions
OnUpdateSlots(num)
- Description: Updates the number of active meter slots (0–3) to reflect current Inspiration level. Plays activation/deactivation animations and triggers sound effects.
- Parameters:
num(number) — the target number of active slots. Must be between0andNUM_SLOTS(inclusive). - Returns: Nothing.
OnBuffChanged(num, name)
- Description: Updates the buff icon in a given slot. If
nameis non-nil, sets the icon and plays an activation animation; ifnameisnil, plays deactivation and resets tobuff_off. - Parameters:
num(number) — the slot index (1–NUM_SLOTS).name(string?) — the animation/sprite name for the buff icon, ornilto clear.
- Returns: Nothing.
- Error states: No-op if
numis out of bounds orself.buffs[num]isnil.
EnableClientPredictedDraining(enable)
- Description: Starts or stops the client-side meter countdown (used to reduce visual lag). Calls
StartUpdating/StopUpdatingaccordingly. - Parameters:
enable(boolean?) — whether to enable draining. Defaults tofalseif omitted. - Returns: Nothing.
OnUpdate(dt)
- Description: Decrements the local
percentover time usingTUNING.INSPIRATION_DRAIN_RATE. Called only ifEnableClientPredictedDraining(true)was previously set and the server is not paused. - Parameters:
dt(number) — delta time in seconds since last frame. - Returns: Nothing.
- Error states: Early exit if
TheNet:IsServerPaused()is true.
Events & listeners
- Listens to: None identified
- Pushes: None identified