Inventory — Teaching Panels¶
The Teaching folder contains a set of lightweight IMGUI panels used for learning, debugging, and hands-on testing of the Inventory System directly inside your scenes.
These panels demonstrate stacking, equipment rules, searching, sorting, and snapshot persistence using the public runtime APIs of the Inventory system.
Each panel is intentionally minimal and code-first — ideal for understanding behaviour, copying patterns, and wiring your own production UI later.
Status: Sample / Teaching UI — intended for development and testing scenes only. Not for shipping.
Define Guard:
REV_TEACHABLESandREV_INVENTORY_PRESENT— both aredefineConstraintsonRevFramework.Inventory.Teaching.asmdef, so the whole assembly compiles out when either is absent.Teaching content never reaches a player build.
Teaching/Guards/RevTeachablesBuildGuard.csraises a compile#erroron any Player build whileREV_TEACHABLESis set, so a panel left in a scene fails the build rather than shipping in it. To build a player, runTools ▸ RevGaming ▸ RevFramework ▸ Validate ▸ Pre-Build Clean, or delete/moveAssets/RevFramework/Teaching— the define follows the folder and cannot be cleared on its own.
Panel Overview¶
| Panel | Focus | Notes |
|---|---|---|
| InventoryQuickstartPanel | Core flow | Give items, inspect container, remove, clear. Snapshots are InventorySnapshotsPanel's job, not this one's |
| InventoryItemsAndStacksPanel | Stack operations | Merge/swap, split, quick split, max-stack rules |
| InventorySlotsAndRestrictionsPanel | Equipment rules | Slot filters, acceptance checks, equip/unequip |
| InventorySearchAndSortPanel | Discovery tools | Service-backed search and stable sorting |
| InventorySnapshotsPanel | Persistence | Capture, restore, delete snapshots and missing-item policy |
| InventorySavePanel | Save files | The whole scene through the save coordinator, and how a restore fails |
Each panel is self-contained and demonstrates one clear concept.
All panels inherit from TeachablePanelBase and use IMGUI. Every shipped sample instance is set to Anchor = Free, which means draggable rather than pinned — placed near the top-left by positionRef and movable at runtime. Set anchor to TopLeft/TopRight/BottomLeft/BottomRight to pin one instead; dragging is disabled in those modes.
All six expose a toggleKey field, defaulting to **Backquote ()**, which collapses and expands the panel contents — the title and **Panel State** row stay visible either way, and setting the field toKeyCode.None` disables the shortcut.
Learning Goals¶
Across all panels you’ll learn to:
- Bind and resolve
CharacterInventory,CharacterEquipment, andSceneInventoryService - Perform safe inventory mutations (
GiveExact,RemoveFromSlot,SplitResult) - Understand merge-then-swap and stack semantics
- Apply and test equipment filters and slot restrictions
- Execute service-backed search and stable sorting
- Capture and restore inventory snapshots
- Put inventory into a real save file through
RevSaveCoordinator, alongside your own game state - Recognise the StableId mismatch that makes a valid save restore nothing
- Interpret operation results and rejection reasons
- Use public runtime APIs without accessing internal containers
Example: Giving Items Safely¶
Teaching panels demonstrate the same call patterns your production UI will use:
var stack = new ItemStack { def = itemDef, quantity = 5 };
var result = sceneInventory.GiveExact(owner, stack, containerId);
if (!result.Success)
{
Debug.Log(result.ToUserMessage("Give"));
}
No mock logic. No demo-only shortcuts. These are the real inventory calls used at runtime.
Integration Tips¶
- Teaching panels are IMGUI-based and intended for Editor and development scenes.
- They cannot reach a player build: the build guard fails the compile while
REV_TEACHABLESis set, so a panel left in a scene is caught at build time rather than shipped. - Safe to keep in dev scenes — they won’t affect runtime systems.
- Copy service calls, result handling, and container logic into your own UI.
- Ignore IMGUI/layout code — it’s scaffolding only.
Important notes:
- Inventory mutations via
SceneInventoryServicerespectIInventoryAuthority - Panels interact with inventory using public APIs and supported runtime types
- Panels do not access internal container implementations
- Snapshot restore requires a valid
ItemDatabase
Panels will surface clear warnings when required dependencies are missing.
Teaching Folder Layout¶
Teaching/
└─ Inventory/
├─ README.md
├─ RevFramework.Inventory.Teaching.asmdef
└─ HostileConsumers/
├─ README.md
├─ InventoryQuickstartPanel.cs
├─ InventoryItemsAndStacksPanel.cs
├─ InventorySlotsAndRestrictionsPanel.cs
├─ InventorySearchAndSortPanel.cs
├─ InventorySnapshotsPanel.cs
└─ InventorySavePanel.cs
HostileConsumers/ is the only subfolder, and every Inventory panel lives in it. Some other systems also carry a Demos/ folder for panels that attach helpers or rewire a service; Inventory has none, because no Inventory panel needs one.
Panels inside HostileConsumers compile against the public API only, verifying that the Inventory system can be consumed externally.
Quick Review¶
| Attribute | Summary |
|---|---|
| Audience | Developers integrating or exploring the Inventory system |
| Goal | Teach container behaviour, stacking, equipment, search/sort, and persistence |
| Style | Code-first, readable, dependency-light |
| Location | Assets/RevFramework/Teaching/Inventory/ |
| Safety | Editor-only, and enforced: the build guard fails a player build while REV_TEACHABLES is set |
| Theme | IMGUI — consistent with all RevFramework teaching panels |
TL;DR¶
The Teaching folder is your in-engine classroom for the Inventory system.
Use it to explore:
- stacking behaviour
- equipment restrictions
- search and sorting
- snapshot persistence
Then copy the service calls and runtime patterns into your own gameplay UI.