Move towards incorporating sound into ai
This commit is contained in:
+23
-9
@@ -23,6 +23,7 @@ module Dodge.SoundLogic (
|
||||
import Dodge.Data
|
||||
import Sound.Data (SoundStatus (..))
|
||||
import Geometry.Vector
|
||||
import Dodge.SoundLogic.Synonyms
|
||||
|
||||
import Control.Lens
|
||||
import qualified Data.Map as M
|
||||
@@ -61,7 +62,8 @@ soundOnceOrigin
|
||||
:: Int -- ^ ID of the sound to be played
|
||||
-> SoundOrigin -- ^ The \"creator\" of the sound
|
||||
-> Point2 -- ^ The position of the sound in the world
|
||||
-> World -> World
|
||||
-> World
|
||||
-> World
|
||||
soundOnceOrigin sType so p w = w & sounds %~ M.insertWith (\ _ x -> x) so theSound
|
||||
where
|
||||
theSound = Sound
|
||||
@@ -70,7 +72,9 @@ soundOnceOrigin sType so p w = w & sounds %~ M.insertWith (\ _ x -> x) so theSou
|
||||
, _soundFadeTime = 0
|
||||
, _soundStatus = ToStart
|
||||
, _soundChannel = Nothing
|
||||
, _soundPos = Just (a,0)
|
||||
, _soundAngDist = Just (a,0)
|
||||
, _soundPos = p
|
||||
, _soundVolume = soundVolID sType
|
||||
}
|
||||
a = soundAngle p w
|
||||
|
||||
@@ -89,7 +93,9 @@ soundFromPos so pos sType time fadeTime w = over sounds (M.insertWith f so sound
|
||||
, _soundStatus = ToStart
|
||||
, _soundFadeTime = fadeTime
|
||||
, _soundChannel = Nothing
|
||||
, _soundPos = Just (a,0)
|
||||
, _soundAngDist = Just (a,0)
|
||||
, _soundPos = pos
|
||||
, _soundVolume = soundVolID sType
|
||||
}
|
||||
f _ s = s {_soundTime = Just time, _soundFadeTime = fadeTime}
|
||||
a = soundAngle pos w
|
||||
@@ -114,8 +120,9 @@ soundFrom
|
||||
-> Int -- ^ Sound ID
|
||||
-> Int -- ^ Frames to play
|
||||
-> Int -- ^ Fade out time (ms)
|
||||
-> World -> World
|
||||
soundFrom so sType time fadeTime = sounds %~ M.insertWith f so sound
|
||||
-> World
|
||||
-> World
|
||||
soundFrom so sType time fadeTime w = w & sounds %~ M.insertWith f so sound
|
||||
where
|
||||
sound = Sound
|
||||
{ _soundChunkID = sType
|
||||
@@ -123,7 +130,9 @@ soundFrom so sType time fadeTime = sounds %~ M.insertWith f so sound
|
||||
, _soundStatus = ToStart
|
||||
, _soundFadeTime = fadeTime
|
||||
, _soundChannel = Nothing
|
||||
, _soundPos = Nothing
|
||||
, _soundAngDist = Nothing
|
||||
, _soundPos = _cameraCenter w
|
||||
, _soundVolume = soundVolID sType
|
||||
}
|
||||
f _ s = s {_soundTime = Just time, _soundFadeTime = fadeTime}
|
||||
{-| Uses the first free origin from a list.
|
||||
@@ -147,7 +156,9 @@ soundMultiFrom (so:sos) sType time fadeTime w
|
||||
, _soundStatus = ToStart
|
||||
, _soundFadeTime = fadeTime
|
||||
, _soundChannel = Nothing
|
||||
, _soundPos = Nothing
|
||||
, _soundAngDist = Nothing
|
||||
, _soundPos = _cameraCenter w
|
||||
, _soundVolume = soundVolID sType
|
||||
}
|
||||
{-| Uses the first free origin from a list.
|
||||
Does nothing if all origins are already creating sounds. -}
|
||||
@@ -157,7 +168,8 @@ soundMultiFromPos
|
||||
-> Int -- ^ Frames to play for
|
||||
-> Int -- ^ Fade out time (ms)
|
||||
-> Point2 -- ^ Position
|
||||
-> World -> World
|
||||
-> World
|
||||
-> World
|
||||
soundMultiFromPos [] _ _ _ _ w = w
|
||||
soundMultiFromPos (so:sos) sType time fadeTime pos w
|
||||
| so `M.member` _sounds w = soundMultiFromPos sos sType time fadeTime pos w
|
||||
@@ -169,7 +181,9 @@ soundMultiFromPos (so:sos) sType time fadeTime pos w
|
||||
, _soundStatus = ToStart
|
||||
, _soundFadeTime = fadeTime
|
||||
, _soundChannel = Nothing
|
||||
, _soundPos = Just (a,0)
|
||||
, _soundAngDist = Just (a,0)
|
||||
, _soundPos = pos
|
||||
, _soundVolume = soundVolID sType
|
||||
}
|
||||
a = soundAngle pos w
|
||||
{- | Sets '_soundTime' to 0. -}
|
||||
|
||||
Reference in New Issue
Block a user