Skip to main content

Event

Enum Event 

Source
#[non_exhaustive]
pub enum Event {
Show 32 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, }, 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, }, StopRemoved { stop: EntityId, 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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

ElevatorDeparted

An elevator departed from a stop.

Fields

§elevator: EntityId

The elevator that departed.

§from_stop: EntityId

The stop it departed from.

§tick: u64

The tick when departure occurred.

§

ElevatorArrived

An elevator arrived at a stop.

Fields

§elevator: EntityId

The elevator that arrived.

§at_stop: EntityId

The stop it arrived at.

§tick: u64

The tick when arrival occurred.

§

DoorOpened

An elevator’s doors finished opening.

Fields

§elevator: EntityId

The elevator whose doors opened.

§tick: u64

The tick when the doors opened.

§

DoorClosed

An elevator’s doors finished closing.

Fields

§elevator: EntityId

The elevator whose doors closed.

§tick: u64

The tick when the doors closed.

§

PassingFloor

Emitted when an elevator passes a stop without stopping. Games/dispatch can use this to decide whether to add stops mid-travel.

Fields

§elevator: EntityId

The elevator passing by.

§stop: EntityId

The stop being passed.

§moving_up: bool

Direction: true = moving up, false = moving down.

§tick: u64

The tick when the pass occurred.

§

RiderSpawned

A new rider appeared at a stop and wants to travel.

Fields

§rider: EntityId

The spawned rider entity.

§origin: EntityId

The stop where the rider appeared.

§destination: EntityId

The stop the rider wants to reach.

§tick: u64

The tick when the rider spawned.

§

RiderBoarded

A rider boarded an elevator.

Fields

§rider: EntityId

The rider that boarded.

§elevator: EntityId

The elevator the rider boarded.

§tick: u64

The tick when boarding occurred.

§

RiderExited

A rider exited an elevator at a stop.

Fields

§rider: EntityId

The rider that exited.

§elevator: EntityId

The elevator the rider exited.

§stop: EntityId

The stop where the rider exited.

§tick: u64

The tick when exiting occurred.

§

RiderRejected

A rider was rejected from boarding (e.g., over capacity).

Fields

§rider: EntityId

The rider that was rejected.

§elevator: EntityId

The elevator that rejected the rider.

§reason: RejectionReason

The reason for rejection.

§context: Option<RejectionContext>

Additional numeric context for the rejection.

§tick: u64

The tick when rejection occurred.

§

RiderAbandoned

A rider gave up waiting and left the stop.

Fields

§rider: EntityId

The rider that abandoned.

§stop: EntityId

The stop the rider left.

§tick: u64

The tick when abandonment occurred.

§

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

§rider: EntityId

The rider that was ejected.

§elevator: EntityId

The elevator the rider was ejected from.

§stop: EntityId

The stop the rider was placed at.

§tick: u64

The tick when ejection occurred.

§

ElevatorAssigned

An elevator was assigned to serve a stop by the dispatcher.

Fields

§elevator: EntityId

The elevator that was assigned.

§stop: EntityId

The stop it was assigned to serve.

§tick: u64

The tick when the assignment occurred.

§

StopAdded

A new stop was added to the simulation.

Fields

§stop: EntityId

The new stop entity.

§line: EntityId

The line the stop was added to.

§group: GroupId

The group the stop was added to.

§tick: u64

The tick when the stop was added.

§

ElevatorAdded

A new elevator was added to the simulation.

Fields

§elevator: EntityId

The new elevator entity.

§line: EntityId

The line the elevator was added to.

§group: GroupId

The group the elevator was added to.

§tick: u64

The tick when the elevator was added.

§

EntityDisabled

An entity was disabled.

Fields

§entity: EntityId

The entity that was disabled.

§tick: u64

The tick when it was disabled.

§

EntityEnabled

An entity was re-enabled.

Fields

§entity: EntityId

The entity that was re-enabled.

§tick: u64

The tick when it was 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

§rider: EntityId

The affected rider.

§affected_stop: EntityId

The stop that caused the invalidation.

§reason: RouteInvalidReason

Why the route was invalidated.

§tick: u64

The tick when invalidation occurred.

§

RiderRerouted

A rider was manually rerouted via sim.reroute() or sim.reroute_rider().

Fields

§rider: EntityId

The rerouted rider.

§new_destination: EntityId

The new destination stop.

§tick: u64

The tick when rerouting occurred.

§

RiderSettled

A rider settled at a stop, becoming a resident.

Fields

§rider: EntityId

The rider that settled.

§stop: EntityId

The stop where the rider settled.

§tick: u64

The tick when settlement occurred.

§

RiderDespawned

A rider was removed from the simulation.

Fields

§rider: EntityId

The rider that was removed.

§tick: u64

The tick when despawn occurred.

§

LineAdded

A line was added to the simulation.

Fields

§line: EntityId

The new line entity.

§group: GroupId

The group the line was added to.

§tick: u64

The tick when the line was added.

§

LineRemoved

A line was removed from the simulation.

Fields

§line: EntityId

The removed line entity.

§group: GroupId

The group the line belonged to.

§tick: u64

The tick when the line was removed.

§

LineReassigned

A line was reassigned to a different group.

Fields

§line: EntityId

The line entity that was reassigned.

§old_group: GroupId

The group the line was previously in.

§new_group: GroupId

The group the line was moved to.

§tick: u64

The tick when reassignment occurred.

§

ElevatorReassigned

An elevator was reassigned to a different line.

Fields

§elevator: EntityId

The elevator that was reassigned.

§old_line: EntityId

The line the elevator was previously on.

§new_line: EntityId

The line the elevator was moved to.

§tick: u64

The tick when reassignment occurred.

§

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

§elevator: EntityId

The elevator being repositioned.

§to_stop: EntityId

The stop it is being sent to.

§tick: u64

The tick when repositioning began.

§

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

§elevator: EntityId

The elevator that completed repositioning.

§at_stop: EntityId

The stop it arrived at.

§tick: u64

The tick when it arrived.

§

ServiceModeChanged

An elevator’s service mode was changed.

Fields

§elevator: EntityId

The elevator whose mode changed.

§from: ServiceMode

The previous service mode.

§to: ServiceMode

The new service mode.

§tick: u64

The tick when the change occurred.

§

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

§elevator: EntityId

The elevator whose load changed.

§current_load: OrderedFloat<f64>

Current total weight aboard after the change.

§capacity: OrderedFloat<f64>

Maximum weight capacity of the elevator.

§tick: u64

The tick when the change occurred.

§

ElevatorIdle

An elevator became idle (no more assignments or repositioning).

Fields

§elevator: EntityId

The elevator that became idle.

§at_stop: Option<EntityId>

The stop where it became idle (if at a stop).

§tick: u64

The tick when it became idle.

§

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

§elevator: EntityId

The elevator whose indicator lamps changed.

§going_up: bool

New state of the up-direction lamp.

§going_down: bool

New state of the down-direction lamp.

§tick: u64

The tick when the change occurred.

§

ElevatorRemoved

An elevator was permanently removed from the simulation.

Distinct from [EntityDisabled] — a disabled elevator can be re-enabled, but a removed elevator is despawned.

Fields

§elevator: EntityId

The elevator that was removed.

§line: EntityId

The line it belonged to.

§group: GroupId

The group it belonged to.

§tick: u64

The tick when removal occurred.

§

StopRemoved

A stop was permanently removed from the simulation.

Distinct from [EntityDisabled] — a disabled stop can be re-enabled, but a removed stop is despawned.

Fields

§stop: EntityId

The stop that was removed.

§tick: u64

The tick when removal occurred.

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Event

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Event

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Event

Source§

fn eq(&self, other: &Event) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Event

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Event

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,