53 lines
1.4 KiB
Haskell
53 lines
1.4 KiB
Haskell
module Dodge.Creature.Vocalization (
|
|
crWarningSounds,
|
|
vocalizationTest,
|
|
resetCrVocCoolDown,
|
|
) where
|
|
|
|
import Control.Lens
|
|
import Dodge.Data.World
|
|
import Dodge.SoundLogic.ExternallyGeneratedSounds
|
|
import Sound.Data
|
|
import System.Random
|
|
|
|
crVocalizationSound :: Creature -> Maybe SoundID
|
|
crVocalizationSound cr = case cr ^. crType of
|
|
Avatar{} -> Nothing
|
|
AvatarDead -> Nothing
|
|
ChaseCrit{} -> Just seagullChatterS
|
|
SwarmCrit -> Nothing
|
|
AutoCrit -> Nothing
|
|
BarrelCrit{} -> Nothing
|
|
LampCrit{} -> Nothing
|
|
|
|
crWarningSounds :: Creature -> [SoundID]
|
|
crWarningSounds cr = case cr ^. crType of
|
|
Avatar{} -> mempty
|
|
AvatarDead -> mempty
|
|
ChaseCrit{} ->
|
|
[ seagullBarkS
|
|
, seagullChatterS
|
|
, seagullChatter1S
|
|
, seagullWhistleS
|
|
, seagullWhistle1S
|
|
, seagullCryS
|
|
, seagullCry1S
|
|
, seagullCry2S
|
|
]
|
|
SwarmCrit -> mempty
|
|
AutoCrit -> mempty
|
|
BarrelCrit{} -> mempty
|
|
LampCrit{} -> mempty
|
|
|
|
vocalizationTest :: Creature -> Maybe SoundID
|
|
vocalizationTest cr = case cr ^? crVocalization . vcCoolDown of
|
|
Just 0 -> crVocalizationSound cr
|
|
_ -> Nothing
|
|
|
|
resetCrVocCoolDown :: World -> Creature -> Creature
|
|
resetCrVocCoolDown w cr = case cr ^? crVocalization . vcMaxCoolDown of
|
|
Just (i, j) -> cr & crVocalization . vcCoolDown .~ x
|
|
where
|
|
x = fst $ randomR (i, j) (_randGen w)
|
|
Nothing -> cr
|