Fix no damage to walls bug

This commit is contained in:
2022-07-28 18:57:53 +01:00
parent ec4ff84c46
commit c8ad3e1294
19 changed files with 177 additions and 158 deletions
+8 -11
View File
@@ -11,19 +11,16 @@ import Dodge.Data.World
import Dodge.Wall.DamageEffect
import LensHelp
-- maybeDestroyDoor should rather happen during the door mechanism update
damageWall :: Damage -> Wall -> World -> World
damageWall dt wl w = case _wlStructure wl of
MachinePart mcid ->
fst . defaultWallDamage dt wl $
w
& cWorld . machines . ix mcid . mcDamage .:~ dt
BlockPart blid ->
let (w', x) = defaultWallDamage dt wl w
in w' & cWorld . blocks . ix blid . blHP -~ x & maybeDestroyBlock blid
DoorPart drid ->
let (w', x) = defaultWallDamage dt wl w
in w' & cWorld . doors . ix drid . drHP -~ x & maybeDestroyDoor drid
_ -> fst $ defaultWallDamage dt wl w
MachinePart mcid -> w' & cWorld . machines . ix mcid . mcDamage .:~ dt
BlockPart blid -> w' & cWorld . blocks . ix blid . blHP -~ x & maybeDestroyBlock blid
DoorPart drid -> w' & cWorld . doors . ix drid . drHP -~ x & maybeDestroyDoor drid
_ -> w'
where
x = dt' ^. dmAmount
(w', dt') = damageWallEffect dt wl w
-- block destruction is convoluted...
maybeDestroyBlock :: Int -> World -> World