Stack Inventory v1.0.0
Welcome to the Stack Inventory documentation! A high-performance, interface-based inventory system for Godot 4 C# projects.
Key Features
Section titled “Key Features”Interface-Based Architecture
Section titled “Interface-Based Architecture”- Unified
IIteminterface for both Resources and POCS classes - Zero-overhead performance with direct property access
- No conversion overhead in hot paths
- Works seamlessly with both editor-defined and runtime-generated items
Flexible Item Creation
Section titled “Flexible Item Creation”- ItemDefinition Resources - Visual editing in Godot Inspector
- Item POCS Classes - Runtime creation, serialization, networking
- Both implement the same
IIteminterface
Comprehensive Testing
Section titled “Comprehensive Testing”- 191 total tests ensuring reliability
- 143 xUnit tests (POCS logic)
- 48 GoDotTest tests (Godot integration)
- Full coverage of core functionality
High Performance
Section titled “High Performance”- 10-100x faster than string-based lookup systems
- Zero allocations for interface casts
- Cache-friendly data structures
- Optimized for item-heavy games
Quick Links
Section titled “Quick Links”- Getting Started - Set up your first inventory
- API Reference - Complete class documentation
- Migration Guide - Upgrade from previous versions
- Architecture Overview - Understand the design
Key Features
Section titled “Key Features”Zero-Overhead Interface Usage
Section titled “Zero-Overhead Interface Usage”// Before (old pattern - still works)Item item = itemDefinition.ToCore(); // Creates new object
// After (new pattern - recommended)IItem item = itemDefinition; // Just a cast, zero allocation!Hierarchical Tag System
Section titled “Hierarchical Tag System”// Define tag hierarchy in editorvar equipment = new ItemTagDefinition { Name = "Equipment" };var weapon = new ItemTagDefinition { Name = "Weapon", Parent = equipment };
// Check tags with hierarchy supportif (itemDef.HasTag(equipment.ToCore())){ GD.Print("This is equipment!");}Flexible Stack Management
Section titled “Flexible Stack Management”// Intelligent stacking with overflow handlingvar pickup = new Pickup2D{ ItemDefinition = swordDef, Amount = 10};
var takenAmount = player.TryTake(pickup);// Automatically distributes across available stacksArchitecture
Section titled “Architecture”Stack Inventory uses a three-layer architecture:
1. Core Layer (POCS)
Section titled “1. Core Layer (POCS)”Pure C# interfaces and classes:
IItem- Item interfaceItem- POCS class for serializationItemTag- Tag with hierarchy supportIActionSettings- Settings interface
2. Game Layer (Godot Resources)
Section titled “2. Game Layer (Godot Resources)”Resources implementing core interfaces:
ItemDefinition- ImplementsIItemItemTagDefinition- Converts toItemTagActionSettings- ImplementsIActionSettings
3. UI Layer (Godot Nodes)
Section titled “3. UI Layer (Godot Nodes)”Nodes using interfaces:
Pickup2D- UsesIItemStackView- UsesIActionSettingsItemCountsView- UsesIItem
Benefits
Section titled “Benefits”✅ Performance - Zero-overhead interface casts
✅ Flexibility - Easy serialization and network support
✅ Testability - Pure C# logic testable with xUnit
✅ Integration - Seamless Godot editor integration
✅ Maintainability - Clean separation of concerns
Breaking Changes
Section titled “Breaking Changes”Only ONE breaking change: ActionSettingsResource renamed to ActionSettings
Migration time: ~5 minutes (simple find/replace)
See the Migration Guide for details.