Add explicit machine damage application

This commit is contained in:
2022-06-05 10:56:15 +01:00
parent fcc6d3952c
commit 0afbb39aaf
4 changed files with 7 additions and 1 deletions
+1
View File
@@ -958,6 +958,7 @@ data Machine = Machine
, _mcWallIDs :: IS.IntSet
, _mcUpdate :: Machine -> World -> World
, _mcDeath :: Machine -> World -> World
, _mcApplyDamage :: [Damage] -> Machine -> World -> World
, _mcDraw :: Machine -> SPic
, _mcPos :: Point2
, _mcDir :: Float
+1
View File
@@ -209,6 +209,7 @@ defaultMachine = Machine
, _mcWallIDs = mempty
, _mcUpdate = defaultMachineUpdate
, _mcDeath = \_ -> id
, _mcApplyDamage = \_ _ -> id
, _mcDraw = const mempty
, _mcPos = V2 0 0
, _mcDir = 0
+4
View File
@@ -1,6 +1,7 @@
module Dodge.Machine where
import Dodge.Data
import Dodge.Wall.Delete
import Dodge.Machine.Damage
import LensHelp
import Sound.Data
import Dodge.SoundLogic
@@ -9,6 +10,9 @@ import Dodge.Base
import qualified Data.IntMap.Strict as IM
basicMachineUpdate :: (Machine -> World -> World) -> Machine -> World -> World
basicMachineUpdate f mc = basicMachineApplyDamage mc . f mc
machineUpdateLiveDieEff
:: (Machine -> World -> World) -- | effect when hp >= 1
-> (Machine -> World -> World) -- | effect (once) when hp < 1
+1 -1
View File
@@ -42,7 +42,7 @@ putTerminal col f = ps0PushPSw PutNothing $ \_ _ -> Just $
$ \pl -> Just $ pt0 (PutMachine col (reverse $ square 10) defaultMachine
{ _mcDraw = noPic . terminalShape col
, _mcHP = 100
, _mcUpdate = machineAddSound fridgeHumS (\_ -> id)
, _mcUpdate = basicMachineUpdate $ machineAddSound fridgeHumS (\_ -> id)
, _mcDeath = \mc -> (buttons . at (fromJust (_plMID pl)) .~ Nothing)
. makeExplosionAt (_mcPos mc)
})