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<'_>
impl MemberMut<'_>
Sourcepub fn id(&self) -> MemberId
pub fn id(&self) -> MemberId
The MemberId this member was borrowed with — see Member::id.
Sourcepub fn pos(&self) -> (f32, f32)
pub fn pos(&self) -> (f32, f32)
Where the member is — see Member::pos.
Sourcepub fn draw_pos(&self) -> (i16, i16)
pub fn draw_pos(&self) -> (i16, i16)
The coherent pixel the member draws at — see Member::draw_pos.
Sourcepub fn velocity(&self) -> Velocity
pub fn velocity(&self) -> Velocity
What the member is travelling at — see Member::velocity.
Sourcepub fn contacts(&self) -> Contacts
pub fn contacts(&self) -> Contacts
What the member’s last step ran into — see Member::contacts.
Sourcepub fn bounds(&self) -> Bounds
pub fn bounds(&self) -> Bounds
The rectangle the member covers — see Member::bounds.
Sourcepub fn confines(&self) -> Option<Bounds>
pub fn confines(&self) -> Option<Bounds>
The rectangle the member may not leave, if it named one — see Member::confines.
Sourcepub fn sprite(&self) -> Option<SpriteId>
pub fn sprite(&self) -> Option<SpriteId>
The cell the member wears, if any — see Member::sprite.
Sourcepub fn solid(&self) -> Option<BitFlags<SpriteFlag>>
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.
Sourcepub fn heeds(&self) -> BitFlags<SpriteFlag>
pub fn heeds(&self) -> BitFlags<SpriteFlag>
Which flags the member cares to be told about — see Member::heeds.
Sourcepub fn mass(&self) -> f32
pub fn mass(&self) -> f32
What the member weighs — see Member::mass.
Sourcepub fn flip(&self) -> (bool, bool)
pub fn flip(&self) -> (bool, bool)
Which way round the member is drawn — see Member::flip.
Sourcepub fn span(&self) -> (u8, u8)
pub fn span(&self) -> (u8, u8)
How many cells the member is drawn from, across and down — see Member::span.
Whether the member is left off the screen — see Member::hidden.
Sourcepub fn set_pos(&mut self, x: f32, y: f32)
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.
Sourcepub fn set_velocity(&mut self, velocity: Velocity)
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.
Sourcepub fn resize(&mut self, width: u16, height: u16)
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.
Sourcepub fn set_offset(&mut self, dx: i16, dy: i16)
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.
Sourcepub fn set_confines(&mut self, confines: Option<Bounds>)
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.
Sourcepub fn set_sprite(&mut self, sprite: Option<SpriteId>)
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.
Sourcepub fn set_solid(&mut self, solid: Option<BitFlags<SpriteFlag>>)
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.
Sourcepub fn set_heeds(&mut self, heeds: impl Into<BitFlags<SpriteFlag>>)
pub fn set_heeds(&mut self, heeds: impl Into<BitFlags<SpriteFlag>>)
Sets which flags the member cares to be told about — see MemberBuilder::heeding.
Sourcepub fn set_mass(&mut self, mass: f32)
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.
Sourcepub fn set_flip(&mut self, flip_x: bool, flip_y: bool)
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.
Sourcepub fn set_span(&mut self, width: u8, height: u8)
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.
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.
Sourcepub fn retire(self)
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.