Remove loop dependency on loading dodge sounds

This commit is contained in:
2021-03-27 13:42:14 +01:00
parent 2897c65e9e
commit 2011728de5
10 changed files with 171 additions and 153 deletions
+20 -24
View File
@@ -1,12 +1,7 @@
module Dodge.SoundLogic where
-- imports {{{
import Dodge.Data
import Control.Lens
import qualified Data.Map as M
-- }}}
--
-- PLACEHOLDERS:
haltSound :: World -> World
haltSound w = w
@@ -21,26 +16,28 @@ 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}
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}
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
@@ -57,7 +54,6 @@ soundMultiFrom (so:sos) sType time fadeTime w
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