pub trait DispatchStrategy: Send + Sync {
// Required method
fn decide(
&mut self,
elevator: EntityId,
elevator_position: f64,
group: &ElevatorGroup,
manifest: &DispatchManifest,
world: &World,
) -> DispatchDecision;
// Provided methods
fn pre_dispatch(
&mut self,
_group: &ElevatorGroup,
_manifest: &DispatchManifest,
_world: &mut World,
) { ... }
fn decide_all(
&mut self,
elevators: &[(EntityId, f64)],
group: &ElevatorGroup,
manifest: &DispatchManifest,
world: &World,
) -> Vec<(EntityId, DispatchDecision)> { ... }
fn notify_removed(&mut self, _elevator: EntityId) { ... }
}Expand description
Pluggable dispatch algorithm.
Receives a manifest with per-rider metadata grouped by stop. Convenience methods provide aggregate counts; implementations can also iterate individual riders for priority/weight-aware dispatch.
Required Methods§
Sourcefn decide(
&mut self,
elevator: EntityId,
elevator_position: f64,
group: &ElevatorGroup,
manifest: &DispatchManifest,
world: &World,
) -> DispatchDecision
fn decide( &mut self, elevator: EntityId, elevator_position: f64, group: &ElevatorGroup, manifest: &DispatchManifest, world: &World, ) -> DispatchDecision
Decide for a single elevator.
Provided Methods§
Sourcefn pre_dispatch(
&mut self,
_group: &ElevatorGroup,
_manifest: &DispatchManifest,
_world: &mut World,
)
fn pre_dispatch( &mut self, _group: &ElevatorGroup, _manifest: &DispatchManifest, _world: &mut World, )
Optional hook called once before the per-group dispatch pass.
Strategies that need to mutate World extension storage (e.g.
DestinationDispatch writing sticky rider → car assignments) or
crate::components::DestinationQueue entries before per-elevator
decisions override this. The default is a no-op.
Called by [crate::systems::dispatch::run] for every group with
mutable world access. The corresponding DispatchManifest is
rebuilt internally so downstream decide/decide_all calls see
consistent state.
Sourcefn decide_all(
&mut self,
elevators: &[(EntityId, f64)],
group: &ElevatorGroup,
manifest: &DispatchManifest,
world: &World,
) -> Vec<(EntityId, DispatchDecision)>
fn decide_all( &mut self, elevators: &[(EntityId, f64)], group: &ElevatorGroup, manifest: &DispatchManifest, world: &World, ) -> Vec<(EntityId, DispatchDecision)>
Decide for all idle elevators in a group.
Default: calls decide() per elevator.
Sourcefn notify_removed(&mut self, _elevator: EntityId)
fn notify_removed(&mut self, _elevator: EntityId)
Notify the strategy that an elevator has been removed.
Implementations with per-elevator state (e.g., direction tracking) should clean up here to prevent unbounded memory growth. Default: no-op.