How-To: Author an Item Definition

Goal: create an item as a Blueprint class, compose it from fragments, give it per-instance state, and make it discoverable at runtime.

Prerequisites
Quick Start step 1 (a scan path registered) and How-To: Get the Building Blocks.

1. Create the class and set its identity

Inside a scanned folder: right-click -> Blueprint Class -> `CrimsonInventoryItemDefinition`. In Class Defaults set Display Name and Item Type (a gameplay tag; the type drives context menus, type filters, and sorting).

Verify
Save. Tools -> Inventory Dev Tools -> Items lists the new class in its item picker.

2. Add fragments

Fragments are static, shared data on the definition. Add the ones you need under Fragments with the + button.

FragmentDisplay namePropertiesRead by
UCrimsonInventoryItemFragment_DataInventory DatabUnique, bStackable, MaxStackSizeMerging and splitting. Without it an item is a non-stackable single.
UCrimsonInventoryItemFragment_VisualsItem VisualsItemIcon, SlotWidgetClass, PickupActorClass, PickupMeshUI; DropItemByEntry spawns PickupActorClass.
UCrimsonInventoryItemFragment_TooltipItem TooltipTooltipWidgetClass, Description, RarityColorUI.
UCrimsonInventoryItemFragment_FootprintInventory FootprintDimensions, Weight, SlotCost, bAllowRotationGrid layouts and the float-tag (weight) constraint. Default is 1x1, weight 0, 1 slot.
UCrimsonInventoryItemFragment_EquippableEquippableEquipmentDefinition, PreferredSlotTagThe Equip context action. See How-To: Bridge to Equipment.
UCrimsonInventoryItemFragment_ConsumableConsumableUseEventTag, EffectsToApply, Application, DurationSeconds, DurationSetByCallerTag, ConsumeCount, CooldownTag, CooldownSeconds, CooldownEffectThe Use context action and the action bar. Adding it is the whole integration - the item then answers ICrimsonUsableObject and one shared use-ability serves it. See How-To: Make an Item Usable.
UCrimsonInventoryItemFragment_BagInventory BagLayout, IntCapacities, FloatCapacities, Constraints, bAllowNestedBags, MaxNestingDepth, Mode, GroupDisplayNameThe layout runtime. See How-To: Nest Bags.
UCrimsonInventoryItemFragment_GrantCurrencyGrant Currency On PickupCurrencyType, AmountPerItemAddItemDefinition: the item converts to currency instead of occupying a slot.
UCrimsonInventoryItemFragment_ContextActionsContext ActionsActionsContext menus. See How-To: Add Context Actions.
UCrimsonInventoryItemFragment_ConstraintInventory ConstraintsConstraintsToCheckExtra per-item rules evaluated when this item is placed.

Click + on Fragments, pick the fragment class from the dropdown, expand it, fill the fields.

Verify
Give yourself the item from Dev Tools -> Items. With Inventory Data Stackable and MaxStackSize = 20, giving 25 produces two entries: x20 and x5.

3. Add per-instance state (optional)

State fragments are replicated subobjects created per UCrimsonInventoryItemInstance. Their SaveGame properties serialize into the save struct and OnStateRestored fires after a load.

State fragmentPropertiesBehavior
UCrimsonInventoryStateFragment_DurabilityMaxDurability, CurrentDurability (replicated, SaveGame)ApplyDurabilityChange, GetDurabilityPercentage, IsBroken. Server-only mutation.
UCrimsonInventoryStateFragment_LifetimeTotalLifetime, TimeRemaining (replicated, SaveGame)Counts down on the server; resumes from TimeRemaining after OnStateRestored.

Under State Fragments click + and pick State Fragment: Item Durability; set Max Durability. To write your own, create a Blueprint child of CrimsonInventoryStateFragment and override Initialize From Definition, Tick State, On State Restored, or Resume State Logic.

Verify
Play As Client. Give the item on the server; the client's Dev Tools -> Items row shows the durability value replicated.

4. Discover definitions at runtime

Get All Item Definition Ids returns Primary Asset Ids from the scan paths; Load Item Definition By Id turns one into a class. Get All Item Definitions In Editor loads everything (editor and uncooked builds only).

Verify
Print the count from Get All Item Definition Ids; it matches the number of item Blueprints in your scan paths.

See also

  • How-To: Nest Bags
  • How-To: Bridge to Equipment
  • How-To: Add Context Actions
  • Concept: Entries, Instances and Definitions