Rewinding fixes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -85,6 +85,7 @@ defaultWorld = World
|
||||
, _gameRooms = []
|
||||
, _worldClock = 0
|
||||
, _worldBounds = defaultBounds
|
||||
, _maybeWorld = Nothing'
|
||||
, _rewindWorlds = []
|
||||
, _rewinding = False
|
||||
, _lSelHammerPosition = HammerUp
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 .~
|
||||
|
||||
Reference in New Issue
Block a user