Make creature vocalizations stop on death

This commit is contained in:
2021-11-18 02:42:12 +00:00
parent f6d5d5a201
commit 94552ff658
7 changed files with 43 additions and 13 deletions
+18
View File
@@ -6,6 +6,8 @@ module Dodge.Update
( update
) where
import Dodge.Data
import Dodge.Data.SoundOrigin
import Dodge.SoundLogic
import Dodge.Menu
import Dodge.Config.Data
import Dodge.Base
@@ -18,6 +20,7 @@ import Dodge.WorldEvent.Sound
import Dodge.Wall.Delete
import Dodge.Wall.Dust
import Dodge.RandomHelp
import Sound.Data
import Geometry
import Geometry.ConvexPoly
import Geometry.Vector3D
@@ -29,6 +32,7 @@ import Data.Function
import qualified Data.Set as S
import qualified Data.IntSet as IS
import qualified Data.IntMap.Strict as IM
import qualified Data.Map.Strict as M
import Control.Lens
import Control.Monad
import Control.Monad.State
@@ -53,6 +57,7 @@ functionalUpdate w = case _menuLayers w of
(_ : _) -> w
[] -> checkEndGame
. updateRadialDistortions
. updateCreatureSoundPositions
. ppEvents
. updateCamera
. colCrsWalls
@@ -87,6 +92,19 @@ functionalUpdate w = case _menuLayers w of
where
(x,y) = cloudZoneOfPoint $ stripZ $ _clPos cl
updateCreatureSoundPositions :: World -> World
updateCreatureSoundPositions w = M.foldrWithKey insertSound w soundsToUpdate
where
insertSound k s w' = w & toPlaySounds %~ M.insertWith (\_ -> id) k (updateSound k s)
updateSound (CrMouth cid) s = case w ^? creatures . ix cid . crPos of
Just p -> s {_soundPos = p, _soundAngDist = Just (soundAngle p w,0)}
Nothing -> s {_soundTime = Just 0}
soundsToUpdate = M.filterWithKey (\k _ -> isCrMouth k) $ _playingSounds w
isCrMouth :: SoundOrigin -> Bool
isCrMouth CrMouth{} = True
isCrMouth _ = False
updateModifications :: World -> World
updateModifications w = foldr f w (_modifications w)
where