Allow monsters to break blocks
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Alex Page 2022-02-01 03:01:21 -05:00
parent b62f2759de
commit 82c4358ac7
2 changed files with 8 additions and 1 deletions

View file

@ -236,6 +236,11 @@ impl Map {
self.tiles[self.point2d_to_index(point)]
}
pub fn get_tile_at_mut(&mut self, point: Point) -> &mut TileType {
let index = self.point2d_to_index(point);
&mut self.tiles[index]
}
pub fn set_tile_at(&mut self, point: Point, tile: TileType) {
let index = self.point2d_to_index(point);
self.tiles[index] = tile;

View file

@ -88,10 +88,12 @@ impl<'a> System<'a> for MonsterAiSystem {
let _ = entities.delete(*entity);
}
} else {
match map.get_tile_at(destination) {
let tile = map.get_tile_at_mut(destination);
match tile {
TileType::Wall => {}
TileType::Block => {
// TODO: Sound
*tile = TileType::Floor;
let _ = entities.delete(*entity);
}
_ => {