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