
Static Inventory
A type-bound inventory system in C# where every item category owns exactly one fixed slot.
About the Project
Static Inventory is a compact prototype for an intentionally fixed game inventory. Instead of placing items in arbitrary empty spaces, every ItemType has one reserved slot. Weapons, armor, bows, potions, and keys therefore always appear in predictable positions.
The project explores a simple game-system question: how can a fixed inventory structure be represented with as little mapping logic as possible?
What I Built
- A dedicated
Itemmodel with a name and typed category - An
ItemTypeenum containing nine fixed item classes - A nullable array as compact inventory storage
- Direct mapping from enum value to slot index
- Collision detection when adding an item
- Operations for removing and listing inventory contents
Technical Structure
The number of slots is not maintained separately. The constructor derives it directly from the available enum values:
Slots = new Item?[Enum.GetValues<ItemType>().Length];
When an item is added, its ItemType is converted to an integer and used as the array index. The system therefore needs neither a dictionary nor a large conditional statement. If the assigned slot is already occupied, the existing item remains in place and the console reports the conflict.
Design Decision
The model is intentionally static: exactly one slot exists for each category. This constraint makes the behavior easy to understand and suits games where equipment types matter more than freely arranged backpack slots.
The position of a slot also depends on the order of the enum. In a larger version, I would add stable identifiers, return values for failed operations, and tests covering invalid or occupied slots.
Development Notes
The devlog explains why the enum can serve as category, slot definition, and index at the same time: