Currency — Teaching Panels¶
The Teaching folder contains a set of lightweight IMGUI panels used for learning, debugging, and hands‑on testing of the Currency System directly inside your scenes.
Each panel is intentionally minimal and code‑first — ideal for exploring behaviour, copying patterns, and wiring your own production UI later.
Status: Sample / Teaching UI — intended for development and testing scenes only.
Define Guard:
REV_CURRENCY_PRESENT⚠️ Teaching content never reaches a player build. The build guard raises a compile
#erroron any Player build whileREV_TEACHABLESis set, so the build fails rather than shipping a debug overlay. To build, run Tools > RevGaming > RevFramework > Validate > Pre-Build Clean, or delete/moveAssets/RevFramework/Teaching. The define follows the Teaching folder and cannot be cleared on its own.
Panel Categories¶
Currency teaching panels are split into two groups.
HostileConsumer¶
Panels in Teaching/Currency/HostileConsumers:
- use only public APIs
- rely on documented runtime types
- do not modify runtime wiring
- avoid reflection and internal helpers
These panels act as API verification tools.
If they compile and run, the Currency public API surface is correct.
Demo¶
Panels in Teaching/Currency/Demos demonstrate scene integrations and optional seams, such as:
- UI bars
- scene bootstraps
- escrow pumps
- inventory‑backed currency
- example adapters
They are still written using public APIs, but they may rely on scene wiring or demo helpers, so they are not considered hostile‑consumer verification panels.
Panel Overview¶
| Panel | Focus | Category |
|---|---|---|
| CurrencyBasicsPanel | Credit / Debit / Set flows | HostileConsumer |
| CurrencyPolicyCapsPanel | Clamp vs Fail policies | HostileConsumer |
| CurrencyExchangePanel | Exchange tables, fees, rounding | HostileConsumer |
| CurrencyPersistenceAuditPanel | Save/load + audit trail | HostileConsumer |
| CurrencyBatchAndTxnPanel | Atomic multi‑op transactions | HostileConsumer |
| CurrencyAwaitersPanel | Async wallet awaiters | HostileConsumer |
| CurrencyEscrowPanel | Escrow lifecycle | HostileConsumer |
| CurrencyIdempotencyPanel | Request replay protection | HostileConsumer |
| CurrencySavePanel | Save files and the unsaved-wallet policy | HostileConsumer |
| CurrencyUIBarsPanel | Live UI bindings | Demo |
| CurrencyInventoryBackedPanel | Inventory‑as‑currency adapter | Demo — ships with the Inventory ↔ Currency integration, not with Currency |
Each panel demonstrates one specific concept.
All panels inherit from TeachablePanelBase, use pure IMGUI, and can be toggled at runtime for quick testing.
Learning Goals¶
Across the teaching panels you’ll learn to:
- Create and resolve wallets via the active
ICurrencyService - Perform credit, debit, and set operations safely
- Apply policy rules (Clamp vs Fail)
- Enforce currency caps and limits
- Configure exchange rates and fees
- Use escrow for delayed or conditional commits
- Protect operations with idempotency
- Execute atomic batch transactions
- Await balances and predicates via async awaiters
- Back a currency with inventory or external services
- Inspect audit logs and persistence state
Example: Basic Credit / Debit¶
Every teaching panel follows the same direct, copyable pattern:
var result = currency.Credit(owner, "Gold", 50);
if (!result.Success)
{
Debug.Log($"Credit failed: {result.Code}");
}
There is no ToUserMessage for a CurOpResult
Earlier revisions of this page showed result.ToUserMessage("Credit"). No version of that call is available to you. A previous correction on this page said the extension lives in the Inventory ↔ Currency integration and that adding the integration would give you its phrasing — that is not true either: the helper there is internal, so it is not callable from your project with or without the integration.
Read CurOpResult.Code directly and phrase it yourself. For the framework's own wording of a code, RevGaming.RevFramework.Common.UX.ReasonText is the public surface that renders one.
…and event observation:
currency.OnWalletChanged += delta =>
{
Debug.Log($"{delta.currency}: {delta.before} → {delta.after}");
};
OnWalletChanged carries a single CurrencyDelta — owner, currency, before and after — not four separate arguments. It reports where the balance moved from and to, so if you want the change as a plain number it is delta.after.amount - delta.before.amount — before and after are Money, not long.
No mock logic.
No demo‑only shortcuts.
These are the real calls your production UI will make.
Integration Tips¶
- Teaching panels are IMGUI‑based debugging tools.
- They are intended for development scenes, not shipped gameplay.
- Safe to keep in dev scenes — they don’t modify runtime systems.
- Copy service calls, result handling, and event wiring into your own UI.
- Ignore the IMGUI layout code — it’s scaffolding only.
Teaching Folder Layout¶
Teaching/Currency/
├─ HostileConsumers/
│ ├─ CurrencyBasicsPanel.cs
│ ├─ CurrencyPolicyCapsPanel.cs
│ ├─ CurrencyExchangePanel.cs
│ ├─ CurrencyPersistenceAuditPanel.cs
│ ├─ CurrencyBatchAndTxnPanel.cs
│ ├─ CurrencyAwaitersPanel.cs
│ ├─ CurrencyEscrowPanel.cs
│ ├─ CurrencyIdempotencyPanel.cs
│ └─ CurrencySavePanel.cs
│
└─ Demos/
├─ CurrencyServiceBootstrap_Escrow.cs
└─ CurrencyUIBarsPanel.cs
Integrations/Currency/InventoryIntegration/Teaching/
└─ CurrencyInventoryBackedPanel.cs
Samples/Systems/Currency/
└─ Matching demo scenes
CurrencyInventoryBackedPanel is not under Teaching/Currency/. It teaches the Inventory ↔ Currency integration, so it ships with that integration and exists only when both systems are installed. Owning Currency alone is why you would not find it.
Why Hostile Consumers Exist¶
RevFramework uses hostile‑consumer panels as a built‑in API verification layer.
These panels are written exactly how a developer outside the framework would consume the system.
If they compile and run:
- the public API surface is sufficient
- internal refactors cannot break external users
- the runtime model remains usable without internal access
In short:
If the hostile‑consumer panels work, the framework contract is intact.
Quick Review¶
| Attribute | Summary |
|---|---|
| Audience | Developers integrating or exploring the Currency system |
| Goal | Teach one clear behaviour per panel |
| Style | Code‑first, readable, dependency‑light |
| Location | Teaching/Currency/ |
| Verification | HostileConsumer panels verify the public API |
| Demonstration | Demo panels show scene integrations |
TL;DR¶
The Teaching folder is your in‑engine classroom.
HostileConsumer panels verify the public API surface.
Demo panels show real scene integrations like UI bars, escrow pumps, and adapters.Press Play, toggle the panels, and explore the Currency system live.