From d217fe73754ae5ebcb0b01097f5b7d6db864ff58 Mon Sep 17 00:00:00 2001 From: justin Date: Tue, 25 Apr 2023 15:45:45 +0100 Subject: [PATCH] Allow for time rewind with floating camera --- src/Dodge/Camera.hs | 2 +- src/Dodge/Update.hs | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Dodge/Camera.hs b/src/Dodge/Camera.hs index 55eecc1c8..631a83419 100644 --- a/src/Dodge/Camera.hs +++ b/src/Dodge/Camera.hs @@ -9,4 +9,4 @@ useNormalCamera = (uvWorld . wCam . camControl .~ CamInGame) pauseAndFloatCam :: Universe -> Universe pauseAndFloatCam = (uvWorld . wCam . camControl .~ CamFloat) - . (uvWorld . timeFlow .~ CameraScrollTimeFlow 0 0 []) + . (uvWorld . timeFlow .~ CameraScrollTimeFlow 0 200 []) diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index a5ea67406..d312ec8ed 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -143,7 +143,6 @@ updateUniverseMid u = case _uvScreenLayers u of timeFlowUpdate :: Universe -> Universe timeFlowUpdate u = case u ^. uvWorld . timeFlow of --- _ | debugcamera -> u NormalTimeFlow -> functionalUpdate u ItemScrollTimeFlow smoothing _ _ _ -> over uvWorld (doItemTimeScroll smoothing) u CameraScrollTimeFlow smoothing _ _ -> over uvWorld (doTimeScroll smoothing) u @@ -186,12 +185,14 @@ scrollTimeBack w = case w ^? pastWorlds . _head of & timeFlow . futureWorlds .:~ (w ^. cWorld . lWorld) & timeFlow . reverseAmount -~ 1 & cWorld . lWorld .~ lw - & pointituse . leftConsumption . wpCharge .~ (x -1) - & pointituse . leftHammer .~ HammerDown + & mupdateitem x _ -> w where - pointituse = pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse - i = w ^?! timeFlow . scrollItemLocation + mupdateitem x = fromMaybe id $ do + i <- w ^? timeFlow . scrollItemLocation + let pointituse = pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse + return $ (pointituse . leftConsumption . wpCharge .~ (x -1)) + . ( pointituse . leftHammer .~ HammerDown) scrollTimeForward :: World -> World scrollTimeForward w = case w ^? timeFlow . futureWorlds . _head of @@ -201,10 +202,13 @@ scrollTimeForward w = case w ^? timeFlow . futureWorlds . _head of & pastWorlds .:~ (w ^. cWorld . lWorld) & cWorld . lWorld .~ lw & timeFlow . reverseAmount .~ ramount - & pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse . leftConsumption . wpCharge .~ ramount + & mupdateitem where - i = w ^?! timeFlow . scrollItemLocation ramount = (w ^?! timeFlow . reverseAmount) + 1 + mupdateitem = fromMaybe id $ do + i <- w ^? timeFlow . scrollItemLocation + return $ pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse . leftConsumption . wpCharge .~ ramount + -- | The update step. functionalUpdate :: Universe -> Universe