Cleanup
This commit is contained in:
+69
-40
@@ -45,16 +45,16 @@ pauseSound w = w
|
||||
resumeSound :: Universe -> Universe
|
||||
resumeSound w = w
|
||||
|
||||
soundWithStatusVolume
|
||||
soundWithStatusVolumeGeneral
|
||||
:: Float -- ^ Volume factor, 0 - 1
|
||||
-> PlayStatus
|
||||
-> SoundOrigin -- ^ \"Creator\" of sound
|
||||
-> Point2 -- ^ Position of sound
|
||||
-> (World -> Point2) -- ^ Position of sound
|
||||
-> SoundID -- ^ ID of sound to be played
|
||||
-> Maybe Int -- ^ Frames to play sound for, Nothing for until finished
|
||||
-> World
|
||||
-> World
|
||||
soundWithStatusVolume vol status so pos sType mtime w = w & toPlaySounds %~ M.insertWith f so sound
|
||||
soundWithStatusVolumeGeneral vol status so fpos sType mtime w = w & toPlaySounds %~ M.insertWith f so sound
|
||||
where
|
||||
sound = Sound
|
||||
{ _soundChunkID = sType
|
||||
@@ -65,12 +65,40 @@ soundWithStatusVolume vol status so pos sType mtime w = w & toPlaySounds %~ M.in
|
||||
}
|
||||
, _soundChannel = Nothing
|
||||
, _soundAngDist = Just (a,floor (225 * (1 - vol)))
|
||||
, _soundPos = pos
|
||||
, _soundPos = fpos w
|
||||
, _soundVolume = soundToVol sType * vol
|
||||
, _soundVolumeFraction = vol
|
||||
}
|
||||
f _ s = s {_soundTime = mtime }
|
||||
a = soundAngle pos w
|
||||
a = soundAngle (fpos w) w
|
||||
|
||||
soundWithStatusVolume
|
||||
:: Float -- ^ Volume factor, 0 - 1
|
||||
-> PlayStatus
|
||||
-> SoundOrigin -- ^ \"Creator\" of sound
|
||||
-> Point2 -- ^ Position of sound
|
||||
-> SoundID -- ^ ID of sound to be played
|
||||
-> Maybe Int -- ^ Frames to play sound for, Nothing for until finished
|
||||
-> World
|
||||
-> World
|
||||
soundWithStatusVolume vol status so pos = soundWithStatusVolumeGeneral vol status so (const pos)
|
||||
--soundWithStatusVolume vol status so pos sType mtime w = w & toPlaySounds %~ M.insertWith f so sound
|
||||
-- where
|
||||
-- sound = Sound
|
||||
-- { _soundChunkID = sType
|
||||
-- , _soundTime = mtime
|
||||
-- , _soundStatus = SoundStatus
|
||||
-- {_playStatus = status
|
||||
-- ,_isLooping = isJust mtime
|
||||
-- }
|
||||
-- , _soundChannel = Nothing
|
||||
-- , _soundAngDist = Just (a,floor (225 * (1 - vol)))
|
||||
-- , _soundPos = pos
|
||||
-- , _soundVolume = soundToVol sType * vol
|
||||
-- , _soundVolumeFraction = vol
|
||||
-- }
|
||||
-- f _ s = s {_soundTime = mtime }
|
||||
-- a = soundAngle pos w
|
||||
|
||||
soundWithStatus
|
||||
:: PlayStatus
|
||||
@@ -117,23 +145,24 @@ soundFromGeneral
|
||||
-> Maybe Int -- ^ Frames to play sound for, Nothing for until finished
|
||||
-> World
|
||||
-> World
|
||||
soundFromGeneral so fpos sType mtime w = over toPlaySounds (M.insertWith f so sound) w
|
||||
where
|
||||
sound = Sound
|
||||
{ _soundChunkID = sType
|
||||
, _soundTime = mtime
|
||||
, _soundStatus = SoundStatus
|
||||
{ _playStatus = ToStart
|
||||
, _isLooping = isJust mtime
|
||||
}
|
||||
, _soundChannel = Nothing
|
||||
, _soundAngDist = Just (a,0)
|
||||
, _soundPos = fpos w
|
||||
, _soundVolume = soundToVol sType
|
||||
, _soundVolumeFraction = 1
|
||||
}
|
||||
f _ s = s {_soundTime = mtime }
|
||||
a = soundAngle (fpos w) w
|
||||
soundFromGeneral = soundWithStatusVolumeGeneral 1 ToStart
|
||||
--soundFromGeneral so fpos sType mtime w = w & toPlaySounds %~ M.insertWith f so sound
|
||||
-- where
|
||||
-- sound = Sound
|
||||
-- { _soundChunkID = sType
|
||||
-- , _soundTime = mtime
|
||||
-- , _soundStatus = SoundStatus
|
||||
-- { _playStatus = ToStart
|
||||
-- , _isLooping = isJust mtime
|
||||
-- }
|
||||
-- , _soundChannel = Nothing
|
||||
-- , _soundAngDist = Just (a,0)
|
||||
-- , _soundPos = fpos w
|
||||
-- , _soundVolume = soundToVol sType
|
||||
-- , _soundVolumeFraction = 1
|
||||
-- }
|
||||
-- f _ s = s {_soundTime = mtime }
|
||||
-- a = soundAngle (fpos w) w
|
||||
|
||||
{-| Calculates the angle of a sound with reference to '_cameraViewFrom'.
|
||||
Within 10 units considers the sound to be directly in front.
|
||||
@@ -153,30 +182,30 @@ soundAngle p w
|
||||
{-| Uses the first free origin from a list.
|
||||
Does nothing if all origins are already creating sounds. -}
|
||||
soundMultiFrom
|
||||
:: [SoundOrigin]
|
||||
:: [SoundOrigin]
|
||||
-> Point2 -- ^ Position
|
||||
-> SoundID -- ^ Sound ID
|
||||
-> Maybe Int -- ^ Frames to play for, Nothing for full length
|
||||
-> World
|
||||
-> World
|
||||
soundMultiFrom [] _ _ _ w = w
|
||||
soundMultiFrom [so] pos sType mtime w
|
||||
= over toPlaySounds (M.insert so sound) w
|
||||
where
|
||||
sound = Sound
|
||||
{ _soundChunkID = sType
|
||||
, _soundTime = mtime
|
||||
, _soundStatus = SoundStatus
|
||||
{ _playStatus = ToStart
|
||||
, _isLooping = isJust mtime
|
||||
}
|
||||
, _soundChannel = Nothing
|
||||
, _soundAngDist = Just (a,0)
|
||||
, _soundPos = pos
|
||||
, _soundVolume = soundToVol sType
|
||||
, _soundVolumeFraction = 1
|
||||
}
|
||||
a = soundAngle pos w
|
||||
--soundMultiFrom [so] pos sType mtime w
|
||||
-- = over toPlaySounds (M.insert so sound) w
|
||||
-- where
|
||||
-- sound = Sound
|
||||
-- { _soundChunkID = sType
|
||||
-- , _soundTime = mtime
|
||||
-- , _soundStatus = SoundStatus
|
||||
-- { _playStatus = ToStart
|
||||
-- , _isLooping = isJust mtime
|
||||
-- }
|
||||
-- , _soundChannel = Nothing
|
||||
-- , _soundAngDist = Just (a,0)
|
||||
-- , _soundPos = pos
|
||||
-- , _soundVolume = soundToVol sType
|
||||
-- , _soundVolumeFraction = 1
|
||||
-- }
|
||||
-- a = soundAngle pos w
|
||||
soundMultiFrom (so:sos) pos sType mtime w
|
||||
| so `M.member` _playingSounds w = soundMultiFrom sos pos sType mtime w
|
||||
| otherwise = over toPlaySounds (M.insert so sound) w
|
||||
|
||||
Reference in New Issue
Block a user