Expand description
Platform-agnostic simulation core.
Owns the Action / BuyQty types (the input router produces them;
apply_action is the only thing that interprets them) and the per-tick
state.tick() + ambient spawn helpers.
What lives outside this module:
- the threaded sim loop on native (
app.rs::sim_loop), which wrapssim_tick+apply_actionwithmpsc::recv_timeout, save scheduling via thePersistenceimpl, and the demo-recorder driver. - the requestAnimationFrame-driven loop on web (added when the wasm
port lands), which calls the same
sim_tick+apply_actionsingle-threaded.
The split is: this module is cross-platform; threading + I/O scheduling around it isn’t. See tracking issue #13 for rationale.
Structs§
- SimGeometry
- Geometry the sim needs to interpret screen-space events. Updated on
every render via
Action::UpdateGeometry.
Enums§
- Action
- Commands the input router produces and the sim consumes. The sim is
the sole authority on
GameStatemutation — input handling translates raw events (key/mouse/wheel) into these and feeds them through. - BuyQty
- Buy quantity for a fingerer purchase action. Modifier-key meaning is translated to this in the input router; sim only consumes the resolved value so the modifier mapping can change without touching tick logic.
Functions§
- apply_
action - Apply one
Actionto the canonicalGameState. Pure data: no I/O, no time, no threading. Called from both the native sim thread (onmpsc::recv_timeoutreturning Ok) and the web rAF loop. - sim_
tick - Run the platform-agnostic body of one sim tick: state updates + ambient
spawn helpers. Save scheduling and demo-driver autopilot are the
caller’s concern (they live in
app.rs::sim_loopon native).