Skip to content

RevFramework – Integration Scene: 01_Economy_WithInventory

Goal

Teach full Economy orchestration across money and inventory:

Player owner → ICurrencyService + IInventoryServiceIValueLedger + IItemStore → Shop / Sell / Craft / Reward → EcoOpResult.


What This Scene Demonstrates

This scene shows Economy coordinating Currency and Inventory through public abstractions.

The flow is:

Player → Currency service + Inventory service → EconomyInventoryBootstrapIValueLedger / IItemStore → Economy service call → EcoOpResult

  • Currency owns value mutation
  • Inventory owns item ownership, removal, delivery, and space checks
  • Economy orchestrates money and item services
  • Preflight checks guide button state only
  • Execution result is truth
  • Rollback behaviour is operation-specific
  • Failure injection is teaching-only, but it still wraps public contracts

This is an integration scene.

No Economy internals are used as supported integration points.


What To Look For

Use the EconomyWithInventoryPanel to observe full money + item flows.

  • Binding State

  • Player is the owner of both wallet and inventory container

  • Currency is the assigned ICurrencyService
  • Inventory is the assigned IInventoryService
  • Container identifies the target inventory container, such as Backpack
  • ItemGuidMap resolves item guid strings into ItemDefinition assets

  • Balances

  • Reads watched currency ids from the currency service

  • Shows whether money changed after Buy, Sell, Craft, or Reward

  • Container Preview

  • Reads the live inventory container

  • Shows item stacks currently owned by the player
  • Use this with balances to verify actual mutation results

  • Preflight

  • CanPay, CanRemove, and HasSpaceFor are UX checks only

  • Buttons may disable when preflight expects failure
  • Final truth still comes from EcoOpResult

  • Rollback

  • Buy can refund money and rollback delivery failures

  • Sell can restore removed items if payout fails
  • Craft can refund money and restore ingredients if result delivery fails
  • Reward grants money first, then items; money is not rolled back if item grants fail

  • Failure Injection

  • Buy delivery failure wraps IItemStore.Add

  • Sell payout failure wraps IValueLedger.Grant
  • Craft result failure wraps IItemStore.Add
  • These wrappers are teaching-only and exist to make rollback visible

  • Log

  • Shows operation summaries and source correlation

  • Use it alongside balances and container preview

Sample Scope

This scene covers:

  • Economy + Inventory integration
  • Public IValueLedger and IItemStore usage
  • Buy flow with money and item delivery
  • Sell flow with item removal and money payout
  • Craft flow with costs, ingredients, and result delivery
  • Reward flow with money and/or item payout
  • UX preflight checks
  • Operation-specific rollback behaviour
  • Teaching-only failure injection through public wrappers
  • Source/correlation id generation using EcoSource.Build
  • Craft flow support exists in the panel, but this scene intentionally leaves Craft unconfigured to keep the teaching focus on Buy, Sell, and Reward

This scene does NOT cover:

  • Crafting integration (covered in a dedicated scene/video)
  • Crafting system authoring in depth
  • Inventory item definition design in depth
  • Multiplayer replication or networking
  • Backend transaction coordination
  • Production logging pipelines
  • Save/load persistence for economy state

Those are covered by other systems or project-level integration work.


Authority Note

This scene may include a permissive sample authority setup so it runs without additional configuration.


Networking Reminder

RevFramework does not include networking.

For multiplayer projects, Economy actions must be validated and executed through your own authority and networking layer. Preflight is not authority, and rollback shown here is local service behaviour, not network transaction coordination.


How To Use

  1. Enter Play Mode.
  2. Open the EconomyWithInventoryPanel.
  3. Confirm the required bindings:

  4. Player owner is assigned

  5. ICurrencyService is assigned
  6. IInventoryService is assigned
  7. Container name matches the player inventory container
  8. Assign an ItemGuidMap if item additions, craft results, or item rewards should succeed.
  9. Use supporting panels or gameplay to seed money and items if needed.
  10. Check Balances and Container Preview before running an action.
  11. Run one of the actions:

  12. Buy

  13. Sell
  14. Craft
  15. Reward
  16. Inspect the returned EcoOpResult.
  17. Check balances and container preview to verify what actually changed.
  18. Enable failure injection toggles to observe rollback paths:

    • Force Deliver Fail for Buy
    • Force Payout Fail for Sell
    • Force Add Fail for Craft
    • Check the Log for operation summaries and source correlation.

Failure Behaviour

Failures are shown through dependency guards, disabled action reasons, result banners, toast messages, logs, and EcoOpResult.

Common causes:

  • Play Mode required

  • The panel reads and mutates live currency and inventory services

  • Fix: enter Play Mode

  • Missing Player Owner

  • No player owner is assigned

  • Fix: assign Player so the panel knows which wallet and container to use

  • Missing Currency Service

  • No ICurrencyService is assigned

  • Fix: assign a MonoBehaviour implementing ICurrencyService

  • Missing Inventory Service

  • No IInventoryService is assigned

  • Fix: assign a MonoBehaviour implementing IInventoryService

  • Economy Services Not Built

  • EconomyInventoryBootstrap did not produce the required public services

  • Fix: check player, currency service, inventory service, container, policy, and preflight mode

  • No ItemGuidMap assigned

  • Item guid strings may not resolve to ItemDefinition assets

  • Fix: assign ItemGuidMap if item delivery should succeed

  • Container not found

  • The selected owner/container id does not resolve to an inventory container

  • Fix: check the container name or create the container before running item flows

  • Buy unavailable

  • The player cannot pay, lacks required item costs, or has no space for delivery

  • Fix: adjust balance, price, item ownership, inventory space, policy, or preflight mode

  • Sell unavailable

  • No sell items are configured, payout is missing, or the player does not own the items

  • Fix: configure Sell Items, configure Sell Payout, or add the items to the container

  • Craft unavailable

  • Craft is intentionally unconfigured in this scene/video

  • Fix: use the dedicated Crafting integration scene/video, or configure Craft Cost and Craft Result if using this panel outside this demo

  • Reward unavailable

  • Payout is empty or item reward space check fails

  • Fix: configure money/item payout or free inventory space

  • Injected failure

  • A teaching-only wrapper deliberately failed a public dependency call

  • Fix: disable the relevant force-fail toggle or use the result/log to study rollback behaviour

  • Execution fails after preflight passes

  • The live service rejected the operation during execution

  • Fix: trust EcoOpResult; inspect balances, container state, policy, authority, service composition, and failure injection toggles

Behind The Scenes

The panel uses public Economy, Currency, and Inventory APIs:

  • EconomyInventoryBootstrap.BuildForPlayer

  • builds public Economy services from player, currency, inventory, resolver, container, policy, and preflight mode

  • IValueLedger

  • money preflight and money mutation support

  • IItemStore

  • item space checks, item removal, and item delivery support

  • IShopService

  • Buy

  • Sell

  • ICraftingService

  • Craft

  • IRewardService

  • Grant

  • ICurrencyService

  • owns actual currency balances

  • IInventoryService

  • owns actual inventory containers and item state

  • ItemGuidMap

  • resolves item guid strings into ItemDefinition assets

  • LedgerPreflightMode

  • changes preflight behaviour

  • CurrencyPolicy

  • optionally affects currency preflight and effective debits

  • EcoSource.Build

  • builds stable source/correlation ids

  • EcoOpResult

  • Success

  • Code
  • Message

Teaching-only failure wrappers are used only to force visible rollback paths through public IValueLedger and IItemStore contracts.

The panel does not use Economy internals as supported extension points.


Key Takeaway

Economy coordinates systems.

Currency owns money. Inventory owns items.

Preflight guides the UI, but the executed EcoOpResult tells the truth.