Refactor damages to materials

This commit is contained in:
2025-06-22 08:31:18 +01:00
parent df3fde5d3e
commit 9fa3e060d7
17 changed files with 576 additions and 609 deletions
+10 -5
View File
@@ -6,21 +6,26 @@ module Dodge.Wall.Damage (
damageWall,
) where
import Geometry.Vector
import Dodge.Material.Damage
import Dodge.Block
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 -> w' & cWorld . lWorld . machines . ix mcid . mcDamage .:~ dt
BlockPart blid -> w' & cWorld . lWorld . blocks . ix blid . blHP -~ x & maybeDestroyBlock blid
DoorPart drid -> w' & cWorld . lWorld . doors . ix drid . drHP -~ x & maybeDestroyDoor drid
BlockPart blid ->
w' & cWorld . lWorld . blocks . ix blid . blHP -~ x
& maybeDestroyBlock blid
DoorPart drid ->
w' & cWorld . lWorld . doors . ix drid . drHP -~ x
& maybeDestroyDoor drid
_ -> w'
where
x = dt' ^. dmAmount
(w', dt') = damageWallEffect dt wl w
x = dt ^. dmAmount
w' = damageMaterial dt (_wlMaterial wl) (argV $ uncurry (-) (_wlLine wl)) w
-- block destruction is convoluted...
maybeDestroyBlock :: Int -> World -> World