Skip to content

💰 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/testing scenes only. Not for shipping.

Define Guard: REV_CURRENCY_PRESENT

⚠️ If a Teaching panel is present on a GameObject in a shipped scene, it will be visible and interactive at runtime.
Shipping with Teaching panels attached is a developer error, not a framework bug.


🧩 Panel Overview

Panel Focus Notes
CurrencyBasicsPanel Credit / Debit / Set flows Core wallet operations and events
CurrencyPolicyCapsPanel Clamp vs Fail policies Demonstrates per-currency caps
CurrencyExchangePanel Exchange tables, fees, rounding Uses CurrencyExchangeTable
CurrencyPersistenceAuditPanel Save/load + audit trail JSON persistence and history
CurrencyUIBarsPanel Live UI bindings UGUI / TMP / UITK examples
CurrencyEscrowPanel Holds, commits, releases Escrow lifecycle + expiry
CurrencyIdempotencyPanel Request replay protection Safe retries with instant OK
CurrencyBatchAndTxnPanel Atomic multi-op transactions Batch events and rollback
CurrencyAwaitersPanel Async wallet awaiters Balance, delta, predicate waits
CurrencyInventoryBackedPanel Inventory-as-currency adapter Wraps inventory as a wallet

Each panel is self-contained and demonstrates one clear concept.
All panels inherit from TeachablePanelBase, use pure IMGUI, anchor top-left, and toggle with the Backquote (`) key.


🎯 Learning Goals

Across all 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 and test 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(result.ToUserMessage("Credit"));
}

…and event observation:

currency.OnBalanceChanged += (owner, id, delta, total) =>
{
    Debug.Log($"{id}: {delta:+#;-#;0} → {total}");
};

No mock logic.
No demo-only shortcuts.
These are the real calls your production UI will make.


🧰 Integration Tips

  • Teaching panels are IMGUI-based and intended for Editor use only.
  • They are excluded from player builds unless explicitly enabled and left in a scene.
  • Safe to keep in dev scenes — they won’t affect runtime systems.
  • Copy service calls, result handling, and event wiring into your own UI.
  • Ignore IMGUI/layout code — it’s scaffolding only.

For adapter-based panels, ensure:

  • Required services are present in the scene
  • Decorators are registered in the correct order
  • Persistence providers are configured if used

Panels will clearly warn if something is missing.


🧱 Teaching Folder Layout

Currency/
 ├─ Teaching/
 │   ├─ CurrencyBasicsPanel.cs
 │   ├─ CurrencyPolicyCapsPanel.cs
 │   ├─ CurrencyExchangePanel.cs
 │   ├─ CurrencyPersistenceAuditPanel.cs
 │   ├─ CurrencyUIBarsPanel.cs
 │   ├─ CurrencyEscrowPanel.cs
 │   ├─ CurrencyIdempotencyPanel.cs
 │   ├─ CurrencyBatchAndTxnPanel.cs
 │   ├─ CurrencyAwaitersPanel.cs
 │   ├─ CurrencyInventoryBackedPanel.cs
 │   └─ CurrencyKitchenSinkPanel.cs
 └─ Samples/
     └─ Matching demo scenes

🧠 Quick Review

Attribute Summary
Audience Developers integrating or exploring the Currency system
Goal Teach one clear behaviour per panel
Style Code-first, readable, and dependency-light
Location Assets/RevFramework/Runtime/Systems/Currency/Teaching/
Safety Editor-focused; must not be shipped with scenes
Theme IMGUI — consistent with all RevFramework teaching panels

TL;DR

The Teaching folder is your in-engine classroom.
Each panel is a focused lesson — from basic wallets to escrow, idempotency, and atomic transactions.
Press Play, hit `, and explore the Currency system live — then copy the patterns into your own UI.