Simplify vocalization

This commit is contained in:
2026-04-01 20:30:31 +01:00
parent b77170c4bc
commit 735cc8d92d
11 changed files with 144 additions and 142 deletions
+5 -11
View File
@@ -3,7 +3,7 @@
module Dodge.Creature.Vocalization (
crWarningSounds,
crDeathSounds,
vocalizationTest,
crVocalizationSound,
resetCrVocCoolDown,
) where
@@ -59,15 +59,9 @@ defaultDeathSounds = \case
PlainDeath -> mempty
GibsDeath -> [gut1S, gut2S, gut3S, gut4S, gut5S, gut6S]
vocalizationTest :: Creature -> Maybe SoundID
vocalizationTest cr = case cr ^? crVocalization . vcCoolDown of
Just 0 -> crVocalizationSound cr
_ -> Nothing
crVocalResetTime :: Creature -> StdGen -> Int
crVocalResetTime _ = fst . randomR (50,100)
-- this should update the randgen as well
resetCrVocCoolDown :: World -> Creature -> Creature
resetCrVocCoolDown w cr = case cr ^? crVocalization . vcMaxCoolDown of
Just (i, j) -> cr & crVocalization . vcCoolDown .~ x
& crVocalization . vcTimer .~ 0
where
x = fst $ randomR (i, j) (_randGen w)
Nothing -> cr
resetCrVocCoolDown w cr = cr & crVocalization .~ VocTimer 0 (crVocalResetTime cr (w ^. randGen))