К содержимому

SusEquipmentSlot

SusEquipmentSlot

Слот снаряжения — label, empty/filled chrome, иконка экипированного SusInventoryItem, drop highlight, context menu.

Пакет

SusGame · Инвентарь (коммерческий)

Открыть в песочнице

SusGame · Inventory

Свойства

ИмяТипПо умолчанию
SlotIdProp<string>""v-model
SlotNameProp<string>""v-model
SlotIconProp<string>""v-model
EquippedItemProp<ItemInstance>nullv-model
HighlightedProp<int>0v-model
RarityProp<string>""v-model

Слоты

Слотов нет.

События

ИмяПолеPayload
SlotClickOnSlotClickstring
ItemClickedOnItemClickedSusInventoryItem, string
ItemDragStartOnItemDragStartSusInventoryItem, string
ItemDragEndOnItemDragEndSusInventoryItem
ItemDraggingOnItemDraggingSusInventoryItem, Vector2
ItemContextActionOnItemContextActionstring, SusInventoryItem

Хуки стиля

Контракт USS-классов — внешний вид переопределяется без правки C#. Состояния переключаются этими классами:

  • sus-equipment-slot
  • sus-equipment-slot__bg
  • sus-equipment-slot__frame
  • sus-equipment-slot__frame--rarity-common
  • sus-equipment-slot__frame--rarity-epic
  • sus-equipment-slot__frame--rarity-exotic
  • sus-equipment-slot__frame--rarity-legendary
  • sus-equipment-slot__frame--rarity-rare
  • sus-equipment-slot__frame--rarity-uncommon
  • sus-equipment-slot__icon
  • sus-equipment-slot__label
  • sus-equipment-slot--empty
  • sus-equipment-slot--filled
  • sus-equipment-slot--highlight-candidate
  • sus-equipment-slot--highlight-invalid
  • sus-equipment-slot--highlight-valid
  • sus-inventory-item

Использование

Предпочитайте родительский SusEquipmentPanel (или сессию SusInventory) — панель задаёт id/размер/категории и отрисовывает предмет. Отдельно — для Storybook / кастомного paper-doll:

csharp
var slot = new SusEquipmentSlot();
slot.SlotId.Value = "helm";
slot.SlotName.Value = "Helmet";
slot.GridWidth = 2;
slot.GridHeight = 2;
slot.CellSize = 48f;
slot.ItemMedia = "image";
slot.CellLayout = "grid";
slot.AllowedCategories = new[] { "armor" };
slot.Model = model;
slot.EquippedItem.Value = equippedInstance; // or null
slot.OnSlotClick += id => { /* unequip path */ };
slot.OnItemClicked += (item, id) => { /* select */ };
slot.UpdateItemIcon();
xml
<template>
  <sus:SusEquipmentSlot :SlotId="Id.Value"
                        :SlotName="Name.Value"
                        :Highlighted="Hl.Value" />
</template>

<script>
public Prop<string> Id = new("helm");
public Prop<string> Name = new("Helmet");
public Prop<int> Hl = new(0);
// EquippedItem / Model / AllowedCategories — set from C# after mount.
</script>
Prop / APIРоль
SlotId / SlotNameИдентификатор + подпись
EquippedItemПривязанный ItemInstance (null = пусто)
Highlighted0 нет · 1 valid · 2 invalid · 3 candidate
GridWidth / GridHeight / CellSizeРазмер в px = ячейки × size
AllowedCategoriesФильтр категорий для Accepts(ItemDef)
UpdateItemIcon()Перерисовать иконку экипированного предмета из Model
Accepts(def)Проверка категории
OnSlotClick / OnItem* / OnItemContextActionСобытия

Заметки

  • Контекстные действия над предметом: equip / unequip / delete (как у предметов сумки).
  • Клик по пустому chrome вызывает OnSlotClick(SlotId) — раскладка сумки снимает предмет обратно в сумку; экипировка открывает флайаут категории (владеет shell).
  • Значения Highlighted совпадают с SusInventoryCell.