Stop new old sounds from playing during rewinding
This commit is contained in:
+8
-1
@@ -69,10 +69,16 @@ updateRenderSplit w = do
|
||||
update w `par` void (doDrawing (_renderData preData) w)
|
||||
return $ update w
|
||||
|
||||
playSoundUnlessRewinding :: World -> IO (M.Map SoundOrigin Sound)
|
||||
playSoundUnlessRewinding w
|
||||
| _rewinding w = return M.empty
|
||||
| otherwise = playSoundAndUpdate (_soundData $ _preloadData w) (_playingSounds w) (_toPlaySounds w)
|
||||
|
||||
doSideEffects :: World -> IO World
|
||||
doSideEffects w = do
|
||||
let preData = _preloadData w
|
||||
newPlayingSounds <- playSoundAndUpdate (_soundData preData) (_playingSounds w) (_toPlaySounds w)
|
||||
--newPlayingSounds <- playSoundAndUpdate (_soundData preData) (_playingSounds w) (_toPlaySounds w)
|
||||
newPlayingSounds <- playSoundUnlessRewinding w
|
||||
w' <- _sideEffects w w
|
||||
endTicks <- SDL.ticks
|
||||
let lastFrameTicks = _frameTimer preData
|
||||
@@ -86,6 +92,7 @@ doSideEffects w = do
|
||||
& playingSounds .~ newPlayingSounds
|
||||
& toPlaySounds .~ M.empty
|
||||
& sideEffects .~ return
|
||||
& rewinding .~ False -- this is probably not the best place for this
|
||||
|
||||
doPreload :: IO PreloadData
|
||||
doPreload = do
|
||||
|
||||
@@ -38,4 +38,4 @@ initialWorld = defaultWorld
|
||||
}
|
||||
|
||||
testStringInit :: World -> [String]
|
||||
testStringInit _ = []
|
||||
testStringInit w = [show $ _rewinding w]
|
||||
|
||||
@@ -6,12 +6,14 @@ import Dodge.Picture.Layer
|
||||
import Dodge.Creature.Action
|
||||
import Dodge.Item.Weapon.TriggerType
|
||||
import Dodge.Default.Weapon
|
||||
import Sound.Data
|
||||
import Geometry
|
||||
import Picture
|
||||
import qualified IntMapHelp as IM
|
||||
import Shape
|
||||
import ShapePicture
|
||||
|
||||
import qualified Data.Map.Strict as M
|
||||
import Control.Lens
|
||||
|
||||
rewindGun :: Item
|
||||
@@ -29,24 +31,21 @@ rewindEffect iteff cr invid w = w & rewindWorlds %~ (take 100 . (w' : ))
|
||||
& creatures . ix (_crID cr) . crInv . ix invid . wpLoadedAmmo .~ length (_rewindWorlds w)
|
||||
where
|
||||
w' = w & rewindWorlds .~ []
|
||||
& rewinding .~ True
|
||||
|
||||
useRewindGun :: Item -> Creature -> World -> World
|
||||
useRewindGun it cr w = case _rewindWorlds w of
|
||||
(w':[]) -> w'
|
||||
& upbuts
|
||||
& rewindWorlds .~ []
|
||||
& rewinding .~ True
|
||||
& lClickHammer .~ HammerUp
|
||||
where
|
||||
upbuts = (keys .~ _keys w) . (mouseButtons .~ _mouseButtons w)
|
||||
(_:w':ws) -> w'
|
||||
(w':[]) -> rewindusing w' []
|
||||
(_:w':ws) -> rewindusing w' ws
|
||||
_ -> w
|
||||
where
|
||||
rewindusing w' ws = w'
|
||||
-- & creatures . ix (_crID cr) .~ cr
|
||||
& upbuts
|
||||
& rewindWorlds .~ ws
|
||||
& rewinding .~ True
|
||||
& lClickHammer .~ HammerUp
|
||||
where
|
||||
upbuts = (keys .~ _keys w) . (mouseButtons .~ _mouseButtons w)
|
||||
_ -> w
|
||||
& worldEvents %~ (. (worldEvents %~ (.(rewinding .~ False)))) -- fucking nesting
|
||||
upbuts = (keys .~ _keys w) . (mouseButtons .~ _mouseButtons w)
|
||||
|
||||
shrinkGun :: Item
|
||||
shrinkGun = defaultGun
|
||||
|
||||
@@ -65,13 +65,13 @@ room2 :: RandomGen g => Int -> State g (SubCompTree Room)
|
||||
room2 = lasCenSensEdge
|
||||
|
||||
startRoom :: RandomGen g => Int -> State g (SubCompTree Room)
|
||||
startRoom i = join $ takeOne
|
||||
[ chainUses <$> sequence [minigunFakeout,weaponRoom]
|
||||
, rezBoxesWp
|
||||
, rezBoxesThenWeaponRoom
|
||||
, rezBoxThenWeaponRoom
|
||||
, rezBoxesWpCrit
|
||||
, runPastStart i
|
||||
startRoom i = join $ uncurry takeOneWeighted $ unzip
|
||||
[ (,) (0.5::Float) $ chainUses <$> sequence [minigunFakeout,weaponRoom]
|
||||
, (,) 1 $ rezBoxesWp
|
||||
, (,) 1 $ rezBoxesThenWeaponRoom
|
||||
, (,) 1 $ rezBoxThenWeaponRoom
|
||||
, (,) 1 $ rezBoxesWpCrit
|
||||
, (,) 1 $ runPastStart i
|
||||
]
|
||||
|
||||
runPastStart :: RandomGen g => Int -> State g (SubCompTree Room)
|
||||
|
||||
Reference in New Issue
Block a user