Add some background sounds to machines
This commit is contained in:
@@ -18,7 +18,8 @@ data SoundOrigin
|
||||
| CrWeaponSound Int Int
|
||||
| ItemSound Int Int
|
||||
| CrWeaponFailSound Int
|
||||
| MachineSound Int
|
||||
| MachinePrimarySound Int
|
||||
| MachineBackgroundSound Int
|
||||
| MachineAltSound Int
|
||||
| TerminalSound
|
||||
| WallSound Int
|
||||
|
||||
@@ -1153,7 +1153,7 @@ doGenFloat (UniRandFloat x y) g = randomR (x, y) g
|
||||
|
||||
mcShootLaser :: Item -> Machine -> World -> World
|
||||
mcShootLaser _ mc =
|
||||
shootLaser (MachineSound (_mcID mc)) (DamageLaser 11) 1 pos dir yellow
|
||||
shootLaser (MachinePrimarySound (_mcID mc)) (DamageLaser 11) 1 pos dir yellow
|
||||
where
|
||||
pos = _mcPos mc +.+ 20 *.* unitVectorAtAngle dir
|
||||
dir = mc ^?! mcType . _McTurret . tuDir
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
module Dodge.Machine where
|
||||
|
||||
import Linear
|
||||
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
|
||||
|
||||
basicMachineUpdate :: (Machine -> World -> World) -> Machine -> World -> World
|
||||
basicMachineUpdate f mc = basicMachineApplyDamage mc . f mc
|
||||
|
||||
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 . lWorld . machines %~ IM.delete mcid)
|
||||
. deleteWallIDs (_mcWallIDs mc)
|
||||
| otherwise = livef mc . (cWorld . lWorld . machines . ix mcid %~ ((mcDamage .~ []) . (mcHP -~ dams)))
|
||||
where
|
||||
dams = sum $ map _dmAmount $ _mcDamage mc
|
||||
mcid = _mcID mc
|
||||
|
||||
machineUpdateDeathEff ::
|
||||
(Machine -> World -> World) ->
|
||||
Machine ->
|
||||
World ->
|
||||
World
|
||||
machineUpdateDeathEff f mc
|
||||
| _mcHP mc < 1 =
|
||||
f mc
|
||||
. (cWorld . lWorld . machines %~ IM.delete mcid)
|
||||
. deleteWallIDs (_mcWallIDs mc)
|
||||
| otherwise = cWorld . lWorld . machines . ix mcid %~ ((mcDamage .~ []) . (mcHP -~ dams))
|
||||
where
|
||||
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
|
||||
| otherwise = f mc w
|
||||
where
|
||||
d = dist (you w ^. crPos . _xy) (_mcPos mc)
|
||||
mid = _mcID mc
|
||||
@@ -118,11 +118,29 @@ mcPlaySound mc w = case _mcType mc of
|
||||
| d < 100 ->
|
||||
soundContinueVol
|
||||
(1 -0.01 * d)
|
||||
(MachineSound mid)
|
||||
(MachineBackgroundSound mid)
|
||||
(_mcPos mc)
|
||||
fridgeHumS
|
||||
(Just 2)
|
||||
w
|
||||
McDistributer {}
|
||||
| d < 100 ->
|
||||
soundContinueVol
|
||||
(0.5 * (1 -0.01 * d))
|
||||
(MachineBackgroundSound mid)
|
||||
(_mcPos mc)
|
||||
whirS
|
||||
(Just 2)
|
||||
w
|
||||
McProxSensor {}
|
||||
| d < 100 ->
|
||||
soundContinueVol
|
||||
(0.5 * (1 -0.01 * d))
|
||||
(MachineBackgroundSound mid)
|
||||
(_mcPos mc)
|
||||
throbC4S
|
||||
(Just 2)
|
||||
w
|
||||
_ -> w
|
||||
where
|
||||
d = max 0 (dist ( you w ^. crPos . _xy) (_mcPos mc) - 100)
|
||||
|
||||
Reference in New Issue
Block a user