Add some background sounds to machines

This commit is contained in:
2025-12-26 12:30:05 +00:00
parent 2575ccc0f4
commit 337e786f33
4 changed files with 22 additions and 59 deletions
+2 -1
View File
@@ -18,7 +18,8 @@ data SoundOrigin
| CrWeaponSound Int Int | CrWeaponSound Int Int
| ItemSound Int Int | ItemSound Int Int
| CrWeaponFailSound Int | CrWeaponFailSound Int
| MachineSound Int | MachinePrimarySound Int
| MachineBackgroundSound Int
| MachineAltSound Int | MachineAltSound Int
| TerminalSound | TerminalSound
| WallSound Int | WallSound Int
+1 -1
View File
@@ -1153,7 +1153,7 @@ doGenFloat (UniRandFloat x y) g = randomR (x, y) g
mcShootLaser :: Item -> Machine -> World -> World mcShootLaser :: Item -> Machine -> World -> World
mcShootLaser _ mc = mcShootLaser _ mc =
shootLaser (MachineSound (_mcID mc)) (DamageLaser 11) 1 pos dir yellow shootLaser (MachinePrimarySound (_mcID mc)) (DamageLaser 11) 1 pos dir yellow
where where
pos = _mcPos mc +.+ 20 *.* unitVectorAtAngle dir pos = _mcPos mc +.+ 20 *.* unitVectorAtAngle dir
dir = mc ^?! mcType . _McTurret . tuDir dir = mc ^?! mcType . _McTurret . tuDir
-56
View File
@@ -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
+19 -1
View File
@@ -118,11 +118,29 @@ mcPlaySound mc w = case _mcType mc of
| d < 100 -> | d < 100 ->
soundContinueVol soundContinueVol
(1 -0.01 * d) (1 -0.01 * d)
(MachineSound mid) (MachineBackgroundSound mid)
(_mcPos mc) (_mcPos mc)
fridgeHumS fridgeHumS
(Just 2) (Just 2)
w 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 _ -> w
where where
d = max 0 (dist ( you w ^. crPos . _xy) (_mcPos mc) - 100) d = max 0 (dist ( you w ^. crPos . _xy) (_mcPos mc) - 100)