Tweak sound
This commit is contained in:
@@ -571,6 +571,7 @@ data SoundOrigin = InventorySound
|
||||
| BlockDegradeSound Int
|
||||
| CrHitSound Int
|
||||
| BarrelHiss Int
|
||||
| GlassBreakSound Int
|
||||
deriving (Eq,Ord,Show)
|
||||
|
||||
type Poly = [Point2]
|
||||
|
||||
@@ -54,7 +54,7 @@ withWarmUp t f cid w
|
||||
$ over (pointerToItem . wpLoadedAmmo) (\ammo -> ammo-1)
|
||||
$ set (pointerToItem . wpFireState) 2
|
||||
$ f cid
|
||||
$ continueSoundFrom (CrWeaponSound cid) 28 2 0
|
||||
$ soundFrom (CrWeaponSound cid) 28 2 0
|
||||
w
|
||||
where cr = _creatures w IM.! cid
|
||||
itRef = _crInvSel cr
|
||||
|
||||
+21
-9
@@ -15,29 +15,40 @@ 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
|
||||
--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}
|
||||
|
||||
soundOnceOrigin :: Int -> SoundOrigin -> World -> World
|
||||
soundOnceOrigin sType so = over sounds (M.insertWith (flip const) so sound)
|
||||
where
|
||||
sound = Sound
|
||||
{ _soundType = sType
|
||||
, _soundTime = time
|
||||
, _soundFadeTime = fadeTime
|
||||
, _soundTime = Nothing
|
||||
, _soundFadeTime = 0
|
||||
, _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
|
||||
, _soundTime = Just time
|
||||
, _soundFadeTime = fadeTime
|
||||
, _soundChannel = Nothing
|
||||
, _soundPos = Nothing
|
||||
}
|
||||
f _ s = s {_soundTime = time, _soundFadeTime = fadeTime}
|
||||
f _ s = s {_soundTime = Just time, _soundFadeTime = fadeTime}
|
||||
|
||||
soundMultiFrom :: [SoundOrigin] -> Int -> Int -> Int -> World -> World
|
||||
soundMultiFrom [] _ _ _ w = w
|
||||
@@ -45,14 +56,15 @@ 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
|
||||
, _soundTime = Nothing
|
||||
, _soundFadeTime = fadeTime
|
||||
, _soundChannel = Nothing
|
||||
, _soundPos = Nothing
|
||||
}
|
||||
|
||||
|
||||
stopSoundFrom :: SoundOrigin -> World -> World
|
||||
stopSoundFrom so = over (sounds . ix so . soundTime) (min 0)
|
||||
stopSoundFrom so = over (sounds . ix so . soundTime) (fmap $ min 0)
|
||||
|
||||
-- idea: pass the id of the sound to the world and send it to some queue for
|
||||
-- playback
|
||||
|
||||
@@ -8,11 +8,11 @@ import System.Random
|
||||
import Control.Lens
|
||||
|
||||
mkSoundBreakGlass :: World -> World
|
||||
mkSoundBreakGlass w = soundOnce soundid $ set randGen g w
|
||||
mkSoundBreakGlass w = soundOnceOrigin soundid (GlassBreakSound 0) $ set randGen g w
|
||||
where
|
||||
(soundid,g) = _randGen w & randomR (37,40)
|
||||
|
||||
mkSoundSplinterGlass :: World -> World
|
||||
mkSoundSplinterGlass w = soundOnce soundid $ set randGen g w
|
||||
mkSoundSplinterGlass w = soundOnceOrigin soundid (GlassBreakSound 1) $ set randGen g w
|
||||
where
|
||||
(soundid,g) = _randGen w & randomR (33,36)
|
||||
|
||||
Reference in New Issue
Block a user