Skip to content

SusAbilityBar ​

SusAbilityBar

Horizontal ability strip — rebuilds SusAbilitySlot children, fills from SusHudAbilityData, digits 1…N activate when not in hold mode.

Package

SusGame · HUD (commercial)

Open in Playground

SusGame · HUD

Props

NameTypeDefault
SlotCountProp<int>4
UseHoldProp<bool>false
KeyScopeProp<string>"focus"

Slots

No slots.

Events

NameFieldPayload
AbilityActivatedOnAbilityActivatedint
AbilityHoldCompleteOnAbilityHoldCompleteint

Style hooks ​

USS class contract — override appearance without touching C#. States toggle via these classes:

  • sus-ability-bar
  • sus-hidden

Usage ​

Drive slot contents from code with SetAbilities. XML only sets layout/mode props.

csharp
var bar = new SusAbilityBar();
bar.SlotCount.Value = 4;
bar.UseHold.Value = false;
bar.OnAbilityActivated += index => { /* cast / spend AP */ };
bar.OnAbilityHoldComplete += index => { /* charged cast */ };

bar.SetAbilities(new List<SusHudAbilityData>
{
    new() { Id = "strike", Icon = "sword", Title = "Strike", Keybind = "1" },
    new() { Id = "heal", Icon = "plus", Title = "Heal", Cooldown01 = 0.4f, CooldownText = "2s" },
    new() { Id = "shield", Icon = "shield", Title = "Guard", Disabled = true },
});
xml
<template>
  <sus:SusAbilityBar :SlotCount="Slots.Value"
                     :UseHold="Hold.Value"
                     @ability-activated="OnAbilityActivated"
                     @ability-hold-complete="OnAbilityHoldComplete" />
</template>

<script>
public Prop<int> Slots = new(4);
public Prop<bool> Hold = new(false);
void OnAbilityActivated(int index) { /* … */ }
void OnAbilityHoldComplete(int index) { /* … */ }
// Call SetAbilities / UpdateAbility from combat code after mount.
</script>
Prop / APIRole
SlotCountSlot count (1…10, default 4)
UseHoldPropagates hold mode to every slot
SetAbilities(list)Resize + fill from SusHudAbilityData
UpdateAbility(i, data)Patch one slot
GetSlot(i)Access child SusAbilitySlot
OnAbilityActivatedIndex of activated slot
OnAbilityHoldCompleteIndex after hold completes
ActivateSlot(i)Activate slot i from your own input — same as a click
KeyScopeWhere the bar listens for keys: "focus" (default) or "panel"

Ability keys ​

By default ability input stays on the game side: your game reads its own input and calls ActivateSlot(index). That call works exactly like a click — it raises OnAbilityActivated unless the slot is a hold slot, disabled or on cooldown.

csharp
// in your input handler
if (Input.GetKeyDown(KeyCode.Q)) bar.ActivateSlot(0);

KeyScope chooses where the bar itself listens for keys:

  • "focus" (default): digits 1–9 (top row or keypad) activate slot N-1, but only while the bar has focus. In battle the focus is usually elsewhere, so these keys do nothing there.
  • "panel": the bar listens on the whole panel while it is attached, no focus needed. The pressed key is matched against each slot's Keybind string — a digit, a letter or a KeyCode name such as F1. Keys typed into a text field are ignored, hold slots are not activated by a key, and only a key bound to a slot stops propagation.

Notes ​

  • Empty until SetAbilities (or host/Assembler fills slots). Calling before mount queues until Mounted.
  • SusHudAbilityData: Id, Icon, Title, Description, Cooldown01 (0 ready … 1 full), CooldownText, Disabled, optional Keybind (empty → index+1).
  • Prefer the bar over hand-wiring many SusAbilitySlot instances when you need a shared key contract.