Add integration strategy for Inventory System in game engine

Define connections between the Inventory System and other components, including Game Loop interactions for looting, character sheet management, combat system consumables, and persistence requirements for saving game state. Outline triggers, logic, display, and actions for each integration point to enhance overall gameplay experience.
This commit is contained in:
Matthew Mone 2025-12-27 16:54:12 -08:00
parent ac0f3cc396
commit 68646f7f7b

View file

@ -154,3 +154,37 @@ function finalizeRun(runInventory, hubInventory) {
- Saving the game must serialize the `InventoryStorage` array correctly.
- Loading the game must restore specific item instances (not just generic definitions).
---
## **6. Integration Strategy (Wiring)**
This section defines where the Inventory System connects to the rest of the engine.
### **A. Game Loop (Looting)**
- **Trigger:** Player unit moves onto a tile with a Loot Chest / Item Drop.
- **Logic:** `GameLoop` detects collision -> calls `InventoryManager.runStash.addItem(foundItem)`.
- **Visual:** `VoxelManager` removes the chest model. UI shows "Item Acquired" toast.
### **B. Character Sheet (Management)**
- **Trigger:** Player opens Character Sheet -> Inventory Tab.
- **Logic:** The UI Component imports `InventoryManager`.
- **Display:** It renders `InventoryManager.runStash.items` (if in dungeon) or `hubStash.items` (if in hub).
- **Action:** Dragging an item to a slot calls `InventoryManager.equipItem(activeUnit, itemUid, slot)`.
### **C. Combat System (Consumables)**
- **Trigger:** Player selects a "Potion" from the Combat HUD Action Bar.
- **Logic:**
1. Check `unit.equipment.belt` for the item.
2. Execute Effect (Heal).
3. Call `InventoryManager.consumeItem(unit, slotIndex)`.
4. Update Unit Inventory state.
### **D. Persistence (Saving)**
- **Trigger:** `GameStateManager.saveRun()` or `saveRoster()`.
- **Logic:** The `Explorer` class's `equipment` object and the `InventoryManager`'s `runStash` must be serialized to JSON.
- **Requirement:** Ensure `ItemInstance` objects are saved with their specific `uid` and `quantity`, not just `defId`.