Skip to main content

Event

Enum Event 

Source
#[non_exhaustive]
pub enum Event {
Show 30 variants Jumped { kind: JumpKind, buffered: bool, }, JumpCut, Apex, LeftGround, DroppedThrough, Landed { impact: f32, drop: i32, }, RollStarted, RollEnded, HardLanded, Recovered, Dashed { dx: f32, dy: f32, }, DashEnded, Recharged { crystal: bool, }, Grabbed, LetGo, ClimbHop, StaminaOut, DiveStarted, SuperCharged, SuperDashStarted { dir: i32, }, SuperDashEnded { bonk: bool, }, GlideStarted, GlideEnded, DiveImpact { drop: i32, }, Bonked, CornerCorrected { dx: i32, }, FellOut, Custom { id: CustomId, data: [f32; 4], }, Squished, Respawned,
}
Expand description

Something that happened in one step. New moves bring new events, so matches need a _ arm.

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.
§

Jumped

The hero jumped. buffered: the press came before the jump was possible and waited in the jump buffer.

Fields

§kind: JumpKind

Which kind of jump.

§buffered: bool

Whether the press was queued.

§

JumpCut

The hero let go of jump while rising and the jump was cut short.

§

Apex

Vertical speed crossed zero going up to down in the air.

§

LeftGround

The hero walked or rolled off the ground (not by jumping).

§

DroppedThrough

Down + jump on a one-way platform: dropping through it.

§

Landed

The hero touched down.

Fields

§impact: f32

Downward speed at contact, units/s (pixels/s from a scaled crate::Platformer).

§drop: i32

Units fallen from the highest point of the airtime (pixels from a scaled crate::Platformer).

§

RollStarted

A landing turned into a roll.

§

RollEnded

The roll ran out (not by jumping).

§

HardLanded

A landing from high up without moving: a heavy landing that costs control.

§

Recovered

A heavy landing or a dive impact is over.

§

Dashed

A dash started, in direction dx, dy (8-way, normalized, y down).

Fields

§dx: f32

Horizontal direction.

§dy: f32

Vertical direction.

§

DashEnded

The dash ran out and handed over its leftover speed.

§

Recharged

Dashes were refilled, on the ground or by a crystal.

Fields

§crystal: bool

By a crystal (in the air), not by the ground.

§

Grabbed

Grabbed a wall.

§

LetGo

Let go of a wall (released grab, wall ended, or out of stamina).

§

ClimbHop

Climbed over the top of a wall with a small hop.

§

StaminaOut

Stamina ran out on a wall.

§

DiveStarted

A dive started: a short hang, then straight down.

§

SuperCharged

The super dash finished charging: release to launch.

§

SuperDashStarted

The super dash launched.

Fields

§dir: i32

Direction, -1 or 1.

§

SuperDashEnded

The super dash is over.

Fields

§bonk: bool

It hit a wall (otherwise it was cancelled).

§

GlideStarted

The cloak opened: gliding.

§

GlideEnded

The glide is over (jump released, landed, a wall, a dash).

§

DiveImpact

A dive hit the ground.

Fields

§drop: i32

Units fallen from the dive’s start (pixels from a scaled crate::Platformer).

§

Bonked

The head hit a ceiling.

§

CornerCorrected

The head clipped a ceiling corner and was nudged past it.

Fields

§dx: i32

Units nudged, signed (pixels from a scaled crate::Platformer).

§

FellOut

The character fell out of the world (the terrain said so).

§

Custom

Something of your own happened (an Ability reported it). Make one with Event::custom and add numbers with Event::with.

Fields

§id: CustomId

Which of your events (see CustomId).

§data: [f32; 4]

Up to four numbers of your own: a knockback’s speed, a hit target’s index, a charge level. Zero when unused.

§

Squished

Something solid moved into the character (moving ground carried it into a ceiling, a moving solid hit it): it’s stuck inside. Reported every step it stays so; usually a respawn.

§

Respawned

It was put back at its spawn point (after falling out, unless respawning is off).

Implementations§

Source§

impl Event

Source

pub const fn custom(id: CustomId) -> Self

A custom event id without data.

Source

pub const fn with(self, data: [f32; 4]) -> Self

This event with data (only for Event::Custom; other events stay as they are).

Source

pub fn in_pixels(self, k: i32) -> Self

This event with its distances and speeds in pixels, k per unit: a landing’s drop and impact, a dive impact’s drop, a corner correction’s dx. What a crate::Platformer with a crate::Builder::scale hands out; directions and Event::Custom data (yours, in units) stay as they are.

Source

pub fn custom_data(&self, id: CustomId) -> Option<[f32; 4]>

The data of custom event id, if this is one.

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Event

Source§

impl Debug for Event

Source§

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

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

impl PartialEq for Event

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more