Refactor, try to limit dependencies
This commit is contained in:
+33
-24
@@ -1,45 +1,54 @@
|
||||
module Dodge.Machine where
|
||||
import Dodge.Data
|
||||
import Dodge.Wall.Delete
|
||||
|
||||
import Dodge.Base
|
||||
import Dodge.Data.World
|
||||
import Dodge.Machine.Damage
|
||||
import Dodge.SoundLogic
|
||||
import Dodge.Wall.Delete
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
import Sound.Data
|
||||
import Dodge.SoundLogic
|
||||
import Geometry
|
||||
import Dodge.Base
|
||||
|
||||
import qualified IntMapHelp 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
|
||||
-> Machine -> World -> World
|
||||
machineUpdateLiveDieEff ::
|
||||
-- | effect when hp >= 1
|
||||
(Machine -> World -> World) ->
|
||||
-- | effect (once) when hp < 1
|
||||
(Machine -> World -> World) ->
|
||||
Machine ->
|
||||
World ->
|
||||
World
|
||||
machineUpdateLiveDieEff livef dief mc
|
||||
| _mcHP mc < 1 = dief mc
|
||||
. (cWorld . machines %~ IM.delete mcid)
|
||||
. deleteWallIDs (_mcWallIDs mc)
|
||||
| otherwise = livef mc . (cWorld . machines . ix mcid %~ ( (mcDamage .~ []) . (mcHP -~ dams) ))
|
||||
| _mcHP mc < 1 =
|
||||
dief mc
|
||||
. (cWorld . machines %~ IM.delete mcid)
|
||||
. deleteWallIDs (_mcWallIDs mc)
|
||||
| otherwise = livef mc . (cWorld . machines . ix mcid %~ ((mcDamage .~ []) . (mcHP -~ dams)))
|
||||
where
|
||||
dams = sum $ map _dmAmount $ _mcDamage mc
|
||||
dams = sum $ map _dmAmount $ _mcDamage mc
|
||||
mcid = _mcID mc
|
||||
|
||||
machineUpdateDeathEff :: (Machine -> World -> World)
|
||||
-> Machine -> World -> World
|
||||
machineUpdateDeathEff ::
|
||||
(Machine -> World -> World) ->
|
||||
Machine ->
|
||||
World ->
|
||||
World
|
||||
machineUpdateDeathEff f mc
|
||||
| _mcHP mc < 1 = f mc
|
||||
. (cWorld . machines %~ IM.delete mcid)
|
||||
. deleteWallIDs (_mcWallIDs mc)
|
||||
| otherwise = cWorld . machines . ix mcid %~ ( (mcDamage .~ []) . (mcHP -~ dams) )
|
||||
| _mcHP mc < 1 =
|
||||
f mc
|
||||
. (cWorld . machines %~ IM.delete mcid)
|
||||
. deleteWallIDs (_mcWallIDs mc)
|
||||
| otherwise = cWorld . machines . ix mcid %~ ((mcDamage .~ []) . (mcHP -~ dams))
|
||||
where
|
||||
dams = sum $ map _dmAmount $ _mcDamage mc
|
||||
dams = sum $ map _dmAmount $ _mcDamage mc
|
||||
mcid = _mcID mc
|
||||
|
||||
machineAddSound :: SoundID -> (Machine -> World -> World) -> Machine -> World -> World
|
||||
machineAddSound sid f mc w
|
||||
| d < 200 = soundContinueVol (1-0.005*d) (MachineSound mid) (_mcPos mc) sid (Just 2) $ f mc w
|
||||
| d < 200 = soundContinueVol (1 -0.005 * d) (MachineSound mid) (_mcPos mc) sid (Just 2) $ f mc w
|
||||
| otherwise = f mc w
|
||||
where
|
||||
d = dist (_crPos $ you w) (_mcPos mc)
|
||||
|
||||
Reference in New Issue
Block a user