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

SusInventoryItem ​

SusInventoryItem

Предмет на сетке: иконка, rarity-рамка, stack, durability, drag & drop, context menu.

Пакет

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

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

SusGame · Inventory

Свойства

ИмяТипПо умолчанию
IconProp<string>""v-model
RarityProp<string>"common"v-model
StackCountProp<int>1v-model
DurabilityProp<float>100fv-model
IsEquippedProp<bool>falsev-model
IsDraggingProp<bool>falsev-model
IsSelectedProp<bool>falsev-model
ShowNameProp<bool>falsev-model
ItemNameProp<string>""v-model
MediaModeProp<string>"image"v-model

Слоты

Слотов нет.

События

ИмяПолеPayload
DragStartOnDragStartSusInventoryItem
DragEndOnDragEndSusInventoryItem
DraggingOnDraggingSusInventoryItem, Vector2
ItemClickedOnItemClickedSusInventoryItem
ContextActionOnContextActionstring, SusInventoryItem

Хуки стиля ​

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

  • sus-hidden
  • sus-img
  • sus-img__error
  • sus-img__placeholder
  • sus-img__surface
  • sus-img--rounded-md
  • sus-img--rounded-sm
  • sus-inv-ghost
  • sus-inv-ghost__glyph
  • sus-inv-ghost__image
  • sus-inv-ghost__stack
  • sus-inv-ghost--common
  • sus-inv-ghost--epic
  • sus-inv-ghost--exotic
  • sus-inv-ghost--legendary
  • sus-inv-ghost--rare
  • sus-inv-ghost--uncommon
  • sus-inventory-item
  • sus-inventory-item__durability-fill
  • sus-inventory-item__durability-fill--good
  • sus-inventory-item__durability-fill--low
  • sus-inventory-item__durability-fill--warn
  • sus-inventory-item__durability-track
  • sus-inventory-item__glyph
  • sus-inventory-item__image
  • sus-inventory-item__name
  • sus-inventory-item__rarity
  • sus-inventory-item__stack
  • sus-inventory-item__tip
  • sus-inventory-item--dragging
  • sus-inventory-item--equipped
  • sus-inventory-item--long-press
  • sus-inventory-item--media-icon
  • sus-inventory-item--media-image
  • sus-inventory-item--rarity-common
  • sus-inventory-item--rarity-epic
  • sus-inventory-item--rarity-exotic
  • sus-inventory-item--rarity-legendary
  • sus-inventory-item--rarity-rare
  • sus-inventory-item--rarity-uncommon
  • sus-inventory-item--selected
  • sus-tooltip--inventory

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

Предпочитайте родительский SusInventory через SusInventorySession — не размещайте предметы-сироты без сетки/модели. Отрисовка сетки задаёт Item / Def / props иконки автоматически.

csharp
// Session mounts SusInventory; items get Def + DnD + tooltip automatically
var session = SusInventorySession.Attach(host);
session.Configure(SusInventorySystemParams.PackedGrid);
session.SetCatalog(defs);
session.SeedItems(seeds);
session.Apply();

Отдельный chrome (Storybook / кастомная иконка):

csharp
var item = new SusInventoryItem();
item.Icon.Value = "SusGameDemo/Items/sword";
item.Rarity.Value = "rare";
item.StackCount.Value = 3;
item.Durability.Value = 72f;
item.MediaMode.Value = "image"; // image | icon
item.IsEquipped.Value = false;
item.IsSelected.Value = false;
item.Def = itemDef;             // tooltip content
item.OnItemClicked += ii => { /* select */ };
item.OnContextAction += (action, ii) => { /* equip|unequip|delete */ };
xml
<template>
  <sus:SusInventoryItem :Icon="Icon.Value"
                        :Rarity="Rarity.Value"
                        :StackCount="Stack.Value"
                        :Durability="Dura.Value"
                        :MediaMode="Media.Value"
                        :IsEquipped="Eq.Value"
                        :IsSelected="Sel.Value" />
</template>

<script>
public Prop<string> Icon = new("SusGameDemo/Items/sword");
public Prop<string> Rarity = new("rare");
public Prop<int> Stack = new(3);
public Prop<float> Dura = new(72f);
public Prop<string> Media = new("image");
public Prop<bool> Eq = new(false);
public Prop<bool> Sel = new(false);
</script>
Prop / APIРоль
IconПуть в Resources (image) или ключ icon-set (MediaMode=icon)
Raritycommon…exotic → BEM --rarity-*
StackCountБейдж при > 1
Durability0…100; полоса скрыта при 100
IsEquipped / IsDragging / IsSelectedКлассы состояния
MediaModeimage (заливка SusImg) | icon (глиф SusIcon)
Item / DefСсылки на модель (tooltip + идентичность DnD)
ShowNameПоказывает плашку sus-inventory-item__name (текст из Def.Name, иначе Def.Id). По умолчанию false — существующие раскладки сохраняют свой вид
OnDrag* / OnItemClicked / OnContextActionУказатель и меню

Всплывающая подсказка ​

Использует SusTooltip (слой Tooltip в OverlayHost). Нативный UITK tooltip очищается. Содержимое берётся из ItemDef (name, rarity · category · subcategory, description, weight, modifiers). Тайминг / строки: родительский SusInventorySystemParams.

Корень подсказки — hover-триггер (у предмета инвентаря это обёртка #ItemTip на всю ячейку), а не карточка. Он несёт sus-item-tooltip__trigger и сохраняет sus-item-tooltip. Карточка несёт sus-item-tooltip__card и сохраняет его после переезда в overlay-хост. Оформляйте карточку через .sus-item-tooltip__card, тогда правило карточки никогда не попадёт на ячейку:

css
.sus-item-tooltip__card { min-width: 280px; }
.sus-item-tooltip__card .sus-tooltip__header { padding: 8px 12px; }
.sus-item-tooltip__trigger { /* the cell wrapper, if you need it */ }

Части карточки — унаследованные элементы SusTooltip (__header, __header-title, __header-type, __hero, __bars, __footer), к ним обращаются как .sus-item-tooltip__card .sus-tooltip__<part>.

Заметки ​

  • Контекстные действия: equip | unequip | delete.
  • Порог перетаскивания / ghost host берутся из родительской сетки / shell — задайте GhostHost перед DnD.
  • Предпочитайте Session предметам-сиротам, чтобы rarity / tooltip / DnD оставались согласованными.

См. также ​