Commit before moving button press events from events into your control

This commit is contained in:
2022-06-29 12:12:45 +01:00
parent 5501d6f9b5
commit 4b8155ae16
8 changed files with 55 additions and 28 deletions
+17 -13
View File
@@ -1,3 +1,4 @@
{-# LANGUAGE BangPatterns #-}
{- |
Module : Dodge.Update
Description : Simulation update
@@ -60,7 +61,7 @@ functionalUpdate cfig w = checkEndGame
. (worldClock +~ 1)
. updateWorldSelect
. doRewind
. (doubleMouseHammer %~ moveHammerUp)
. (hammers . each %~ moveHammerUp)
. updateDistortions
. updateCreatureSoundPositions
. ppEvents
@@ -146,9 +147,11 @@ doRewind w = case _maybeWorld w of
Nothing' -> w & timeFlow .~ NormalTimeFlow
zoneCreatures :: World -> World
zoneCreatures w = w & crZoning %~ \zn ->
foldl' (flip $ updateZoning (\cr -> IM.insert (_crID cr) cr))
(zn & znObjects .~ mempty) (_creatures w)
zoneCreatures w = w
& crZoning . znObjects .~ mempty
& crZoning %~ \zn ->
foldl' (flip $ updateZoning (\cr -> IM.insert (_crID cr) cr))
zn (_creatures w)
updateCreatureSoundPositions :: World -> World
updateCreatureSoundPositions w = M.foldlWithKey' insertSound w
@@ -286,16 +289,17 @@ ppEvents :: World -> World
ppEvents w = IM.foldl' (flip $ \pp -> _ppEvent pp pp) w $ _pressPlates w
updateSeenWalls :: World -> World
updateSeenWalls w = runIdentity $ S.fold_ f w id (S.map (_wlID . snd) $ allVisibleWalls w)
where
f w' i -- = w' & walls . ix i . wlSeen .~ True -- this is much simpler, but leaks
= w' { _walls = IM.adjust mw i $ _walls w' }
mw wl = wl {_wlSeen = True}
updateSeenWalls w = runIdentity $ S.fold_ markWallSeen w id (S.map (_wlID . snd) $ allVisibleWalls w)
-- where
-- f w' !i -- = w' & walls . ix i . wlSeen .~ True
-- = w' { _walls = IM.adjust mw i $ _walls w' }
-- mw wl = wl {_wlSeen = True}
--markWallSeen :: World -> Wall -> World
--markWallSeen w wl = w { _walls = IM.adjust mw (_wlID wl) $ _walls w }
-- where
-- mw wl' = wl' {_wlSeen = True}
markWallSeen :: World -> Int -> World
markWallSeen !w !i = w { _walls = IM.adjust markSeen i $ _walls w }
markSeen :: Wall -> Wall
markSeen wl = wl {_wlSeen = True}
checkEndGame :: World -> World
checkEndGame w = case _deathDelay w of