Skip to content

RevFramework – Currency Netcode Samples

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

⚠️ Important Disclaimer
These files are illustrative only. They show the minimal authority-gating pattern for popular netcode stacks.
They are not a drop-in multiplayer wallet solution.
You are responsible for replication, prediction, reconciliation, and economy rules in your chosen network stack.

Currency is netcode-agnostic.
It does not depend on NGO, Mirror, or Fusion.


Purpose

  • Demonstrate how to implement authority gating through ICurrencyAuthority binders for common network stacks.
  • Show the correct service composition using AuthorityCurrencyService.
  • Provide minimal examples of server-authoritative credit/debit flows via ServerProxy classes.
  • Help developers integrate the Currency module into networked projects safely.

Folder Layout

Samples/
  NetcodeSamples/
    Fusion/
      CurrencyAuthorityBinder_Fusion.cs
      FusionCurrencyServerProxy.cs
    Mirror/
      CurrencyAuthorityBinder_Mirror.cs
      MirrorCurrencyServerProxy.cs
    NGO/
      CurrencyAuthorityBinder_NGO.cs
      NgoCurrencyServerProxy.cs

Each folder is self-contained and can be copied into a project already using that netcode.


Enabling the Samples

To compile a stack’s sample code, add the corresponding Scripting Define Symbol:

Stack Define Notes
NGO REV_USE_NGO Enables the NGO samples.
Mirror REV_USE_MIRROR Enables the Mirror samples.
Fusion REV_USE_FUSION Enables the Fusion samples.

If a define is missing, the sample scripts for that stack will be excluded by design.

Unity path:
Project Settings → Player → Other Settings → Scripting Define Symbols


Authority Quick Start

Single-Player / Local Testing

  • If you wrap your service with WithAuthority, you must add a binder:
  • Add CurrencyAuthorityBinder (Local) to the scene.
  • Set alwaysTrue = true to allow mutations.
  • If you do not want authority gating in single-player:
  • Do not wrap the service with WithAuthority.

Authoritative Multiplayer

  1. Wrap your service with CurrencyFactories.WithAuthority (or WithCapsAuditAuthority).
  2. Add exactly one binder implementing ICurrencyAuthority to the appropriate GameObject:
  3. NGO: CurrencyAuthorityBinder_NGO
  4. Mirror: CurrencyAuthorityBinder_Mirror
  5. Fusion: CurrencyAuthorityBinder_Fusion
  6. Send client requests via a ServerProxy class (provided in samples).
  7. The server automatically enforces authority via the decorator.
  8. Replicate balances using your chosen netcode (SyncVar, NetworkVariable, Networked property, etc.).

Typical Flow (All Stacks)

  1. Client sends an RPC/Command to request a credit, debit, or transfer.
  2. Server/StateAuthority validates via the binder (ICurrencyAuthority).
  3. Server applies the mutation through the wrapped ICurrencyService.
  4. (Optional) Server broadcasts a HUD or VFX update to clients.
  5. Replication is handled separately by your netcode layer.

Per-Stack Notes

NGO (Netcode for GameObjects)

  • Use NetworkVariable<long> or custom structs to replicate balances.
  • ServerRpc for client→server, ClientRpc for feedback.
  • Binder: CurrencyAuthorityBinder_NGO.

Mirror

  • Use [SyncVar] or custom messages for replication.
  • Command for client→server, ClientRpc for feedback.
  • Binder: CurrencyAuthorityBinder_Mirror.

Fusion

  • Use [Networked] properties or RPCs for replication.
  • RpcSources.InputAuthority → RpcTargets.StateAuthority for client→server.
  • Binder: CurrencyAuthorityBinder_Fusion.

Gotchas

  • Authority-wrapped service with no binder → All mutations will be denied. Add a binder or remove the Authority decorator.
  • Balances not syncing → You must handle replication yourself.
  • Prediction/rollback → Out of scope; follow your stack’s docs.
  • Compile errors → Ensure the correct define (REV_USE_NGO, etc.) is active.
  • The samples do not cover fraud prevention, rollback, or economy security — implement these per project.

Support Stance

These files are provided as keys and illustrative examples only.
RevFramework does not implement replication, prediction, rollback, or reconciliation for currency.

  • Single-player: use the local binder or omit authority entirely.
  • Multiplayer: you are responsible for implementing replication and gameplay logic per stack.

Multiplayer functionality is explicitly out of scope for RevFramework.


  • Authority — AuthorityCurrencyService and binder architecture.
  • Core — Base factories and services used in composition.
  • Decorators — Authority and Idempotency decorators.
  • Samples — Scene demos that use these binders.