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.OnWalletChangedto 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¶
- Enter Play Mode.
- Toggle the CurrencyBasicsPanel with
F8. - Select your Player (auto-detected) or cycle between any objects with a
StableId. - Use the panel controls:
- + / − → Credit or debit current wallet.
- Set → Assign an absolute balance.
- Quick nudges → Perform small balance changes for visual feedback.
- 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:
CurrencyAuthorityBinderalwaysTrue = 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:
SceneCurrencyService → AuthorityCurrencyService
(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
CurrencyAuthorityBinderfrom this scene, all currency mutations will fail withUnauthorized. - If the
CurrencyBasicsPaneldoesn’t appear, ensure the panel prefab is linked in the sample scene. - Only one active
CurrencyServiceBootstrapshould exist per scene. CurOpResultdoes not throw — always check.Successor.Code.- For policy, audit, or idempotency behaviour, see later sample scenes.
📚 Related¶
- 01_Currency_PolicyCaps — Demonstrates policy enforcement.
- 04_Currency_UIBars — Focused on live UI integration.
- 06_Currency_Idempotency — Retry-safe, MP-friendly patterns.
- Core —
SceneCurrencyService,CurrencyResolve,CurrencyTxn. - Decorators — Audit, Caps, Authority, Idempotency.