#[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
Jumped
The hero jumped. buffered: the press came before the jump was possible and waited
in the jump buffer.
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: f32Downward speed at contact, units/s (pixels/s from a scaled
crate::Platformer).
drop: i32Units 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).
DashEnded
The dash ran out and handed over its leftover speed.
Recharged
Dashes were refilled, on the ground or by a crystal.
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.
SuperDashEnded
The super dash is over.
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: i32Units 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: i32Units 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
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
impl Event
Sourcepub const fn with(self, data: [f32; 4]) -> Self
pub const fn with(self, data: [f32; 4]) -> Self
This event with data (only for Event::Custom; other events stay as they are).
Sourcepub fn in_pixels(self, k: i32) -> Self
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.
Trait Implementations§
impl Copy 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.