How-To: Choose a Layout
Goal: pick flat-slot, grid, or weight topology for an inventory, seed its capacity, grow it at runtime, and preview placement on the client.
1. Pick the layout class
| Layout | Reads capacity from | Entry placement | Typical game |
|---|---|---|---|
UCrimsonInventoryLayout_FlatSlot | MaxSlotsTag (default Crimson.Inventory.Constraint.Slots) | SlotIndex | MMO, ARPG bag |
UCrimsonInventoryLayout_Grid | GridWidthTag, GridHeightTag (defaults Crimson.Inventory.Constraint.GridWidth / .GridHeight) | GridPosition, Rotation when bAllowRotation | Tarkov, Diablo, Resident Evil |
UCrimsonInventoryLayout_Weight | Crimson.Inventory.Constraint.Weight through a float-tag constraint | Ordered list, SlotIndex | Skyrim, Fallout |
Layouts hold no numbers. FCrimsonPlacementContext::GetIntCapacity(Tag) / GetFloatCapacity(Tag) read the manager's replicated max-tag containers, so two characters can share one layout asset and have different sizes.
right-click -> Miscellaneous -> Data Asset, choose the class. For a grid, tick Allow Rotation if items may turn.
2. Seed the capacity
Capacities are seeded once on the server with InitializeInventory (or InitializeConstraintTags). The tag you pass is the tag the layout reads - there is no suffix convention; the max lives in a separate container under the same tag.
Initialize Inventory on the server. Grid: two Make Crimson Tag Stack entries in Default Int Constraints (Crimson.Inventory.Constraint.GridWidth = 10, .GridHeight = 6). Weight: one Make Crimson Float Tag Stack in Default Float Constraints (Crimson.Inventory.Constraint.Weight = 150.0).
3. Grow or shrink the cap at runtime
Server only. Set Int Constraint Max (Tag = Crimson.Inventory.Constraint.Slots, New Max = 30) replaces an int cap; 0 removes it. Float caps have no setter - they are seeded by Initialize Inventory (Default Float Constraints) and widened by the bonus from an equipped ExpandRoot bag.
Modify Int Constraint Value / Modify Float Constraint Value are a different thing: they move the current counter, not the cap. Reach for them when something other than an item should consume capacity. Either way Crimson.Inventory.Message.ConstraintChanged fires once for that tag with the settled Capacity view - see How-To: Add Constraints -> 6. Observe capacity values.
SetIntConstraintMax on the server: the client's Get Constraint Capacity returns the new Max within one replication tick, and its handler fires exactly once for that tag.4. Preview placement on the client
Because the layout asset, the entries, and the caps all replicate, a client can ask the layout whether a drop is legal before sending the request. PreviewPlacement is not authority-only.
Preview Placement (Query = Make Crimson Placement Query with Item Def, Policy = Explicit Target, Hint = the hovered cell). Read bSuccess and Failure Reason to tint the drag ghost.
bSuccess is false and Failure Reason names the problem.See also
- How-To: Add Constraints
- How-To: Nest Bags
- Concept: Layouts and Groups