Module session

Source
Expand description

Shared lifecycle and fixed-timestep coordination for local games. Shared start, pause, retry and fixed-timestep timing for local game sessions.

Game-specific rules still decide when a session has been won or lost. A local menu or overlay must not pause an authoritative remote match’s clock.

use ferravex_core::session::{GameSession, SessionState};

let mut session = GameSession::new(60.0, 8, false);
assert!(session.start());
let frame = session.advance(1.0 / 30.0);
let mut simulated_seconds = 0.0;
for _ in 0..frame.steps {
    simulated_seconds += frame.dt; // Update game rules with this fixed dt.
}
assert_eq!(session.tick(), 2);
assert!(simulated_seconds > 0.0);
assert!(session.set_paused(true));
assert_eq!(session.advance(10.0).steps, 0);
assert!(session.toggle_pause());
assert!(session.finish(true));
assert_eq!(session.state(), SessionState::Won);
session.restart();
assert_eq!(session.tick(), 0);

Structs§

GameSession
A local game lifecycle with an owned, deterministic FixedClock.
SessionConfig
Validated, reusable settings for a GameSession.

Enums§

SessionState
Host lifecycle state, independent of a game’s simulation-specific phases.
SessionStepError
A rejected request to issue an inspector tick with GameSession::step_paused.