RevFramework – Sample Scene: 01_Currency_PolicyCaps¶
Namespace: RevGaming.RevFramework.Runtime.Currency.Samples.Scenes
🎯 Purpose¶
Demonstrate how to enforce minimum and maximum wallet limits using a Currency Policy.
This scene shows how balance caps affect credit, debit, set, and transfer operations, and how Clamp and Fail modes change behaviour.
🧩 What This Scene Teaches¶
- How to define per-currency rules (min, max, and mode).
- The difference between Clamp and Fail policy modes.
- How to preview and apply operations under policy constraints.
- How Set, Credit, Debit, and Transfer operations interact with caps.
- How to compute and preview effective transfer amounts using
CurrencyServiceExtensions.
🕹️ How to Use¶
- Enter Play Mode.
- Open the CurrencyPolicyCapsPanel (
F8). - Use the arrow buttons to cycle through currencies.
- Observe the current policy rule (min, max, and mode).
- Test various operations:
- Set → Assign an absolute value.
- Credit / Debit → Apply changes and observe how caps respond.
- Transfer → Move value between A → B and see both wallets validated under the same rule.
- Adjust
CurrencyPolicyasset values live and see changes reflected 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.
💡 Key Takeaways¶
- Each currency can define independent min/max bounds and behaviour.
- Clamp Mode: Automatically adjusts values to remain within limits.
- Fail Mode: Rejects operations and returns a
CurOpResultwith a failure code. - Transfers apply caps to both source and destination wallets.
- Policies are data-driven — tweak the
CurrencyPolicyasset, no code changes required. - Cap logic is fully compatible with all decorators and services (e.g., Audit, Authority, Idempotency).
⚙️ Stack Composition¶
Bootstrap: CurrencyServiceBootstrap
Service Stack:
SceneCurrencyService → CappedCurrencyService → AuditedCurrencyService → AuthorityCurrencyService
(Authority provided by CurrencyAuthorityBinder, no idempotency in this scene)
Teaching Panel: CurrencyPolicyCapsPanel
Supporting Assets:
- CurrencyPolicy (ScriptableObject defining rules)
- CurrencySet (for currency lookup)
Scene Path:
Assets/RevFramework/Runtime/Systems/Currency/Samples/Scenes/01_Currency_PolicyCaps/
⚠️ Gotchas¶
- Policies are evaluated per operation — ensure you’re testing both
CreditandSetpaths. - A max of
0means “no upper bound,” not “block all.” - If a currency is not listed in the policy, it’s unrestricted.
- For debugging, check the console logs for returned
CurOpResult.Code. - Clamp mode may silently adjust values — use Fail mode when you need strict enforcement.
📚 Related¶
- 00_Currency_Basics — Fundamentals of wallet operations.
- Decorators —
CappedCurrencyServiceinternals. - Core —
CurrencyPolicyUtil,CurrencyFactories. - Definitions —
CurrencyDefinition,CurrencySetfor UI and persistence.