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
ICurrencyAuthoritybinders for common network stacks. - Show the correct service composition using
AuthorityCurrencyService. - Provide minimal examples of server-authoritative credit/debit flows via
ServerProxyclasses. - 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 = trueto allow mutations. - If you do not want authority gating in single-player:
- Do not wrap the service with
WithAuthority.
Authoritative Multiplayer¶
- Wrap your service with
CurrencyFactories.WithAuthority(orWithCapsAuditAuthority). - Add exactly one binder implementing
ICurrencyAuthorityto the appropriate GameObject: - NGO:
CurrencyAuthorityBinder_NGO - Mirror:
CurrencyAuthorityBinder_Mirror - Fusion:
CurrencyAuthorityBinder_Fusion - Send client requests via a ServerProxy class (provided in samples).
- The server automatically enforces authority via the decorator.
- Replicate balances using your chosen netcode (SyncVar, NetworkVariable, Networked property, etc.).
Typical Flow (All Stacks)¶
- Client sends an RPC/Command to request a credit, debit, or transfer.
- Server/StateAuthority validates via the binder (
ICurrencyAuthority). - Server applies the mutation through the wrapped
ICurrencyService. - (Optional) Server broadcasts a HUD or VFX update to clients.
- Replication is handled separately by your netcode layer.
Per-Stack Notes¶
NGO (Netcode for GameObjects)¶
- Use
NetworkVariable<long>or custom structs to replicate balances. ServerRpcfor client→server,ClientRpcfor feedback.- Binder:
CurrencyAuthorityBinder_NGO.
Mirror¶
- Use
[SyncVar]or custom messages for replication. Commandfor client→server,ClientRpcfor feedback.- Binder:
CurrencyAuthorityBinder_Mirror.
Fusion¶
- Use
[Networked]properties or RPCs for replication. RpcSources.InputAuthority → RpcTargets.StateAuthorityfor 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.
Related¶
- 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.