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.

Prerequisites
Quick Start (a manager exists) and How-To: Get the Building Blocks.

1. Pick the layout class

LayoutReads capacity fromEntry placementTypical game
UCrimsonInventoryLayout_FlatSlotMaxSlotsTag (default Crimson.Inventory.Constraint.Slots)SlotIndexMMO, ARPG bag
UCrimsonInventoryLayout_GridGridWidthTag, GridHeightTag (defaults Crimson.Inventory.Constraint.GridWidth / .GridHeight)GridPosition, Rotation when bAllowRotationTarkov, Diablo, Resident Evil
UCrimsonInventoryLayout_WeightCrimson.Inventory.Constraint.Weight through a float-tag constraintOrdered list, SlotIndexSkyrim, 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.

Verify
Assign the asset to Layout Asset on the manager. Dev Tools -> Layout names the layout class.

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).

Verify
Dev Tools -> Layout shows the tag with its max. A grid shows a 10x6 occupancy map.

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.

Verify
Play As Client. Call 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.

Verify
Hover a 2x2 item over the last column of a grid: bSuccess is false and Failure Reason names the problem.

See also

  • How-To: Add Constraints
  • How-To: Nest Bags
  • Concept: Layouts and Groups