Refactor sound
This commit is contained in:
@@ -23,6 +23,7 @@ import Sound.Data
|
||||
import Geometry.Data
|
||||
import Geometry.Vector
|
||||
import Dodge.SoundLogic.Synonyms
|
||||
import Dodge.SoundLogic.LoadSound
|
||||
|
||||
import Control.Lens
|
||||
import qualified Data.Map as M
|
||||
@@ -44,7 +45,7 @@ resumeSound w = w
|
||||
For each origin only one sound will play at a time.
|
||||
-}
|
||||
soundOnceOrigin
|
||||
:: Int -- ^ ID of the sound to be played
|
||||
:: SoundID -- ^ ID of the sound to be played
|
||||
-> SoundOrigin -- ^ The \"creator\" of the sound
|
||||
-> Point2 -- ^ The position of the sound in the world
|
||||
-> World
|
||||
@@ -58,14 +59,14 @@ soundOnceOrigin sType so p w = w & sounds %~ M.insertWith (\ _ x -> x) so theSou
|
||||
, _soundChannel = Nothing
|
||||
, _soundAngDist = Just (a,0)
|
||||
, _soundPos = p
|
||||
, _soundVolume = soundVolID sType
|
||||
, _soundVolume = soundToVol sType
|
||||
}
|
||||
a = soundAngle p w
|
||||
|
||||
soundFrom
|
||||
:: SoundOrigin -- ^ \"Creator\" of sound
|
||||
-> Point2 -- ^ Position of sound
|
||||
-> Int -- ^ ID of sound to be played
|
||||
-> SoundID -- ^ ID of sound to be played
|
||||
-> Maybe Int -- ^ Frames to play sound for, Nothing for until finished
|
||||
-> World
|
||||
-> World
|
||||
@@ -78,7 +79,7 @@ soundFrom so pos sType mtime w = over sounds (M.insertWith f so sound) w
|
||||
, _soundChannel = Nothing
|
||||
, _soundAngDist = Just (a,0)
|
||||
, _soundPos = pos
|
||||
, _soundVolume = soundVolID sType
|
||||
, _soundVolume = soundToVol sType
|
||||
}
|
||||
f _ s = s {_soundTime = mtime }
|
||||
a = soundAngle pos w
|
||||
@@ -86,7 +87,7 @@ soundFrom so pos sType mtime w = over sounds (M.insertWith f so sound) w
|
||||
soundFromGeneral
|
||||
:: SoundOrigin -- ^ \"Creator\" of sound
|
||||
-> (World -> Point2) -- ^ Position of sound
|
||||
-> Int -- ^ ID of sound to be played
|
||||
-> SoundID -- ^ ID of sound to be played
|
||||
-> Maybe Int -- ^ Frames to play sound for, Nothing for until finished
|
||||
-> World
|
||||
-> World
|
||||
@@ -99,7 +100,7 @@ soundFromGeneral so fpos sType mtime w = over sounds (M.insertWith f so sound) w
|
||||
, _soundChannel = Nothing
|
||||
, _soundAngDist = Just (a,0)
|
||||
, _soundPos = fpos w
|
||||
, _soundVolume = soundVolID sType
|
||||
, _soundVolume = soundToVol sType
|
||||
}
|
||||
f _ s = s {_soundTime = mtime }
|
||||
a = soundAngle (fpos w) w
|
||||
@@ -124,7 +125,7 @@ Does nothing if all origins are already creating sounds. -}
|
||||
soundMultiFrom
|
||||
:: [SoundOrigin]
|
||||
-> Point2 -- ^ Position
|
||||
-> Int -- ^ Sound ID
|
||||
-> SoundID -- ^ Sound ID
|
||||
-> Maybe Int -- ^ Frames to play for, Nothing for full length
|
||||
-> World
|
||||
-> World
|
||||
@@ -140,7 +141,7 @@ soundMultiFrom (so:sos) pos sType mtime w
|
||||
, _soundChannel = Nothing
|
||||
, _soundAngDist = Just (a,0)
|
||||
, _soundPos = pos
|
||||
, _soundVolume = soundVolID sType
|
||||
, _soundVolume = soundToVol sType
|
||||
}
|
||||
a = soundAngle pos w
|
||||
{- | Sets '_soundTime' to 0. -}
|
||||
|
||||
Reference in New Issue
Block a user