Refactor damages to materials
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user