Skip to content

🔗 Currency — Inventory Integration

This folder defines the Inventory integration entry point for the Currency system.

It connects Currency to Inventory through an optional adapter seam, allowing inventory item stacks to act as currency balances.

This integration is built and supported for RevFramework systems only. It is not intended for third-party inventory solutions.


🎯 Purpose

  • Provide a clean integration boundary between Currency and Inventory
  • Keep both systems independent and optional
  • Allow existing inventory data (item stacks) to be treated as currency
  • Expose integration through factory helpers, not concrete types

This integration is not required for Currency to function.


🧩 What Lives Here

Integrations/
  Currency/
    Inventory/
      Adapters/   // Actual adapter implementations + factories
      Teaching/   // Teachable panels and demo UI for this integration

Adapters/

Contains:

  • ItemBackedCurrencyAdapter
  • CurrencyInventoryFactories

This is where the real integration logic lives.

Teaching/

Contains:

  • CurrencyInventoryBackedPanel

These panels demonstrate how the integration behaves at runtime using real services.

They are not required for runtime usage and exist for learning and debugging only.


🧠 Mental Model

[ RevFramework Inventory (items, containers) ]
                ↓
        [ Adapter Layer ]
                ↓
        [ ICurrencyService ]
                ↓
        [ Currency System ]

The adapter translates:

  • item stack counts → currency balances
  • inventory mutations → currency mutations

Currency itself remains completely unaware of Inventory.


⚙️ How It Works

  • One ItemDefinition represents one currency
  • A named inventory container (e.g. "Backpack") acts as the wallet
  • The adapter implements ICurrencyService
  • All interactions still go through the Currency public API

Example:

#if REV_INVENTORY_PRESENT
var svc = CurrencyInventoryFactories.InventoryBacked(
    inventoryService,
    coinItemDefinition,
    "Backpack"
);
#endif

🔐 Compile-Time Gating

This integration is only available when:

REV_INVENTORY_PRESENT

is defined.

If the Inventory package is not installed:

  • This folder is effectively ignored at compile time
  • Currency continues to function normally

⚠️ Behaviour Notes

  • Each adapter instance represents one currency only

  • Multiple currencies require multiple adapter instances

  • Wallet data lives in:

  • Inventory containers, not Currency storage

  • Container behaviour is:

  • best-effort creation on credit/ensure

  • required to exist for debit

  • Transfer behaviour depends on:

  • the underlying Inventory system

  • Missing container APIs result in:

  • CurOpCode.ServiceMissing


🚫 What This Is NOT

This integration does not:

  • Merge Currency and Inventory into one system
  • Guarantee transfer atomicity across systems
  • Provide automatic persistence syncing
  • Replace Inventory logic or rules

It is a bridge, not a unified system.


💡 When to Use

Use this integration when:

  • You want coins as items (e.g. gold stacks in inventory)
  • You are using the RevFramework Inventory system
  • You want Currency features (caps, audit, escrow, etc.) on top of items

🌍 Third-Party / Custom Inventory Use

This integration is built for RevFramework Inventory only.

If you are using a different inventory system:

  • Treat this as a reference example
  • Implement your own adapter
  • Use the public ICurrencyService interface

👉 Custom or third-party inventory integrations are not supported by this adapter.


🧹 Safe to Delete

If you are not using Inventory-backed currency, this entire folder can be removed safely.

Currency will continue to work using:

  • SceneCurrencyService
  • or your own ICurrencyService implementation

  • Adapters — implementation details and factory helpers
  • Currency Core — service composition and decorators
  • Inventory System — container and item behaviour

🥃 Rab verdict

This one’s clean:

👉 Integration boundary is clear 👉 No coupling leaks 👉 Factories hide implementation 👉 Compile-time gating keeps it optional

Exactly how this kind of seam should be done 👍