Rewinding fixes

This commit is contained in:
2022-02-18 11:45:17 +00:00
parent e74ac9f4c4
commit 9923897fe2
4 changed files with 12 additions and 1 deletions
+1
View File
@@ -123,6 +123,7 @@ data World = World
, _distortions :: [Distortion]
, _worldBounds :: Bounds
, _gameRooms :: [GameRoom] -- consider using and IntMap
, _maybeWorld :: Maybe' World
, _rewindWorlds :: [World]
, _rewinding :: Bool
, _worldClock :: Int
+1
View File
@@ -85,6 +85,7 @@ defaultWorld = World
, _gameRooms = []
, _worldClock = 0
, _worldBounds = defaultBounds
, _maybeWorld = Nothing'
, _rewindWorlds = []
, _rewinding = False
, _lSelHammerPosition = HammerUp
+4 -1
View File
@@ -43,13 +43,16 @@ rewindEffect _ cr invid w
useRewindGun :: Item -> Creature -> World -> World
useRewindGun _ _ w = case _rewindWorlds w of
[w'] -> rewindusing w' []
(w':ws) -> rewindusing w' ws
(_:w':ws) -> rewindusing w' ws
_ -> w
where
rewindusing w' ws = w'
rewindusing w' ws = w
& maybeWorld .~ Just' ( w'
-- & creatures . ix (_crID cr) .~ cr
& upbuts
& rewindWorlds .~ ws
)
upbuts = (keys .~ _keys w) . (mouseButtons .~ _mouseButtons w)
-- needs to shift this item to the current inventory slot
+6
View File
@@ -46,6 +46,7 @@ updateUniverse u = case _menuLayers u of
functionalUpdate :: Configuration -> World -> World
functionalUpdate cfig w = checkEndGame
. (worldClock +~ 1)
. doRewind
. updateDistortions
. updateCreatureSoundPositions
. ppEvents
@@ -80,6 +81,11 @@ functionalUpdate cfig w = checkEndGame
where
(x,y) = cloudZoneOfPoint $ stripZ $ _clPos cl
doRewind :: World -> World
doRewind w = case _maybeWorld w of
Just' w' -> w'
Nothing' -> w
zoneCreatures :: World -> World
zoneCreatures w = w
& creaturesZone . znObjects .~