Skip to main content

Module hooks

Module hooks 

Source
Expand description

Lifecycle hooks for injecting logic before/after simulation phases. Lifecycle hooks for injecting custom logic before/after simulation phases.

§Example

use elevator_core::prelude::*;
use elevator_core::hooks::Phase;

let mut sim = SimulationBuilder::demo()
    .before(Phase::Dispatch, |world| {
        // Inspect world state before dispatch runs
        let idle_count = world.iter_idle_elevators().count();
        let _ = idle_count; // use it
    })
    .build()
    .unwrap();

sim.step(); // hooks fire during each step

Enums§

Phase
Simulation phase identifier for hook registration.