Hotbar reference
The hotbar component, the handler interface that teaches it new kinds of content, the slot state a view draws, and the handlers Vantage ships. For how to use it, see Hotbar.
VtHotbar
Component. Add it with Add Component → Vantage → Hotbar → VtHotbar.
A row of slots that hold anything the player can press: abilities, items such as potions, weapons and tools, buildables, or content of your own. Put it on the player next to VtUnit, fill the slots in the Inspector or with Assign, and each slot’s key presses it. A hotbar view reads every slot with Read and calls Assign, Move and Clear when the player drags content onto it, between slots or off it.
Inspector fields
| Field | Type | Default | Range | Description |
|---|---|---|---|---|
Slots (slots) |
VtHotbar.Slot[] | 6 entries | Slots in order. | |
First Ability Action (firstAbilityAction) |
int |
1 | ≥ 1 | Which numbered Ability action slot 1 reads when it has no action of its own. 1 = Ability 1, key 1 by default; 7 puts the first slot on key 7. |
Scripting API
| Member | Description |
|---|---|
IReadOnlyList<VtHotbar.Slot> Slots { get; } |
The slots in order. |
int SlotCount { get; } |
How many slots the bar has. |
int FirstAbilityAction { get; set; } |
Which numbered Ability action slot 1 reads; slot 2 reads the next one. |
event Action OnSlotsChanged |
Fires after a slot’s content changed through Assign, Move, Clear or a restore. |
event Action<int, Object, bool> OnSlotPressed |
Fires after a slot was pressed: (slot, content, whether it did something). |
static void RegisterHandler(IVtHotbarHandler handler) |
Teach every hotbar a kind of content. Handlers registered later are asked first, so one can replace a built-in handler for the content it claims. |
static void UnregisterHandler(IVtHotbarHandler handler) |
Forget a handler added with RegisterHandler. |
static IVtHotbarHandler HandlerFor(Object content) |
The handler for content, or null when no handler knows it. |
static bool CanHold(Object content) |
Whether a hotbar can hold content. A drag view asks this before it accepts a drop. |
Object GetContent(int slotIndex) |
What slot slotIndex holds, or null. |
bool Assign(int slotIndex, Object content) |
Put content in slot slotIndex, growing the bar if needed. Null clears the slot. False, and nothing changed, when no handler knows the content. |
void Clear(int slotIndex) |
Empty slot slotIndex. |
void AssignArea(VtInventoryAreaDefinition area, int firstSlot, int count) |
Show inventory slots on the bar: bar slots firstSlot onward show slots 0 to count - 1 of area, for a hotbar that is part of the inventory. |
bool Move(int from, int to) |
Move the content of slot from to slot to, swapping with what is there. Both must be existing slots. |
bool Press(int slotIndex) |
Press slot slotIndex as if its key was pressed. UI buttons call this. Returns whether it did something. |
InputAction GetAction(int slotIndex) |
The action slot slotIndex is pressed with, for key labels. Null when it has none. |
VtHotbarSlotState Read(int slotIndex) |
Slot slotIndex as a view draws it. An empty or unknown slot has no content and is not usable. |
void Read(List<VtHotbarSlotState> states) |
Fill states with every slot in order. The list is cleared first and reused. |
string[] CaptureSlots() |
Every slot as kind:id, an empty string for an empty slot. The save system writes this. |
void RestoreSlots(string[] saved, VtDefinitionCatalog catalog = null) |
Fill the slots from CaptureSlots output, resolving ids through catalog (the shared catalog when null). Unknown kinds and ids leave the slot empty with a warning. |
IVtHotbarHandler
Interface. Implemented by VtAbilityHotbarHandler, VtBuildableHotbarHandler, VtInventorySlotHotbarHandler, VtItemHotbarHandler.
Teaches VtHotbar one kind of slot content: how to draw it, what pressing it does and how it is saved. Vantage ships handlers for abilities, items and buildables; register one of your own with VtHotbar.RegisterHandler to put emotes, mounts or anything else on the bar.
Scripting API
| Member | Description |
|---|---|
string Kind { get; } |
Short, stable name for the content kind, written into save files as kind:id. Must not contain a colon. |
bool CanHold(Object content) |
Whether this handler draws and presses content. |
void Read(VtHotbar bar, Object content, ref VtHotbarSlotState state) |
Fill state for content on bar. The bar has already set VtHotbarSlotState.Content, VtHotbarSlotState.Kind and VtHotbarSlotState.Action, Count, Durability, DurabilityLeft and DurabilityMax to -1 and Usable to true. |
bool Activate(VtHotbar bar, Object content) |
Do what pressing content does. Returns whether it did something. |
string IdOf(Object content) |
The id content is saved under. |
Object Find(string id, VtDefinitionCatalog catalog) |
The content saved under id, or null. |
IVtHotbarSlotAwareHandler
Interface. Implemented by VtInventorySlotHotbarHandler.
A IVtHotbarHandler that also needs to know which bar slot it draws or presses, and that resolves saved ids against the bar’s own unit. VtHotbar calls these overloads instead of the plain ones when a handler implements them.
Scripting API
| Member | Description |
|---|---|
void Read(VtHotbar bar, int slotIndex, Object content, ref VtHotbarSlotState state) |
Like IVtHotbarHandler.Read, for bar slot slotIndex. |
bool Activate(VtHotbar bar, int slotIndex, Object content) |
Like IVtHotbarHandler.Activate, for bar slot slotIndex. |
Object Find(VtHotbar bar, string id, VtDefinitionCatalog catalog) |
Like IVtHotbarHandler.Find, able to look at bar’s unit. |
VtHotbarSlotState
Struct.
One VtHotbar slot as a hotbar view draws it, filled by the slot’s IVtHotbarHandler.
Scripting API
| Member | Description |
|---|---|
Object Content |
What sits in the slot: an ability, an item, a buildable, or content of your own. Null when empty. |
string Kind |
The handler’s IVtHotbarHandler.Kind, such as ability. Empty when the slot is empty. |
string DisplayName |
The name to show, already localized. |
Sprite Icon |
The icon, or null. |
string IconId |
An icon name from the package’s icon set, for content without a sprite. May be empty. |
int Count |
How many there are, such as potions in the bag. -1 when a count does not apply. |
float Durability |
Durability of the item, 0 to 1. -1 when it does not apply. |
int DurabilityLeft |
Durability the item has left, such as the uses of a tool. -1 when it does not apply. |
int DurabilityMax |
The item’s full durability, including copies combined into it. Durability is DurabilityLeft over this. -1 when it does not apply. |
bool Usable |
Whether pressing the slot can succeed right now: affordable, carried, available. |
bool Active |
Whether the content is in use: an ability being aimed, a piece being placed, an item worn. |
bool Locked |
Whether the slot is not open yet, such as a bar slot past the current size of the inventory area it shows until a backpack is worn. A view draws a lock; pressing it does nothing. |
float CooldownFraction |
Cooldown left over its full length, 0 to 1, with the global cooldown folded in. |
float CooldownRemaining |
Seconds of cooldown left. |
InputAction Action |
The input action that presses the slot, for its key label. Null when it has none. |
VtAbilityHotbarHandler
Class.
Puts a VtAbilityDefinition on a VtHotbar. Pressing it casts through the unit’s VtAbilityHotkeys when it has one, so targeting and aiming work as on the ability bar, and at the caster otherwise. The slot shows the cooldown with the global cooldown folded in, turns unusable while the unit cannot pay, and is active while the ability is being aimed.
Scripting API
| Member | Description |
|---|---|
string Kind { get; } |
Always ability. |
bool CanHold(Object content) |
True for a VtAbilityDefinition. |
void Read(VtHotbar bar, Object content, ref VtHotbarSlotState state) |
Fill the slot with the ability’s name and icon, its cooldown with the global cooldown folded in, whether the unit can pay its cost, and whether it is being aimed. |
bool Activate(VtHotbar bar, Object content) |
Cast the ability through the unit’s VtAbilityHotkeys, with its targeting and aiming, or at the caster when the unit has none. Returns whether the press succeeded. |
string IdOf(Object content) |
The ability’s id. |
Object Find(string id, VtDefinitionCatalog catalog) |
The ability saved under id in catalog, or null. |
static void ReadCooldown(VtUnitAbilities abilities, VtAbilityDefinition ability, ref VtHotbarSlotState state) |
Fill the cooldown of ability on abilities into state, the global cooldown included unless the ability ignores it. |
VtItemHotbarHandler
Class.
Puts a VtItemDefinition on a VtHotbar. Pressing an item with an equipment slot wears it from the bag, such as switching to the axe, and pressing it again puts it back in the bag; pressing any other item uses it from the bag, aimed through the unit’s VtAbilityHotkeys when its use ability needs a target. The slot shows how many are in the bag, the durability of the worn one, the use ability’s cooldown, and is active while worn.
Scripting API
| Member | Description |
|---|---|
string Kind { get; } |
Always item. |
bool CanHold(Object content) |
True for a VtItemDefinition. |
void Read(VtHotbar bar, Object content, ref VtHotbarSlotState state) |
Fill the slot with the item’s name and icon, how many are in the bag, the worn copy’s durability, the use ability’s cooldown, and whether it is worn. |
bool Activate(VtHotbar bar, Object content) |
Wear an item with an equipment slot from the bag, or put it back when it is worn; use any other item from the bag, aimed through the unit’s VtAbilityHotkeys when its use ability needs a target. Returns whether it worked. |
string IdOf(Object content) |
The item’s id. |
Object Find(string id, VtDefinitionCatalog catalog) |
The item saved under id in catalog, or null. |
VtBuildableHotbarHandler
Class.
Puts a VtBuildableDefinition on a VtHotbar. Pressing it starts placing the piece with the unit’s VtUnitBuilder; pressing it again while it is being placed stops. The slot is unusable while the piece is locked or cannot be paid for, and active while it is being placed.
Scripting API
| Member | Description |
|---|---|
string Kind { get; } |
Always buildable. |
bool CanHold(Object content) |
True for a VtBuildableDefinition. |
void Read(VtHotbar bar, Object content, ref VtHotbarSlotState state) |
Fill the slot with the piece’s name and icon, whether the unit’s builder can place it now, and whether it is being placed. |
bool Activate(VtHotbar bar, Object content) |
Start placing the piece, or stop when it is already being placed. False when the unit has no VtUnitBuilder or placement could not start. |
string IdOf(Object content) |
The buildable’s id. |
Object Find(string id, VtDefinitionCatalog catalog) |
The buildable saved under id in catalog, or null. |
VtInventorySlotHotbarHandler
Class.
Puts inventory slots on a VtHotbar, for games where the hotbar is part of the inventory. Put an VtInventoryAreaDefinition in bar slots (or call VtHotbar.AssignArea): the first bar slot holding that area shows the area’s slot 0, the next one slot 1, and so on. Each bar slot shows that stack’s icon, count and wear, not the bag’s total, so two stacks of wood are two slots.
Scripting API
| Member | Description |
|---|---|
string Kind { get; } |
Always invslot. |
bool CanHold(Object content) |
True for a VtInventoryAreaDefinition. |
void Read(VtHotbar bar, Object content, ref VtHotbarSlotState state) |
Fill the state for the area’s first slot. VtHotbar calls the overload with the bar slot’s index instead. |
bool Activate(VtHotbar bar, Object content) |
Press the area’s first slot. VtHotbar calls the overload with the bar slot’s index instead. |
void Read(VtHotbar bar, int slotIndex, Object content, ref VtHotbarSlotState state) |
Fill the state for the inventory slot bar slot slotIndex stands for: its stack’s name, icon, count and wear, whether it is locked, and whether the held slot has it selected. |
bool Activate(VtHotbar bar, int slotIndex, Object content) |
Select the inventory slot bar slot slotIndex stands for when the unit’s VtUnitHeldSlot uses the area; pressing the selected slot again uses its item or puts it on. Without a held slot, uses the item or puts it on. Returns whether it did something. |
string IdOf(Object content) |
The area’s id. |
Object Find(string id, VtDefinitionCatalog catalog) |
Always null: an area is found through the bar’s unit, with the overload that takes the bar. |
Object Find(VtHotbar bar, string id, VtDefinitionCatalog catalog) |
The area with id on the bar unit’s held slot or inventory, or null. |
static int IndexIn(VtHotbar bar, Object area, int slotIndex) |
Which slot of the area bar slot slotIndex stands for: how many bar slots before it hold the same area. |
VtHotbar.Slot
Serializable struct.
One input bound to one piece of content. Empty content leaves the input unused.
Inspector fields
| Field | Type | Default | Description |
|---|---|---|---|
Action (action) |
InputActionReference |
None | Action that presses this slot. Empty uses the numbered Ability action for the slot’s position. |
Content (content) |
Object |
None | What the slot holds: an ability, an item, a buildable, or content a registered handler knows. |