Inventory System
Inventory System
Section titled “Inventory System”Loot Structure Design
Section titled “Loot Structure Design”Loot Data Structure
Section titled “Loot Data Structure”Create comprehensive structure for all loot items:
Struct_Loot Components
Section titled “Struct_Loot Components”- ID String: Unique identifier for item type (used for stacking)
- Name Text: Display name in UI
- Appearance_3D Static Mesh: 3D world representation
- UI Texture System: Background, icon, and border textures with color options
UI Texture Variables
Section titled “UI Texture Variables”// Loot UI Representation SystemStruct_Loot {Texture_Background: Texture2D;Texture_Icon: Texture2D;Texture_Border: Texture2D;
Texture_Background_Color: LinearColor;Texture_Icon_Color: LinearColor;Texture_Border_Color: LinearColor;}
Data Table Implementation
Section titled “Data Table Implementation”Create item database using data tables:
- DT_Loot_Example: Template data table structure
- Unique IDs: Each item needs distinct ID for proper stacking
- Default Values: Set reasonable defaults for texture and color systems
Loot Actor System
Section titled “Loot Actor System”Actor_Loot_Master Blueprint
Section titled “Actor_Loot_Master Blueprint”Create base loot actor with data table integration:
Component Setup
Section titled “Component Setup”- Arrow Component: Root for positioning control
- Static Mesh Component: 3D appearance
- Box Collision: Interaction detection
- Rotating Movement: Visual appeal
Data Table Integration
Section titled “Data Table Integration”// Loot Actor Data IntegrationOnConstruction() {loot_data = GetDataTableRow(DataTable_Loot, 'NewRow');StaticMesh_Appearance.SetStaticMesh(loot_data.Appearance_3D);
// Apply scale and positioning based on mesh}
Loot Interaction
Section titled “Loot Interaction”Connect loot to inventory system:
- Interact Event: Add loot to player inventory
- Destroy Actor: Remove loot from world after pickup
- Interface Integration: Use Interface_Inventory_Add function
Inventory Implementation
Section titled “Inventory Implementation”Player Character Inventory Variables
Section titled “Player Character Inventory Variables”Create inventory storage system:
Core Inventory Arrays
Section titled “Core Inventory Arrays”- Inventory Array: Struct_Loot array for item data
- Inventory_Quantity Array: Integer array for item quantities
- Array Synchronization: Both arrays must maintain identical indices
Inventory Add System
Section titled “Inventory Add System”Handle adding items to inventory with stacking:
// Inventory Add ImplementationInterface_Inventory_Add(Loot) {if (Inventory.Contains(Loot)) {// Item exists - increase quantityitem_index = Inventory.Find(Loot);current_quantity = Inventory_Quantity[item_index];Inventory_Quantity[item_index] = current_quantity + 1;} else {// New item - add to inventoryInventory.Add(Loot);Inventory_Quantity.Add(1);}
UpdateInventoryWidget();}
Inventory Remove System
Section titled “Inventory Remove System”Handle removing items with validation:
Check Inventory Function
Section titled “Check Inventory Function”Validate sufficient resources before removal:
// Inventory ValidationF_Check_Inventory(RequiredItems[], RequiredQuantities[]) -> Bool {ForEach(item in RequiredItems) {if (!Inventory.Contains(item)) {F_Player_Error('Not enough ' + item.Name);return false;}
item_index = Inventory.Find(item);current_amount = Inventory_Quantity[item_index];required_amount = RequiredQuantities[index];
if (current_amount < required_amount) {F_Player_Error('Not enough ' + item.Name);return false;}}return true; // All items available}
Inventory Remove Function
Section titled “Inventory Remove Function”Remove items only after validation passes:
- Validation First: Use F_Check_Inventory before any removal
- Quantity Reduction: Subtract required amounts from inventory quantities
- UI Update: Refresh inventory display after changes
Inventory UI System
Section titled “Inventory UI System”W_Inventory Widget
Section titled “W_Inventory Widget”Create scrollable inventory interface:
Widget Structure
Section titled “Widget Structure”- Size Box Root: 400x800 container
- Scroll Box: Vertical scrolling for large inventories
- Vertical Box: Container for inventory items
- Background Image: Visual styling for inventory panel
W_Inventory_Item Widget
Section titled “W_Inventory_Item Widget”Individual item display component:
Item Widget Components
Section titled “Item Widget Components”- Icon Template: Reuse existing icon system
- Text Blocks: Item name and quantity display
- Layout: Icon on left, name in center, quantity on right
- Scaling: 0.45 scale for appropriate sizing
Inventory Widget Communication
Section titled “Inventory Widget Communication”// Inventory Update SystemInterface_Widget_Inventory_Update(InventoryArray, QuantityArray) {VerticalBox.ClearChildren(); // Clear existing items
ForEach(item in InventoryArray) {item_widget = CreateWidget(W_Inventory_Item);item_widget.SetLootData(item, QuantityArray[index]);VerticalBox.AddChild(item_widget);}}
UI Integration
Section titled “UI Integration”Root Widget Integration
Section titled “Root Widget Integration”Add inventory to main UI system:
- Size to Content: Enable for proper sizing
- Anchor: Middle right positioning
- Default Visibility: Hidden until opened
- Toggle System: B key to open/close inventory
HUD Integration
Section titled “HUD Integration”Follow standard widget integration pattern:
- HUD Interface: Get_Widget_Inventory function
- Widget Variable: Widget_Inventory reference in player character
- Toggle Function: Interface_Widget_Inventory_Toggle for show/hide
Inventory Testing
Section titled “Inventory Testing”Multi-Item Testing
Section titled “Multi-Item Testing”Set up test environment:
- Multiple Loot Types: Create various data tables for different items
- Child Loot Actors: Specialized loot actors for different item types
- Quantity Testing: Verify stacking works correctly
- UI Testing: Confirm inventory display updates properly
The inventory system provides essential item management functionality while maintaining clean, extensible architecture for future crafting, trading, and progression systems.