Skip to main content

MemberMut

Struct MemberMut 

Source
pub struct MemberMut<'a> { /* private fields */ }
Expand description

A member borrowed from its world, to be changed.

What World::member_mut and World::get_member_mut hand back: every setter a cart might write into the seat, and retire to empty it. Borrowed exclusively, so it is held for the few lines that change one member and let go before the world steps or another member is borrowed.

Implementations§

Source§

impl MemberMut<'_>

Source

pub fn id(&self) -> MemberId

The MemberId this member was borrowed with — see Member::id.

Source

pub fn pos(&self) -> (f32, f32)

Where the member is — see Member::pos.

Source

pub fn draw_pos(&self) -> (i16, i16)

The coherent pixel the member draws at — see Member::draw_pos.

Source

pub fn velocity(&self) -> Velocity

What the member is travelling at — see Member::velocity.

Source

pub fn contacts(&self) -> Contacts

What the member’s last step ran into — see Member::contacts.

Source

pub fn bounds(&self) -> Bounds

The rectangle the member covers — see Member::bounds.

Source

pub fn confines(&self) -> Option<Bounds>

The rectangle the member may not leave, if it named one — see Member::confines.

Source

pub fn sprite(&self) -> Option<SpriteId>

The cell the member wears, if any — see Member::sprite.

Source

pub fn solid(&self) -> Option<BitFlags<SpriteFlag>>

The member’s own answer to what means wall to it, where it gave one — see Member::solid.

Source

pub fn heeds(&self) -> BitFlags<SpriteFlag>

Which flags the member cares to be told about — see Member::heeds.

Source

pub fn mass(&self) -> f32

What the member weighs — see Member::mass.

Source

pub fn flip(&self) -> (bool, bool)

Which way round the member is drawn — see Member::flip.

Source

pub fn span(&self) -> (u8, u8)

How many cells the member is drawn from, across and down — see Member::span.

Source

pub fn hidden(&self) -> bool

Whether the member is left off the screen — see Member::hidden.

Source

pub fn set_pos(&mut self, x: f32, y: f32)

Puts the member at (x, y) — a teleport, not a movement.

The drawn pixel is re-snapped to the floor of the new position rather than eased towards it, because this is a jump: a respawn, a room the player has walked into, the rails a prop is driven along. The rectangle goes with it, keeping whatever offset it was given.

Ordinary movement is not this. A member is moved by having a velocity (set_velocity) and being stepped: that is what is stopped by walls, held inside limits and reported in contacts, and none of it happens here.

Source

pub fn set_velocity(&mut self, velocity: Velocity)

Sets what the member is travelling at: what the cart means it to do this update.

Where the buttons, the patrol and the jump all end up. It is written before step, which is what turns it into movement — and written afresh every update by anything that leans on a wall, since the step spends the speed that ran into one.

Source

pub fn resize(&mut self, width: u16, height: u16)

Sets how big the member’s rectangle is.

For a hitbox that follows the animation — a crouch, a blast that grows, a hurtbox switched off by giving it no size at all, which is a member nothing resolves and everything lets through. Where the rectangle sits on the body is set_offset.

Source

pub fn set_offset(&mut self, dx: i16, dy: i16)

Sets where the member’s rectangle sits relative to the pixel it draws at — see MemberBuilder::offset.

Source

pub fn set_confines(&mut self, confines: Option<Bounds>)

Sets the rectangle the member may not leave, or takes its limits away — see MemberBuilder::confined_to.

The room the player has just walked into, an arena closing in, a level that grows. None is a member let go: free to walk off the map, which is what a bullet or a spent enemy wants.

Source

pub fn set_sprite(&mut self, sprite: Option<SpriteId>)

Sets the cell the member wears, or takes it off — see MemberBuilder::wearing.

How an animation is shown: the next frame of a walk cycle, written in the update that took the step. Cells carrying the same flags change how the member looks and nothing about what everybody meets, which is what a walk cycle wants; a badie that turns into a puff of smoke changes both.

Source

pub fn set_solid(&mut self, solid: Option<BitFlags<SpriteFlag>>)

Sets what means wall to the member, or hands it back to the scene’s word — see MemberBuilder::stopped_by.

None is the scene’s word as it stands now (with_solid), and the member follows it from here on.

Source

pub fn set_heeds(&mut self, heeds: impl Into<BitFlags<SpriteFlag>>)

Sets which flags the member cares to be told about — see MemberBuilder::heeding.

Source

pub fn set_mass(&mut self, mass: f32)

Sets what the member weighs: a crate that fills with water, a ship that burns its fuel off.

Source

pub fn set_flip(&mut self, flip_x: bool, flip_y: bool)

Sets which way round the member is drawn — see MemberBuilder::flipped.

The walker turning round: written in the update that turned it, beside the velocity that sends it back the way it came.

Source

pub fn set_span(&mut self, width: u8, height: u8)

Sets how many cells the member is drawn from, across and down — see MemberBuilder::spanning.

The pose that needs more room than the rest: a sword swung out a cell in front, a stretch a cell taller. It is the look alone — the rectangle the member is met by is resize’s, if it changes at all — and a block no sheet holds panics here as it does in spanning.

Source

pub fn set_hidden(&mut self, hidden: bool)

Hides the member, or shows it again — see MemberBuilder::hidden.

The blink: a hero flickering through the frames after a hit is hidden on every other one of them, and stepped, met and told on all of them alike.

Source

pub fn retire(self)

Empties the member’s seat: it leaves the cast, and the id to it goes stale on the spot.

What a cart does with a bullet that has left the screen, a badie that has been stomped, an explosion that has burned out. The seat is the next one enlist fills, and until it is filled it is nothing to anybody — the step carries it as a prop covering no pixels, which nothing meets and no force reaches.

The member is gone the moment this returns, so the meeting it died of has already been reported to whoever it met: the whole cast is stepped where it stands, and nothing is waiting on a picture of it.

Retiring a member twice, or asking the world to borrow it afterwards, is a bug in the cart and panics saying so.

Trait Implementations§

Source§

impl Debug for MemberMut<'_>

The member as Member prints it, wrapped in MemberMut(..).

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for MemberMut<'a>

§

impl<'a> Freeze for MemberMut<'a>

§

impl<'a> RefUnwindSafe for MemberMut<'a>

§

impl<'a> Send for MemberMut<'a>

§

impl<'a> Sync for MemberMut<'a>

§

impl<'a> Unpin for MemberMut<'a>

§

impl<'a> UnsafeUnpin for MemberMut<'a>

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