SusInventoryGrid

Packed bag mesh — пересобирает ячейки + иконки SusInventoryItem из InventoryGrid + InventoryModel, DnD / click-to-place / context menu.
Пакет
SusGame · Инвентарь (коммерческий)
Свойства
Публичных свойств нет.
Слоты
Слотов нет.
События
| Имя | Поле | Payload |
|---|---|---|
ItemDragStart | OnItemDragStart | SusInventoryItem |
ItemDragEnd | OnItemDragEnd | SusInventoryItem |
ItemDragging | OnItemDragging | SusInventoryItem, Vector2 |
ItemClicked | OnItemClicked | SusInventoryItem |
EmptyCellClicked | OnEmptyCellClicked | int, int |
ItemContextAction | OnItemContextAction | string, SusInventoryItem |
Хуки стиля
Контракт USS-классов — внешний вид переопределяется без правки C#. Состояния переключаются этими классами:
sus-inventory-grid
Использование
Предпочитайте родительский SusInventory через SusInventorySession — оболочка назначает Grid / Model и вызывает Refresh. Отдельно:
csharp
var grid = new SusInventoryGrid();
grid.Model = model;
grid.Grid = model.Grids["bag"];
grid.CellSize = 48f;
grid.CellGap = 0f; // pitch = CellSize + CellGap
grid.ItemMedia = "image"; // image | icon
grid.CellLayout = "grid"; // grid (multi-cell) | slots (1×1)
grid.GhostHost = ghostOverlay;
grid.IconResolver = myResolver;
grid.OnItemClicked += item => { /* select */ };
grid.OnEmptyCellClicked += (x, y) => { /* click-to-place */ };
grid.OnItemDragStart += item => { /* … */ };
grid.OnItemContextAction += (action, item) => { /* equip|unequip|delete */ };
grid.Refresh();xml
<template>
<sus:SusInventoryGrid />
</template>
<script>
// No Prop<> on the grid — assign Grid / Model / sizes from C#, then Refresh.
// Events: OnItemDragStart|End|Dragging, OnItemClicked, OnEmptyCellClicked, OnItemContextAction.
</script>| Prop / API | Роль |
|---|---|
Grid / Model | Ячейки из Grid.Def; иконки из Grid.Items + ItemDefs |
CellSize / CellGap | Размер в пикселях + зазор (шаг) |
ItemMedia / CellLayout | Передаётся предметам / разрешению footprint |
Refresh() / SyncItems() | Полная пересборка vs синхронизация иконок предметов |
HighlightCells / HighlightDropPreview / ClearHighlight | Превью DnD |
OnItem* / OnEmptyCellClicked | События предмета и пустой ячейки |
Заметки
- Пусто, пока не заданы
Grid+Grid.Defи не выполненRefresh. - Многоклеточные предметы занимают footprint
ItemDef(grid);slotsпринудительно делает 1×1. - Предпочитайте grid ручной расстановке SusInventoryCell / SusInventoryItem, когда нужен общий DnD.