pub struct GridTerrain<G>(pub G);Expand description
A Grid as a Terrain: solid tiles, one-way platforms, surfaces and pits by the
grid’s answers. Wrap a borrow of your map (GridTerrain(&map)) to step through it
each frame, or own it.
It builds on nothing and isn’t findable by find_mut (it may borrow). An ability
that needs your map: write the Terrain yourself, forwarding to the grid’s
Grid::overlaps_solid, Grid::on_platform and Grid::surface_of.
Tuple Fields§
§0: GTrait Implementations§
Source§impl<G: Clone> Clone for GridTerrain<G>
impl<G: Clone> Clone for GridTerrain<G>
impl<G: Copy> Copy for GridTerrain<G>
Source§impl<G: Debug> Debug for GridTerrain<G>
impl<G: Debug> Debug for GridTerrain<G>
Source§impl<G: Grid> Terrain for GridTerrain<G>
impl<G: Grid> Terrain for GridTerrain<G>
Source§fn solid(&self, r: Rect) -> bool
fn solid(&self, r: Rect) -> bool
Whether
r overlaps anything solid (walls, floors, ceilings, moving solids).Source§fn platform(&self, r: Rect) -> bool
fn platform(&self, r: Rect) -> bool
Whether
r stands exactly on top of a one-way platform (its bottom edge on the
platform’s top). One-way platforms hold from above, let the character jump up
through them, and drop it on down + jump.Source§fn surface(&self, r: Rect) -> Surface
fn surface(&self, r: Rect) -> Surface
What kind of ground or wall
r touches: the row under the feet while standing, the
column beside the body at a wall. Ice, conveyor belts, walls that can’t be climbed,
bouncy pads (see Surface). Default: the base’s, or Surface::DEFAULT.Source§fn base(&self) -> Option<&dyn Terrain>
fn base(&self) -> Option<&dyn Terrain>
The terrain this one builds on, which the defaults forward to, or
None.
terrain_layer! writes it with Terrain::base_mut and
Terrain::as_any_mut. Required, so a wrapper can’t lose its base’s platforms,
refills and pits by forgetting it.Source§fn refill(&mut self, r: Rect) -> bool
fn refill(&mut self, r: Rect) -> bool
The character’s body
r touches a dash refill: use it up and return true (it’s
only asked when a dash is spent).Source§fn tick(&mut self, _dt: f32, _bodies: &[Rect])
fn tick(&mut self, _dt: f32, _bodies: &[Rect])
This layer’s own update, once per step after the characters moved, with their
bodies (one, unless several share the terrain through a crate::Party): let
things fall onto them, refills come back, platforms move. Only this layer’s state:
Terrain::update runs the bases’ ticks by itself. Default: nothing.Source§fn update(&mut self, dt: f32, bodies: &[Rect])
fn update(&mut self, dt: f32, bodies: &[Rect])
The whole terrain’s update:
Terrain::tick on this layer, then on every base
down the chain. Don’t write it; write Terrain::tick. Only an adapter that hands
its base something else than it got (converted bodies, say) writes it, and then
calls the base’s update.Source§fn carry(&self, r: Rect) -> (f32, f32)
fn carry(&self, r: Rect) -> (f32, f32)
How far the solid (or one-way platform) overlapping
r moved in the last
Terrain::update, in units: moving platforms, elevators. Read moreSource§fn base_mut(&mut self) -> Option<&mut dyn Terrain>
fn base_mut(&mut self) -> Option<&mut dyn Terrain>
Terrain::base, to change. Return the same terrain from both (checked in debug
builds).Source§fn as_any_mut(&mut self) -> Option<&mut dyn Any>
fn as_any_mut(&mut self) -> Option<&mut dyn Any>
This terrain as itself, so an
Ability can reach your type
through find_mut (break a block, flip a
switch): Some(self), which terrain_layer! writes.
Default: None, it isn’t found (its Terrain::base still is).Auto Trait Implementations§
impl<G> Freeze for GridTerrain<G>where
G: Freeze,
impl<G> RefUnwindSafe for GridTerrain<G>where
G: RefUnwindSafe,
impl<G> Send for GridTerrain<G>where
G: Send,
impl<G> Sync for GridTerrain<G>where
G: Sync,
impl<G> Unpin for GridTerrain<G>where
G: Unpin,
impl<G> UnsafeUnpin for GridTerrain<G>where
G: UnsafeUnpin,
impl<G> UnwindSafe for GridTerrain<G>where
G: UnwindSafe,
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
Mutably borrows from an owned value. Read more
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>
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>
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)
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)
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.