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 and testing scenes only.

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 in a scene is a developer error, not a framework bug.


🧩 Panel Categories

Currency teaching panels are split into two groups.

HostileConsumer

Panels in Teaching/HostileConsumer:

  • 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/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 Demo
CurrencyIdempotencyPanel Request replay protection HostileConsumer
CurrencyUIBarsPanel Live UI bindings Demo
CurrencyInventoryBackedPanel Inventory‑as‑currency adapter Demo

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

…and event observation:

currency.OnWalletChanged += (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 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

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

🧠 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 Runtime/Systems/Currency/Teaching/
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.