Skip to content

t1k:unity:editor:dots-inventory-grid

FieldValue
Moduleeditor
Version2.1.7
Efforthigh
Tools

Keywords: DOTS, grid, inventory, UI

/t1k:unity:editor:dots-inventory-grid

DOTS Inventory Grid, Passives & Set Bonuses

Section titled “DOTS Inventory Grid, Passives & Set Bonuses”

Extensions to com.the1studio.dots-inventory Inventory module. Base module (slots, equipment, loot, currency, crafting) → See dots-rpg skill references/inventory-guide.md.

Related skills: dots-rpg · dots-ecs · dots-jobs-burst


  • Adding InventoryGridDimension, InventoryGridCell, ItemGridShape, ItemGridPosition, ItemRotation
  • Calling InventoryGridUtility.CanPlace, .PlaceItem, .FindFirstFit, .GetEffectiveDimensions
  • Using expansion APIs: CanPlaceExpansion, ActivateCells, IsAdjacentToActive, CountActiveCells
  • Adding ItemPassiveEffect buffer to items; using PassiveCondition.InInventory or .EquippedOnly
  • Adding ItemSetMembership, SetBonusDefinition; implementing set threshold rewards
  • Using ModifierSource.ItemPassive or ModifierSource.ItemSet in stat modifier logic

ComponentTypeFieldsOwner
InventoryGridDimensionIComponentDataint GridWidth, GridHeightCharacter — opt-in gate
InventoryGridCellIBufferElementDataEntity ItemEntity, byte IsActiveCharacter — W×H flat array
ItemGridShapeIComponentDataint DefaultWidth, DefaultHeightItem entity
ItemGridPositionIComponentDataint GridX, GridYItem entity — (-1,-1) = unplaced
ItemRotationIComponentDatabyte RotationIndexItem entity — 0..3
ItemNoRotationTagIComponentData (zero-size)Item — prevents rotation
ItemLockedTagIComponentData (zero-size)Item — prevents movement
ItemShapeMaskIBufferElementDataint2 OffsetItem — polyomino shape (opt-in)
ComponentTypeFieldsOwner
ItemPassiveEffectIBufferElementDataStatType, ModifierType, float Value, PassiveConditionItem entity

PassiveCondition enum: InInventory (always active) · EquippedOnly (only when in EquippedItem buffer)

ComponentTypeFieldsOwner
ItemSetMembershipIComponentDataint SetIdItem entity
SetBonusDefinitionIBufferElementDataint SetId, int RequiredCount, StatType, ModifierType, float ValueWorld singleton

RespawnReset (OrderFirst)
→ PickupSystem
→ GridPlacementSystem [UpdateAfter(Pickup), UpdateBefore(Equipment)]
→ ItemSetBonusSystem [UpdateAfter(Pickup), UpdateBefore(Equipment)]
→ PassiveEffectSystem [UpdateAfter(Pickup), UpdateBefore(Equipment)]
→ EquipmentSystem
→ Crafting / Currency
→ LootDrop (OrderLast)

All three new systems share the EquipmentDirtyTag gate. GridPlacementSystem does not disable the tag — downstream systems still need it. ItemSetBonusSystem additionally uses RequireForUpdate<SetBonusDefinition>.

→ See references/grid-placement-guide.md for InventoryGridUtility API. → See references/passive-effects-guide.md for clear-and-rebuild pattern. → See references/set-bonuses-guide.md for threshold stacking. → See references/gotchas.md for all critical gotchas.


Auto-place item on pickup (done by GridPlacementSystem; manual trigger):

var cells = SystemAPI.GetBuffer<InventoryGridCell>(owner);
var dim = SystemAPI.GetComponent<InventoryGridDimension>(owner);
var effDim = InventoryGridUtility.GetEffectiveDimensions(shape, rotation);
if (InventoryGridUtility.FindFirstFit(cells, dim.GridWidth, dim.GridHeight,
effDim.x, effDim.y, out int gx, out int gy))
InventoryGridUtility.PlaceItem(cells, dim.GridWidth, gx, gy,
effDim.x, effDim.y, itemEntity);

Add passive effect to item at bake time:

var passives = AddBuffer<ItemPassiveEffect>(item);
passives.Add(new ItemPassiveEffect
{
Stat = StatType.PhysAtk, ModType = ModifierType.Flat,
Value = 25f, Condition = PassiveCondition.InInventory
});

Configure set bonus singleton:

var defs = AddBuffer<SetBonusDefinition>(singleton);
// 2-piece bonus
defs.Add(new SetBonusDefinition { SetId = 1, RequiredCount = 2,
Stat = StatType.CritRate, ModType = ModifierType.PercentAdd, Value = 0.05f });
// 4-piece bonus (stacks WITH 2-piece if 4 items owned)
defs.Add(new SetBonusDefinition { SetId = 1, RequiredCount = 4,
Stat = StatType.PhysAtk, ModType = ModifierType.PercentMul, Value = 0.20f });

→ See references/demo-shapes-guide.md for ModifierSource separation table.

FileContent
grid-placement-guide.mdInventoryGridUtility API, rotation rules, auto-placement algorithm
passive-effects-guide.mdPassiveCondition, clear-and-rebuild pattern, bake setup
set-bonuses-guide.mdSetBonusDefinition config, counting logic, threshold stacking
gotchas.mdG1-G10, G14 — core gotchas
gotchas-ui-drag.mdG11-G13 — UI drag-and-drop gotchas
demo-shapes-guide.mdPolyomino shapes API, InventoryDemo, ModifierSource separation
library-api.mdDOTSInventory.Loot.RarityRoller — Burst-safe weighted rarity roll with pity