Skip to content

💰 Currency Samples — Scenes & Integrations

The Currency Samples folder contains demonstration scenes, adapters, and netcode examples for learning and testing the Currency system.
They are intended for teaching, debugging, and prototyping — not for shipping in production builds.


📂 Folder Layout

Samples/
  Scenes/          // Currency feature demos (00–99)
  NetcodeSamples/  // Fusion, Mirror, NGO binders

🎬 Scene Samples

Scene Demonstrates Notes
00_Currency_Basics Core ICurrencyService usage — credit, debit, events. Minimal setup.
01_Currency_PolicyCaps Min/max caps via CappedCurrencyService. Uses CurrencyPolicy asset.
02_Currency_Exchange Multi-currency conversion via TableCurrencyExchange. TryQuote / TryExchange.
03_Currency_Persistence JSON save/load via CurrencyJsonSave. Requires StableId.
04_Currency_UIBars Runtime UI sync with CurrencyBar prefabs. Uses CurrencySet.
05_Currency_Escrow Holds, commit, release, expiry. Demonstrates escrow decorators.
06_Currency_Idempotency Duplicate-safe replay handling. Idempotent request patterns.
07_Currency_BatchAndTxn Batched wallet events and atomic transactions. Uses CurrencyTxn.
08_Currency_Awaiters Awaitable balance checks. Async / coroutine usage.
09_Currency_InventoryBacked Inventory-backed currency adapter. Requires REV_INVENTORY_PRESENT.
99_Currency_Kitchen_Sink All decorators + all stacks combined. Integration benchmark.

🌐 Netcode Examples

Located in:

Samples/Currency/NetcodeSamples/

❗ Scope Reminder > RevFramework does not implement networking, replication, prediction, rollback, or reconciliation. > These samples demonstrate authority gating patterns only — all networking behaviour is your responsibility.

Fusion

  • CurrencyAuthorityBinder_Fusion.cs
  • FusionCurrencyServerProxy.cs

Mirror

  • CurrencyAuthorityBinder_Mirror.cs
  • MirrorCurrencyServerProxy.cs

NGO (Netcode for GameObjects)

  • CurrencyAuthorityBinder_NGO.cs
  • NgoCurrencyServerProxy.cs

All netcode scripts are samples only — adapt them to match your project’s authority rules.


▶️ Usage

Open any sample scene from:

Assets/RevFramework/Samples/Currency/Scenes/

Common scene setup includes:

  • A CurrencyServiceBootstrap with the relevant decorators enabled
  • Wallet owners or UI bars for debugging
  • Optional inventories, stable IDs, or escrow components
  • Teaching panels in the Canvas for interaction

🔐 Design Rationale: Currency Authority

The Currency system is designed to be multiplayer-ready and abuse-resistant by default, while still remaining easy to use in single-player projects.

Currency is one of the most cheat-sensitive systems in any game: - It is frequently mutated from UI buttons. - It often represents real value (progress, unlocks, purchases). - Silent permissive behaviour is dangerous in networked contexts.

Currency mutations are authority-gated when the Authority decorator is used.

  • If the service stack includes Authority, then:
  • No authority present → mutations are denied
  • This ensures:
  • No accidental “everyone can mint currency” bugs
  • Clear server-authoritative control in multiplayer
  • Explicit configuration instead of silent defaults

This is intentional.

Why Demo Scenes Still “Just Work”

All Currency demo scenes include:

CurrencyAuthorityBinder (Demo – Allow All)

Configured with: - alwaysTrue = true

This exists purely to: - Keep demos functional out of the box - Make the authority model visible and explicit - Show exactly what to remove or replace for multiplayer

The binder is a teaching and convenience tool, not a production requirement.

Single-Player vs Multiplayer

Context Recommended Setup
Single-player Use the demo binder, or omit Authority entirely
Multiplayer / Server-authoritative Implement ICurrencyAuthority and validate on the server
Netcode samples Provide minimal binders + server proxies (illustrative only)

Currency never handles: - Replication - Prediction - Rollback - Reconciliation

Those concerns belong to your chosen netcode stack.

Why Other Systems May Behave Differently

Not all RevFramework systems enable authority by default.

Some systems (e.g. Health) use an explicit requireAuthority toggle so developers can opt in gradually.

Currency takes a firmer stance because: - It is frequently mutated from UI - It is commonly networked - It is the most likely system to be exploited accidentally

Other systems may adopt the same pattern in future versions, but Currency intentionally leads here.


⚠️ Gotchas

  • The entire Samples directory is excluded from runtime builds via .asmdef.
  • Netcode samples require defines such as:
  • REV_USE_FUSION
  • REV_USE_MIRROR
  • REV_USE_NGO
  • Only one CurrencyServiceBootstrap should exist in any scene.
  • Sample scripts use minimal error handling for clarity — do not treat them as production-safe.

  • Core: Currency base service, decorators, factories
  • Decorators: Caps, Audit, Escrow, Authority, Idempotency
  • Persistence: CurrencyJsonSave, snapshot flows
  • Teaching Panels: Currency Basics Panel, Escrow Panel, etc.