Skip to content

Stack Inventory v1.0.0

Welcome to the Stack Inventory documentation! A high-performance, interface-based inventory system for Godot 4 C# projects.

  • Unified IItem interface 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
  • ItemDefinition Resources - Visual editing in Godot Inspector
  • Item POCS Classes - Runtime creation, serialization, networking
  • Both implement the same IItem interface
  • 191 total tests ensuring reliability
    • 143 xUnit tests (POCS logic)
    • 48 GoDotTest tests (Godot integration)
  • Full coverage of core functionality
  • 10-100x faster than string-based lookup systems
  • Zero allocations for interface casts
  • Cache-friendly data structures
  • Optimized for item-heavy games
// Before (old pattern - still works)
Item item = itemDefinition.ToCore(); // Creates new object
// After (new pattern - recommended)
IItem item = itemDefinition; // Just a cast, zero allocation!
// Define tag hierarchy in editor
var equipment = new ItemTagDefinition { Name = "Equipment" };
var weapon = new ItemTagDefinition { Name = "Weapon", Parent = equipment };
// Check tags with hierarchy support
if (itemDef.HasTag(equipment.ToCore()))
{
GD.Print("This is equipment!");
}
// Intelligent stacking with overflow handling
var pickup = new Pickup2D
{
ItemDefinition = swordDef,
Amount = 10
};
var takenAmount = player.TryTake(pickup);
// Automatically distributes across available stacks

Stack Inventory uses a three-layer architecture:

Pure C# interfaces and classes:

  • IItem - Item interface
  • Item - POCS class for serialization
  • ItemTag - Tag with hierarchy support
  • IActionSettings - Settings interface

Resources implementing core interfaces:

  • ItemDefinition - Implements IItem
  • ItemTagDefinition - Converts to ItemTag
  • ActionSettings - Implements IActionSettings

Nodes using interfaces:

  • Pickup2D - Uses IItem
  • StackView - Uses IActionSettings
  • ItemCountsView - Uses IItem

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

Only ONE breaking change: ActionSettingsResource renamed to ActionSettings

Migration time: ~5 minutes (simple find/replace)

See the Migration Guide for details.

  1. Install Stack Inventory
  2. Follow the Quick Start
  3. Explore the API
  4. Read Architecture Guide