UiSpellIcons
The UiSpellIcons class renders the spell/utility icon bar containing the "Heal Towers" spell and the "Timeout" utility item. It handles casting spells, buying the Pause item, animated cooldown overlays, and tooltip display with resource costs.
UiSpellIcons private
Extends UiComponent.
Properties
| Name | Type | Description |
|---|---|---|
ui | Ui | Current Ui instance. Inherited from UiComponent. |
componentElem | HTMLElement | The root #hud-spell-icons DOM element. Inherited from UiComponent. |
iconElems | Record<string, HTMLElement> | Map of spell/item type strings to their .hud-spell-icon elements. |
Methods
constructor()
function constructor(ui: Ui): voidInitializes spell icon elements for HealTowersSpell and TimeoutItem, binds click handlers and UiTooltip instances (anchored right, showing resource costs), and registers listeners for wavePaused, inventoryUpdate, spellSchemaUpdate events and the CastSpellResponse RPC.
onIconClick()
function onIconClick(type: string): (event: MouseEvent) => voidReturns a click handler that calls useHealSpell() or useTimeoutItem() based on type. No-op if disabled or on cooldown.
useHealSpell()
function useHealSpell(): voidCancels all active overlays and starts casting via SpellOverlay.startCasting('HealTowersSpell').
useTimeoutItem()
function useTimeoutItem(): voidSends a BuyItem RPC for the Pause item.
onWavePaused()
function onWavePaused(): voidStarts the cooldown animation on the TimeoutItem icon using the Pause schema's purchaseCooldown.
onInventoryUpdate()
function onInventoryUpdate(): voidToggles is-disabled on the TimeoutItem icon based on whether the Pause item is in inventory.
onSpellSchemaUpdate()
function onSpellSchemaUpdate(): voidEnables spell icons that have cooldownTiers defined in their schema.
onCastSpellResponse()
function onCastSpellResponse(response: { spell: string, cooldown: number, cooldownStartTick: number }): voidHandles the CastSpellResponse RPC. Calculates the start timestamp adjusted for tick lag and starts the cooldown animation.
startCooldownForIcon()
function startCooldownForIcon(type: string, duration: number, startTimestamp?: number | null): voidAnimates a circular cooldown overlay using CSS linear-gradient rotation on the left/right cooldown half-elements. Uses requestAnimationFrame for smooth animation over the specified duration.