Allow for door destruction

This commit is contained in:
2022-06-19 20:50:03 +01:00
parent 9e311cccf4
commit 08e5df07e2
14 changed files with 82 additions and 42 deletions
+7
View File
@@ -16,6 +16,8 @@ damageWall dt wl w = case _wlStructure wl of
& machines . ix mcid . mcDamage .:~ dt
BlockPart blid -> let (w',x) = defaultWallDamage dt wl w
in w' & blocks . ix blid . blHP -~ x & maybeDestroyBlock blid
DoorPart drid -> let (w',x) = defaultWallDamage dt wl w
in w' & doors . ix drid . drHP -~ x & maybeDestroyDoor drid
_ -> fst $ defaultWallDamage dt wl w
-- block destruction is convoluted...
@@ -24,6 +26,11 @@ maybeDestroyBlock blid w = case w ^? blocks . ix blid of
Just bl | _blHP bl < 1 -> destroyBlock bl w
_ -> w
maybeDestroyDoor :: Int -> World -> World
maybeDestroyDoor drid w = case w ^? doors . ix drid of
Just dr | _drHP dr < 1 -> destroyDoor dr w
_ -> w
damageBlocksBy :: Int -> Wall -> World -> World
damageBlocksBy x wl = case wl ^? wlStructure . wsBlock of
Just blid -> blocks . ix blid . blHP -~ x