Skip to content

RevFramework – Sample Scene: 00_Currency_Basics

Namespace: RevGaming.RevFramework.Runtime.Currency.Samples.Scenes


🎯 Purpose

Learn the fundamentals of the Currency System — wallets, credit/debit/set operations, and live updates through teaching panels or UI bars.

This is the entry-level sample scene for RevFramework’s Currency module.
It demonstrates how wallet creation, mutation, and UI feedback behave under a clean, single-service stack with a permissive single-player authority (no caps, no audit).


🧩 What This Scene Teaches

  • Wallets are created lazily on first use via EnsureWallet(GameObject).
  • You can credit, debit, and set balances safely — all operations are overflow-checked.
  • Live balances can be displayed via Currency UI Bars (CurrencyBar, CurrencyBarTMP, CurrencyBarUITK).
  • Subscribe to ICurrencyService.OnWalletChanged to drive reactive UI or logic.
  • See how every operation returns a CurOpResult code (e.g. Ok, InsufficientFunds, Overflow, etc.).
  • How authority gating works in practice, without introducing multiplayer complexity yet.

🕹️ How to Use

  1. Enter Play Mode.
  2. Toggle the CurrencyBasicsPanel with F8.
  3. Select your Player (auto-detected) or cycle between any objects with a StableId.
  4. Use the panel controls:
  5. + / − → Credit or debit current wallet.
  6. Set → Assign an absolute balance.
  7. Quick nudges → Perform small balance changes for visual feedback.
  8. Bind a CurrencyBar, CurrencyBarTMP, or CurrencyBarUITK to the same owner and currency to watch it update in real time.

🔐 Authority (Important)

This sample scene includes a CurrencyAuthorityBinder configured for single-player use:

  • CurrencyAuthorityBinder
  • alwaysTrue = true

This allows all currency mutations so the demo works out of the box.

Why this exists

RevFramework currency mutations are authority-gated by default.

  • If no authority is present, all mutations are blocked.
  • This is intentional and required for multiplayer safety.

Multiplayer note

For multiplayer or server-authoritative games:

  • Do not use CurrencyAuthorityBinder
  • Implement your own ICurrencyAuthority
  • Validate all currency mutations on the server/host

This scene uses the permissive binder only to demonstrate behaviour in a local, single-player context.


⚙️ Stack Composition

Bootstrap: CurrencyServiceBootstrap
Service Stack:
SceneCurrencyServiceAuthorityCurrencyService
(Authority provided by CurrencyAuthorityBinder, no caps, no audit)

Teaching Panel: CurrencyBasicsPanel
UI Prefabs: CurrencyBar, CurrencyBarTMP, CurrencyBarUITK

Scene Path:

Assets/RevFramework/Runtime/Systems/Currency/Samples/Scenes/00_Currency_Basics/


⚠️ Gotchas

  • If you remove CurrencyAuthorityBinder from this scene, all currency mutations will fail with Unauthorized.
  • If the CurrencyBasicsPanel doesn’t appear, ensure the panel prefab is linked in the sample scene.
  • Only one active CurrencyServiceBootstrap should exist per scene.
  • CurOpResult does not throw — always check .Success or .Code.
  • For policy, audit, or idempotency behaviour, see later sample scenes.