#[non_exhaustive]pub enum Event {
Show 38 variants
ElevatorDeparted {
elevator: EntityId,
from_stop: EntityId,
tick: u64,
},
ElevatorArrived {
elevator: EntityId,
at_stop: EntityId,
tick: u64,
},
DoorOpened {
elevator: EntityId,
tick: u64,
},
DoorClosed {
elevator: EntityId,
tick: u64,
},
PassingFloor {
elevator: EntityId,
stop: EntityId,
moving_up: bool,
tick: u64,
},
RiderSpawned {
rider: EntityId,
origin: EntityId,
destination: EntityId,
tick: u64,
},
RiderBoarded {
rider: EntityId,
elevator: EntityId,
tick: u64,
},
RiderExited {
rider: EntityId,
elevator: EntityId,
stop: EntityId,
tick: u64,
},
RiderRejected {
rider: EntityId,
elevator: EntityId,
reason: RejectionReason,
context: Option<RejectionContext>,
tick: u64,
},
RiderAbandoned {
rider: EntityId,
stop: EntityId,
tick: u64,
},
RiderEjected {
rider: EntityId,
elevator: EntityId,
stop: EntityId,
tick: u64,
},
ElevatorAssigned {
elevator: EntityId,
stop: EntityId,
tick: u64,
},
StopAdded {
stop: EntityId,
line: EntityId,
group: GroupId,
tick: u64,
},
ElevatorAdded {
elevator: EntityId,
line: EntityId,
group: GroupId,
tick: u64,
},
EntityDisabled {
entity: EntityId,
tick: u64,
},
EntityEnabled {
entity: EntityId,
tick: u64,
},
RouteInvalidated {
rider: EntityId,
affected_stop: EntityId,
reason: RouteInvalidReason,
tick: u64,
},
RiderRerouted {
rider: EntityId,
new_destination: EntityId,
tick: u64,
},
RiderSettled {
rider: EntityId,
stop: EntityId,
tick: u64,
},
RiderDespawned {
rider: EntityId,
tick: u64,
},
LineAdded {
line: EntityId,
group: GroupId,
tick: u64,
},
LineRemoved {
line: EntityId,
group: GroupId,
tick: u64,
},
LineReassigned {
line: EntityId,
old_group: GroupId,
new_group: GroupId,
tick: u64,
},
ElevatorReassigned {
elevator: EntityId,
old_line: EntityId,
new_line: EntityId,
tick: u64,
},
ElevatorRepositioning {
elevator: EntityId,
to_stop: EntityId,
tick: u64,
},
ElevatorRepositioned {
elevator: EntityId,
at_stop: EntityId,
tick: u64,
},
ServiceModeChanged {
elevator: EntityId,
from: ServiceMode,
to: ServiceMode,
tick: u64,
},
EnergyConsumed {
elevator: EntityId,
consumed: OrderedFloat<f64>,
regenerated: OrderedFloat<f64>,
tick: u64,
},
CapacityChanged {
elevator: EntityId,
current_load: OrderedFloat<f64>,
capacity: OrderedFloat<f64>,
tick: u64,
},
ElevatorIdle {
elevator: EntityId,
at_stop: Option<EntityId>,
tick: u64,
},
DirectionIndicatorChanged {
elevator: EntityId,
going_up: bool,
going_down: bool,
tick: u64,
},
ElevatorRemoved {
elevator: EntityId,
line: EntityId,
group: GroupId,
tick: u64,
},
DestinationQueued {
elevator: EntityId,
stop: EntityId,
tick: u64,
},
StopRemoved {
stop: EntityId,
tick: u64,
},
DoorCommandQueued {
elevator: EntityId,
command: DoorCommand,
tick: u64,
},
DoorCommandApplied {
elevator: EntityId,
command: DoorCommand,
tick: u64,
},
ElevatorUpgraded {
elevator: EntityId,
field: UpgradeField,
old: UpgradeValue,
new: UpgradeValue,
tick: u64,
},
ManualVelocityCommanded {
elevator: EntityId,
target_velocity: Option<OrderedFloat<f64>>,
tick: u64,
},
}Expand description
Events emitted by the simulation during ticks.
All entity references use EntityId. Games can look up additional
component data on the referenced entity if needed.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ElevatorDeparted
An elevator departed from a stop.
Fields
ElevatorArrived
An elevator arrived at a stop.
Fields
DoorOpened
An elevator’s doors finished opening.
DoorClosed
An elevator’s doors finished closing.
PassingFloor
Emitted when an elevator passes a stop without stopping. Games/dispatch can use this to decide whether to add stops mid-travel.
Fields
RiderSpawned
A new rider appeared at a stop and wants to travel.
Fields
RiderBoarded
A rider boarded an elevator.
Fields
RiderExited
A rider exited an elevator at a stop.
Fields
RiderRejected
A rider was rejected from boarding (e.g., over capacity).
Fields
reason: RejectionReasonThe reason for rejection.
context: Option<RejectionContext>Additional numeric context for the rejection.
RiderAbandoned
A rider gave up waiting and left the stop.
Fields
RiderEjected
A rider was ejected from an elevator (due to disable or despawn).
The rider is moved to Waiting phase at the nearest stop.
Fields
ElevatorAssigned
An elevator was assigned to serve a stop by the dispatcher.
Fields
StopAdded
A new stop was added to the simulation.
Fields
ElevatorAdded
A new elevator was added to the simulation.
Fields
EntityDisabled
An entity was disabled.
EntityEnabled
An entity was re-enabled.
RouteInvalidated
A rider’s route was invalidated due to topology change.
Emitted when a stop on a rider’s route is disabled or removed. If no alternative is found, the rider will abandon after a grace period.
Fields
reason: RouteInvalidReasonWhy the route was invalidated.
RiderRerouted
A rider was manually rerouted via sim.reroute() or sim.reroute_rider().
Fields
RiderSettled
A rider settled at a stop, becoming a resident.
Fields
RiderDespawned
A rider was removed from the simulation.
LineAdded
A line was added to the simulation.
Fields
LineRemoved
A line was removed from the simulation.
Fields
LineReassigned
A line was reassigned to a different group.
Fields
ElevatorReassigned
An elevator was reassigned to a different line.
Fields
ElevatorRepositioning
An elevator is being repositioned to improve coverage.
Emitted when an idle elevator begins moving to a new position
as decided by the RepositionStrategy.
Fields
ElevatorRepositioned
An elevator completed repositioning and arrived at its target.
Note: this is detected by the movement system — the elevator
arrives just like any other movement. Games can distinguish
repositioning arrivals from dispatch arrivals by tracking
which elevators received ElevatorRepositioning events.
Fields
ServiceModeChanged
An elevator’s service mode was changed.
EnergyConsumed
Energy consumed/regenerated by an elevator this tick.
Requires the energy feature.
Fields
consumed: OrderedFloat<f64>Energy consumed this tick.
regenerated: OrderedFloat<f64>Energy regenerated this tick.
CapacityChanged
An elevator’s load changed (rider boarded or exited).
Emitted immediately after RiderBoarded or
RiderExited. Useful for real-time capacity
bar displays in game UIs.
Load values use OrderedFloat for
Eq compatibility. Dereference to get the inner f64:
use elevator_core::events::Event;
if let Event::CapacityChanged { current_load, capacity, .. } = event {
let pct = *current_load / *capacity * 100.0;
println!("Elevator at {pct:.0}% capacity");
}Fields
current_load: OrderedFloat<f64>Current total weight aboard after the change.
capacity: OrderedFloat<f64>Maximum weight capacity of the elevator.
ElevatorIdle
An elevator became idle (no more assignments or repositioning).
Fields
DirectionIndicatorChanged
An elevator’s direction indicator lamps changed.
Emitted by the dispatch phase when the pair
(going_up, going_down) transitions to a new value — e.g. when
a car is assigned a target above it (up-only), below it (down-only),
or returns to idle (both lamps lit).
Games can use this for UI (lighting up-arrow / down-arrow indicators on a car) without polling the elevator each tick.
Fields
ElevatorRemoved
An elevator was permanently removed from the simulation.
Distinct from Event::EntityDisabled — a disabled elevator can be
re-enabled, but a removed elevator is despawned.
Fields
DestinationQueued
A stop was queued as a destination for an elevator.
Emitted by Simulation::push_destination,
Simulation::push_destination_front,
and the built-in dispatch phase whenever it actually appends a stop
to an elevator’s DestinationQueue.
Adjacent-duplicate pushes (that are deduplicated) do not emit.
Fields
StopRemoved
A stop was permanently removed from the simulation.
Distinct from Event::EntityDisabled — a disabled stop can be
re-enabled, but a removed stop is despawned.
DoorCommandQueued
A manual door-control command was received and either applied immediately or stored for later.
Emitted by
Simulation::request_door_open,
Simulation::request_door_close,
Simulation::hold_door_open,
and Simulation::cancel_door_hold
when the command is accepted. Paired with
Event::DoorCommandApplied when the command eventually takes effect.
Fields
command: DoorCommandThe command that was queued.
DoorCommandApplied
A queued door-control command actually took effect — doors began opening/closing or a hold was applied.
Fields
command: DoorCommandThe command that was applied.
ElevatorUpgraded
An elevator parameter was mutated at runtime via one of the
Simulation::set_* upgrade setters (e.g. buying a speed upgrade
in an RPG, or a scripted event changing capacity mid-game).
Emitted immediately when the setter succeeds. Games can use this to trigger score popups, SFX, or UI updates.
Fields
field: UpgradeFieldWhich field was changed.
old: UpgradeValuePrevious value of the field.
new: UpgradeValueNew value of the field.
ManualVelocityCommanded
A velocity command was submitted to an elevator running in
ServiceMode::Manual.
Emitted by
Simulation::set_target_velocity
and Simulation::emergency_stop.
Implementations§
Source§impl Event
impl Event
Sourcepub const fn category(&self) -> EventCategory
pub const fn category(&self) -> EventCategory
Classify this event into a coarse-grained EventCategory.
Useful when a consumer only cares about, say, rider activity and wants to skip elevator-motion and topology chatter without enumerating every variant. The exhaustive match inside guarantees the method stays in sync when new variants are added.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Event
impl<'de> Deserialize<'de> for Event
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Event
impl StructuralPartialEq for Event
Auto Trait Implementations§
impl Freeze for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnsafeUnpin for Event
impl UnwindSafe for Event
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.