Skip to content

🔗 Economy — Inventory Integration

This folder contains the integration layer between Economy and Inventory.

It demonstrates how currency-based value flows combine with inventory-backed item flows to form complete transactional systems such as:

  • Buy (pay → deliver items)
  • Sell (remove items → payout)
  • Craft (pay/remove → add result)
  • Reward (grant currency and/or items)

🧠 Purpose

The integration layer exists to:

  • Connect IValueLedger (currency) with IItemStore (inventory)
  • Demonstrate full transaction flows using both money and items
  • Show rollback-safe behaviour across multi-step operations
  • Provide reference implementations for real game systems

This layer is optional. Economy works independently with currency-only flows.


🧩 Key Components

EconomyWithInventoryPanel

A teaching panel demonstrating full Economy + Inventory flows.

  • Uses public abstractions only
  • Executes real operations via:

  • IShopService

  • ICraftingService
  • IRewardService
  • Includes:

  • Preflight validation (space, ownership, funds)

  • Rollback behaviour
  • Failure injection (teaching/debugging)

EconomyInventoryBootstrap

Facade for composing:

  • IValueLedger (currency)
  • IItemStore (inventory adapter)
  • Economy services (Shop, Crafting, Reward)

This is the integration entry point when inventory is involved.


ItemGuidMap

Helper ScriptableObject used in samples and teaching panels.

  • Maps guid → ItemDefinition
  • Required for item Add() operations
  • Not intended as a production registry

Samples

Contains demo overlays and helper scripts:

  • EconomyDemoOverlay
  • EconomyDemoOverlay.Inventory

These provide lightweight runtime testing without teachable UI.


Scenes

Demo scenes showcasing full integration:

  • Currency + Inventory wiring
  • Buy / Sell / Craft / Reward flows
  • Container-based item interactions

🔧 Usage

To use Economy with Inventory:

  1. Provide:

  2. ICurrencyService

  3. IInventoryService
  4. Item resolver (Func<string, ItemDefinition>)

  5. Build services:

var built = EconomyInventoryBootstrap.BuildForPlayer(
    player,
    currencyService,
    inventoryService,
    resolver,
    "Backpack",
    policy);
  1. Use returned abstractions:
_shop.Buy(...)
_rewards.Grant(...)
_crafting.Craft(...)

⚠️ Notes

  • This layer depends on:

  • REV_ECONOMY_PRESENT

  • REV_CURRENCY_PRESENT
  • REV_INVENTORY_PRESENT
  • Not required for currency-only projects
  • Teaching panels are not for production UI
  • Rollback behaviour is handled by service orchestration, not UI logic

🧠 Architecture

EconomyBootstrap              → currency-only composition
EconomyInventoryBootstrap     → inventory-backed composition

This separation ensures:

  • Clean asmdef boundaries
  • No forced dependencies
  • Explicit integration paths

🧠 Quick Review

Attribute Summary
Purpose Economy + Inventory integration
Scope Full transactional flows
Dependency Optional (requires Inventory)
Style Public API only
Location Integrations/Economy/InventoryIntegration

TL;DR

This folder shows how money + items combine into real game transactions using the Economy system.