This commit is contained in:
2026-06-13 21:33:38 -05:00
parent 299570bec8
commit 77eba1a09c
6 changed files with 127 additions and 18 deletions
+27
View File
@@ -254,6 +254,33 @@ impl Board {
}
}
/// Advances a [`Archetype::Pusher`] cell at `(x, y)` one step in its facing
/// direction. Reads the direction from the cell itself.
///
/// - If the target is passable: slides the pusher in.
/// - If the target has a pushable chain: pushes it first, then slides in.
/// - If blocked or out of bounds: no-op, returns `false`.
pub(crate) fn advance_pusher(&mut self, x: usize, y: usize) -> bool {
let Archetype::Pusher(dir) = self.get(x, y).1 else { return false; };
let (dx, dy): (i32, i32) = dir.into();
let tx = x as i32 + dx;
let ty = y as i32 + dy;
if !self.in_bounds((tx, ty)) {
return false;
}
let (tx, ty) = (tx as usize, ty as usize);
if self.is_passable(tx, ty) {
self.shift_solid(x, y, dx, dy);
true
} else if self.can_push(tx, ty, dir) {
self.push(tx, ty, dir); // clear the chain first
self.shift_solid(x, y, dx, dy);
true
} else {
false
}
}
/// Moves the single solid occupant of `(x, y)` one step by `(dx, dy)`.
///
/// A solid object is relocated; otherwise the grid archetype (a crate) is