pub struct World {
pub player: Player,
pub tuning: Tuning,
pub spawn: Spot,
pub respawn: bool,
pub tick: u64,
pub events: Vec<Event>,
pub abilities: Vec<Box<dyn Ability>>,
/* private fields */
}Expand description
The character’s movement: its body, its feel, and the bookkeeping between steps. The
world around it is a Terrain passed to every World::step, so it stays yours.
Fields§
§player: PlayerThe character’s body.
tuning: TuningThe movement feel.
spawn: SpotWhere it starts, and comes back to after falling out (units).
respawn: boolPut it back at World::spawn when it falls out (an Event::FellOut is
reported either way).
tick: u64Steps taken so far.
events: Vec<Event>What happened in the last step.
abilities: Vec<Box<dyn Ability>>Moves of your own, run in every step in this order (see Ability).
Implementations§
Source§impl World
impl World
Sourcepub fn scale(&self) -> i32
pub fn scale(&self) -> i32
Pixels of the game’s terrain per unit: 1 for a world stepped on its own, k under a
crate::Platformer with a Builder::scale(k). Abilities get it as
Step::scale, to ask a terrain they find in its pixels.
Sourcepub fn ability<T: Ability + 'static>(&self) -> Option<&T>
pub fn ability<T: Ability + 'static>(&self) -> Option<&T>
The first ability of type T, to read its state (a charge level, a phase): for a
driver of its animation, or the game.
Sourcepub fn ability_mut<T: Ability + 'static>(&mut self) -> Option<&mut T>
pub fn ability_mut<T: Ability + 'static>(&mut self) -> Option<&mut T>
World::ability, to change.
Sourcepub fn step(&mut self, terrain: &mut dyn Terrain, intent: &Intent)
pub fn step(&mut self, terrain: &mut dyn Terrain, intent: &Intent)
Advance one step of DT with intent in terrain. World::events then holds
what happened in this step.
It runs World::act, the terrain’s Terrain::update and World::settle;
several characters on one terrain run those apart, so the terrain updates once per
step (see crate::Party).
Sourcepub fn act(&mut self, terrain: &mut dyn Terrain, intent: &Intent)
pub fn act(&mut self, terrain: &mut dyn Terrain, intent: &Intent)
The first part of a step: the character moves (your abilities, the built-in moves, refills, bouncy ground), the terrain doesn’t update yet.
Sourcepub fn act_among(
&mut self,
terrain: &mut dyn Terrain,
intent: &Intent,
others: &[Rect],
)
pub fn act_among( &mut self, terrain: &mut dyn Terrain, intent: &Intent, others: &[Rect], )
World::act beside other characters, whose bodies its abilities see in
Step::others (a crate::Party passes them).
Sourcepub fn settle(&mut self, terrain: &mut dyn Terrain, extra: Option<(f32, f32)>)
pub fn settle(&mut self, terrain: &mut dyn Terrain, extra: Option<(f32, f32)>)
The last part of a step, after the terrain’s update: moving ground (and conveyor
belts) carry the character (extra adds to how far, for riding on other
characters), and it may be squished or fall out.
Sourcepub fn respawn_at(&mut self, at: Spot)
pub fn respawn_at(&mut self, at: Spot)
Start over at at (units): a fresh body, standing, with everything refilled, and
an Event::Respawned in World::events. For hazards and checkpoints;
World::spawn stays as it is.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for World
impl !Send for World
impl !Sync for World
impl !UnwindSafe for World
impl Freeze for World
impl Unpin for World
impl UnsafeUnpin for World
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.