83 lines
2.3 KiB
Haskell
83 lines
2.3 KiB
Haskell
module Dodge.SoundLogic where
|
|
import Dodge.Data
|
|
import Control.Lens
|
|
import qualified Data.Map as M
|
|
|
|
haltSound :: World -> World
|
|
haltSound w = w
|
|
|
|
pauseSound :: World -> World
|
|
pauseSound w = w
|
|
|
|
resumeSound :: World -> World
|
|
resumeSound w = w
|
|
|
|
soundOnce :: Int -> World -> World
|
|
soundOnce i = over soundQueue ((:) i)
|
|
|
|
continueSoundFrom :: SoundOrigin -> Int -> Int -> Int -> World -> World
|
|
continueSoundFrom so sType time fadeTime w = over sounds (M.insertWith f so sound) w
|
|
where
|
|
sound = Sound
|
|
{ _soundType = sType
|
|
, _soundTime = time
|
|
, _soundFadeTime = fadeTime
|
|
, _soundChannel = Nothing
|
|
, _soundPos = Nothing
|
|
}
|
|
f _ s = s {_soundTime = time, _soundFadeTime = fadeTime}
|
|
|
|
soundFrom :: SoundOrigin -> Int -> Int -> Int -> World -> World
|
|
soundFrom so sType time fadeTime w = over sounds (M.insertWith f so sound) w
|
|
where
|
|
sound = Sound
|
|
{ _soundType = sType
|
|
, _soundTime = time
|
|
, _soundFadeTime = fadeTime
|
|
, _soundChannel = Nothing
|
|
, _soundPos = Nothing
|
|
}
|
|
f _ s = s {_soundTime = time, _soundFadeTime = fadeTime}
|
|
|
|
soundMultiFrom :: [SoundOrigin] -> Int -> Int -> Int -> World -> World
|
|
soundMultiFrom [] _ _ _ w = w
|
|
soundMultiFrom (so:sos) sType time fadeTime w
|
|
| so `M.member` _sounds w = soundMultiFrom sos sType time fadeTime w
|
|
| otherwise = over sounds (M.insert so sound) w
|
|
where sound = Sound { _soundType = sType
|
|
, _soundTime = time
|
|
, _soundFadeTime = fadeTime
|
|
, _soundChannel = Nothing
|
|
, _soundPos = Nothing
|
|
}
|
|
|
|
stopSoundFrom :: SoundOrigin -> World -> World
|
|
stopSoundFrom so = over (sounds . ix so . soundTime) (min 0)
|
|
|
|
-- idea: pass the id of the sound to the world and send it to some queue for
|
|
-- playback
|
|
|
|
reloadSound,putDownSound,pickUpSound,fireSound,grenadeBang,healSound,teleSound,twoStepSlowSound :: Int
|
|
clickSound = 1
|
|
reloadSound = 2
|
|
pickUpSound = 4
|
|
putDownSound = 5
|
|
fireSound = 6
|
|
grenadeBang = 7
|
|
tapQuiet = 8
|
|
twoStepSound = 9
|
|
healSound = 10
|
|
doorSound = 11
|
|
twoStepSlowSound = 12
|
|
knifeSound = 13
|
|
buzzSound = 14
|
|
hitSound = 15
|
|
autoGunSound = 16
|
|
shotgunSound = 17
|
|
teleSound = 18
|
|
longGunSound = 19
|
|
launcherSound = 20
|
|
smokeTrailSound = 21
|
|
foot1Sound = 22
|
|
foot2Sound = 23
|