diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index 9f0fafc79..da95a6561 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -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 diff --git a/src/Dodge/Default.hs b/src/Dodge/Default.hs index d90c928da..fa02bbfff 100644 --- a/src/Dodge/Default.hs +++ b/src/Dodge/Default.hs @@ -209,6 +209,7 @@ defaultMachine = Machine , _mcWallIDs = mempty , _mcUpdate = defaultMachineUpdate , _mcDeath = \_ -> id + , _mcApplyDamage = \_ _ -> id , _mcDraw = const mempty , _mcPos = V2 0 0 , _mcDir = 0 diff --git a/src/Dodge/Machine.hs b/src/Dodge/Machine.hs index 66b545650..5db2c61bd 100644 --- a/src/Dodge/Machine.hs +++ b/src/Dodge/Machine.hs @@ -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 diff --git a/src/Dodge/Placement/Instance/Terminal.hs b/src/Dodge/Placement/Instance/Terminal.hs index f3ce29533..7843381f9 100644 --- a/src/Dodge/Placement/Instance/Terminal.hs +++ b/src/Dodge/Placement/Instance/Terminal.hs @@ -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) })