From 5bc764655dcf7a790ba0c99e29c40ebaf62b69b2 Mon Sep 17 00:00:00 2001 From: justin Date: Thu, 29 Dec 2022 12:54:34 +0000 Subject: [PATCH] Cleanup --- src/Dodge/Combine/Module.hs | 2 +- src/Dodge/Creature.hs | 1 + src/Dodge/Data/CWorld.hs | 5 +++-- src/Dodge/Data/Input.hs | 7 +++++++ src/Dodge/Data/Item/Use.hs | 6 +++--- src/Dodge/Item/Held/Cane.hs | 6 +++--- src/Dodge/Item/Held/Rod.hs | 8 ++++---- src/Dodge/Item/Held/SprayGuns.hs | 2 +- src/Dodge/Item/Held/Utility.hs | 2 +- src/Dodge/Item/Weapon/Remote.hs | 2 +- src/Dodge/Luse.hs | 7 +++++-- src/Dodge/Reloading.hs | 14 +++++++------- src/Dodge/TestString.hs | 18 ++++++++++++++---- src/Dodge/Update.hs | 2 ++ src/Dodge/Update/Camera.hs | 2 +- 15 files changed, 54 insertions(+), 30 deletions(-) diff --git a/src/Dodge/Combine/Module.hs b/src/Dodge/Combine/Module.hs index 13ba85f8a..61414e03d 100644 --- a/src/Dodge/Combine/Module.hs +++ b/src/Dodge/Combine/Module.hs @@ -42,7 +42,7 @@ moduleModification imt = case imt of & itTargeting .~ targetRBPress & itUse . heldMods %~ ModWithDirectedTeleport -- .:~ withPosDirWallCheck directedTelPos -- for the camera: the simplest option is to remove all zoom/offset - & itUse . heldAim . aimZoom . itZoomFac .~ 1 + & itUse . heldAim . aimZoom . izFac .~ 1 & itUse . heldAim . aimRange .~ 0 -- a better option would be to involve a "scope" centered on the firing diff --git a/src/Dodge/Creature.hs b/src/Dodge/Creature.hs index a61919cc9..7202fcbf8 100644 --- a/src/Dodge/Creature.hs +++ b/src/Dodge/Creature.hs @@ -246,6 +246,7 @@ stackedInventory :: [Item] stackedInventory = [ burstRifle , pipe + , timeScrollGun , rewindGun , tractorGun , autoPistol diff --git a/src/Dodge/Data/CWorld.hs b/src/Dodge/Data/CWorld.hs index 7406ee2d6..26de1f111 100644 --- a/src/Dodge/Data/CWorld.hs +++ b/src/Dodge/Data/CWorld.hs @@ -40,8 +40,9 @@ data TimeFlowStatus , _scrollItemLocation :: Int } | RewindLeftClick - { _reverseAmount :: Int } - + { _reverseAmount :: Int + , _scrollItemLocation :: Int + } data CWGen = CWGen { _cwgParams :: GenParams diff --git a/src/Dodge/Data/Input.hs b/src/Dodge/Data/Input.hs index 7f61e1795..6118a82eb 100644 --- a/src/Dodge/Data/Input.hs +++ b/src/Dodge/Data/Input.hs @@ -15,6 +15,13 @@ data PressType = InitialPress | LongPress deriving (Eq,Show) +data MouseButtonInfo = MouseButtonInfo + { _mbHeldDown :: Bool + , _mbFlags :: [MouseButtonFlag] + } +data MouseButtonFlag + = PressedStartRewind + data Input = Input { _mousePos :: Point2 , _mouseMoving :: Bool diff --git a/src/Dodge/Data/Item/Use.hs b/src/Dodge/Data/Item/Use.hs index deebd2339..2cdef8a74 100644 --- a/src/Dodge/Data/Item/Use.hs +++ b/src/Dodge/Data/Item/Use.hs @@ -70,9 +70,9 @@ data AimStance --deriving (Eq, Show, Ord, Enum, Read) --Generic, Flat) data ItZoom = ItZoom - { _itZoomMax :: Float - , _itZoomMin :: Float - , _itZoomFac :: Float + { _izMax :: Float + , _izMin :: Float + , _izFac :: Float } --deriving (Eq, Ord, Show, Read) --Generic, Flat) diff --git a/src/Dodge/Item/Held/Cane.hs b/src/Dodge/Item/Held/Cane.hs index 6b9dfd691..976dfecfd 100644 --- a/src/Dodge/Item/Held/Cane.hs +++ b/src/Dodge/Item/Held/Cane.hs @@ -47,7 +47,7 @@ volleyGun i = & itUse . heldAim . aimWeight .~ 6 & itUse . heldAim . aimRange .~ 1 & itUse . heldAim . aimStance .~ TwoHandFlat - & itUse . heldAim . aimZoom .~ defaultItZoom{_itZoomFac = 1.5} + & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5} & itUse . heldAim . aimHandlePos .~ 5 & itUse . heldAim . aimMuzPos .~ 15 & itUse . heldConsumption . laMax .~ i @@ -82,7 +82,7 @@ rifle = & itUse . heldConsumption . laCycle .~ [loadEject 5, loadInsert 5, loadPrime 5] & itUse . heldAim . aimWeight .~ 6 & itUse . heldAim . aimRange .~ 1 - & itUse . heldAim . aimZoom .~ defaultItZoom{_itZoomFac = 2} + & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 2} & itType . iyModules . at ModHeldAttach ?~ EMPTYMODULE repeater :: Item @@ -118,7 +118,7 @@ miniGunUse i = & heldAim . aimWeight .~ 6 & heldAim . aimRange .~ 1 & heldAim . aimStance .~ TwoHandTwist - & heldAim . aimZoom .~ defaultItZoom{_itZoomFac = 1.5} + & heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5} & heldConsumption .~ defaultBulletLoadable { _laMax = 1500 diff --git a/src/Dodge/Item/Held/Rod.hs b/src/Dodge/Item/Held/Rod.hs index 9227b2f8e..3a1dc48b1 100644 --- a/src/Dodge/Item/Held/Rod.hs +++ b/src/Dodge/Item/Held/Rod.hs @@ -38,7 +38,7 @@ bangRod = & itUse . heldAim . aimWeight .~ 8 & itUse . heldAim . aimRange .~ 1 & itUse . heldAim . aimStance .~ OneHand - & itUse . heldAim . aimZoom .~ defaultItZoom{_itZoomFac = 1.5} + & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5} & itUse . heldAim . aimHandlePos .~ 5 & itUse . heldAim . aimMuzPos .~ 30 & itUse . heldConsumption . laAmmoType .~ hvBullet @@ -70,11 +70,11 @@ sniperRifle = elephantGun & itType . iyBase .~ HELD SNIPERRIFLE & itParams . gunBarrels .~ SingleBarrel 0 - & itUse . heldAim . aimZoom .~ defaultItZoom{_itZoomMax = 0.5, _itZoomMin = 0.5} + & itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 0.5, _izMin = 0.5} & itUse . heldScroll .~ HeldScrollZoom -- zoomLongGun & itScope .~ ZoomScope (V2 0 0) 0 1 0.5 False & itTargeting .~ targetLaser - & itUse . heldAim . aimZoom .~ defaultItZoom{_itZoomFac = 1} + & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1} machineGun :: Item machineGun = @@ -85,7 +85,7 @@ machineGun = & itUse . heldAim . aimWeight .~ 8 & itUse . heldAim . aimRange .~ 1 & itUse . heldAim . aimStance .~ TwoHandTwist - & itUse . heldAim . aimZoom .~ defaultItZoom{_itZoomFac = 1.5} + & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5} & itUse . heldDelay .~ VariableRate{_rateMax = 25, _rateMaxMax = 24, _rateMinMax = 7, _rateTime = 0} & itUse . heldConsumption . laMax .~ 100 & itUse . heldConsumption . laCycle .~ [loadEject 10, loadInsert 40, loadPrime 10] diff --git a/src/Dodge/Item/Held/SprayGuns.hs b/src/Dodge/Item/Held/SprayGuns.hs index 50d3f650a..a45c0e262 100644 --- a/src/Dodge/Item/Held/SprayGuns.hs +++ b/src/Dodge/Item/Held/SprayGuns.hs @@ -90,7 +90,7 @@ flameThrower = & itUse . heldDelay .~ NoDelay & itUse . heldMods .~ FlameThrowerMod & itUse . heldAim . aimWeight .~ 5 - & itUse . heldAim . aimZoom .~ defaultItZoom{_itZoomMax = 5, _itZoomMin = 1.5} + & itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 5, _izMin = 1.5} & itUse . heldAim . aimStance .~ TwoHandTwist & itUse . heldAim . aimHandlePos .~ 0 & itUse . heldAim . aimMuzPos .~ 18 diff --git a/src/Dodge/Item/Held/Utility.hs b/src/Dodge/Item/Held/Utility.hs index 2c0b871b1..cbc574aec 100644 --- a/src/Dodge/Item/Held/Utility.hs +++ b/src/Dodge/Item/Held/Utility.hs @@ -64,5 +64,5 @@ clickDetector dt = & itUse . heldUse .~ HeldDetectorEffect dt --detectorEffect dt & itUse . heldMods .~ AmmoUseCheckMod & itUse . heldAim . aimRange .~ 1 - & itUse . heldAim . aimZoom .~ defaultItZoom{_itZoomFac = 1} + & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1} & itType . iyBase .~ HELD (HELDDETECTOR dt) diff --git a/src/Dodge/Item/Weapon/Remote.hs b/src/Dodge/Item/Weapon/Remote.hs index 0598cf9f2..16c7635fe 100644 --- a/src/Dodge/Item/Weapon/Remote.hs +++ b/src/Dodge/Item/Weapon/Remote.hs @@ -16,7 +16,7 @@ setRemoteBombScope itid pj w = case w ^?! cWorld . lWorld . itemLocations . ix i . scopePos .~ (_prPos pj -.- (w ^?! cWorld . lWorld . creatures . ix cid . crPos)) & cWorld . lWorld . creatures . ix cid . crInv . ix invid . itUse . heldAim . aimZoom - .~ (defaultItZoom{_itZoomMax = 0.5, _itZoomMin = 0.5}) + .~ (defaultItZoom{_izMax = 0.5, _izMin = 0.5}) _ -> w setRemoteScope :: Int -> Point2 -> World -> World diff --git a/src/Dodge/Luse.hs b/src/Dodge/Luse.hs index 98d7aaa69..268f2d344 100644 --- a/src/Dodge/Luse.hs +++ b/src/Dodge/Luse.hs @@ -14,7 +14,7 @@ useL :: Luse -> Item -> Creature -> World -> World useL lu = case lu of LDoNothing -> const $ const id LRewind -> useRewindGun - LTimeScroll -> useTimeScrollGun + LTimeScroll -> hammerCheckL useTimeScrollGun LShrink -> hammerCheckL useShrinkGun LBlink -> hammerCheckL (shootL $ const blinkActionMousePos) LUnsafeBlink -> hammerCheckL (shootL $ const unsafeBlinkAction) @@ -30,7 +30,10 @@ useTimeScrollGun itm _ w = w & cWorld . timeFlow .~ ScrollTimeFlow useRewindGun :: Item -> Creature -> World -> World useRewindGun itm _ w = w - & cWorld . timeFlow .~ RewindLeftClick (itm ^?! itUse . leftConsumption . wpCharge) + & cWorld . timeFlow .~ RewindLeftClick + { _reverseAmount = itm ^?! itUse . leftConsumption . wpCharge + , _scrollItemLocation = _itID itm + } --useRewindGun _ _ w = case w ^. cwTime . rewindWorlds of -- [w'] -> w & cwTime . maybeWorld .~ Just' w' diff --git a/src/Dodge/Reloading.hs b/src/Dodge/Reloading.hs index ad277d129..64b796c8d 100644 --- a/src/Dodge/Reloading.hs +++ b/src/Dodge/Reloading.hs @@ -50,22 +50,22 @@ crHoldReloading cr w = tryStartLoading :: Creature -> Creature tryStartLoading cr = case cr ^? crInv . ix (crSel cr) . itUse . heldConsumption of - Just hc -> tryStartLoading' hc cr + Just hc -> startLoading hc cr Nothing -> cr -tryStartLoading' :: HeldConsumption -> Creature -> Creature -tryStartLoading' ic cr = case ic ^? laProgress . _Just . ix 0 of - Just la -> cr & startLoadAction la +startLoading :: HeldConsumption -> Creature -> Creature +startLoading ic cr = case ic ^? laProgress . _Just . ix 0 of + Just la -> cr & startLoadingStep la Nothing -> case ic ^? laCycle of Nothing -> cr Just [] -> error ("item has empty load cycle" ++ show (cr ^?! crInv . ix (crSel cr) . itType)) Just _ | _laLoaded ic >= _laMax ic -> cr Just (la : las) -> - cr & startLoadAction la + cr & startLoadingStep la & crInv . ix (crSel cr) . itUse . heldConsumption . laProgress ?~ (la : las) -startLoadAction :: LoadAction -> Creature -> Creature -startLoadAction la cr = cr & crInvSel . iselAction .~ ReloadAction (_actionTime la) la NoHammer +startLoadingStep :: LoadAction -> Creature -> Creature +startLoadingStep la cr = cr & crInvSel . iselAction .~ ReloadAction (_actionTime la) la NoHammer rotateActionProgress :: HeldConsumption -> HeldConsumption rotateActionProgress ic = case ic ^? laProgress . _Just of diff --git a/src/Dodge/TestString.hs b/src/Dodge/TestString.hs index 76c038443..9516e8dd5 100644 --- a/src/Dodge/TestString.hs +++ b/src/Dodge/TestString.hs @@ -5,11 +5,21 @@ import Dodge.Data.Universe --import Data.Maybe --import ShortShow --import qualified Data.Map.Strict as M -import qualified IntMapHelp as IM - +--import qualified IntMapHelp as IM testStringInit :: Universe -> [String] -testStringInit u = - [ show $ IM.keys $ u ^?! uvWorld . cWorld . lWorld . creatures . ix 0 . crInv ] +testStringInit u = + [ showTimeFlow $ u ^. uvWorld . cWorld . timeFlow + ] + +showTimeFlow :: TimeFlowStatus -> String +showTimeFlow tfs = case tfs of + RewindingNow -> "RewindingNow" + DeathTime i -> "DeathTime"++show i + RewindingLastFrame -> "RewindingLastFrame" + NormalTimeFlow -> "NormalTimeFlow" + ScrollTimeFlow {_reverseAmount = ra } -> "ScrollTimeFlow" ++ show ra + RewindLeftClick {_reverseAmount = ra } -> "RewindLeftClick" ++ show ra + -- [ show $ u ^? uvScreenLayers . _head . scOffset -- ] -- ++ [ shortShow $ u ^?! uvWorld . cWorld . lWorld . creatures . ix 0 . crPos diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index e4513749a..3f64a3114 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -196,6 +196,8 @@ functionalUpdate' :: Universe -> Universe functionalUpdate' u = case u ^. uvWorld . cWorld . timeFlow of NormalTimeFlow -> functionalUpdate u ScrollTimeFlow smoothing _ _ _ -> over uvWorld (doTimeScroll smoothing) u + RewindLeftClick 0 _ -> u + RewindLeftClick _ _ -> over uvWorld scrollTimeBack u & uvWorld . cWorld . timeFlow .~ NormalTimeFlow _ -> u doTimeScroll :: Int -> World -> World diff --git a/src/Dodge/Update/Camera.hs b/src/Dodge/Update/Camera.hs index 599f44bbc..3741fc4b2 100644 --- a/src/Dodge/Update/Camera.hs +++ b/src/Dodge/Update/Camera.hs @@ -205,7 +205,7 @@ notAtTerminal w = isNothing $ w ^? hud . hudElement . subInventory . termID zoomFromItem :: ItZoom -> Float -zoomFromItem ItZoom{_itZoomMax = zMax, _itZoomMin = zMin, _itZoomFac = zFac} = +zoomFromItem ItZoom{_izMax = zMax, _izMin = zMin, _izFac = zFac} = min zMax $ max zMin zFac clipZoom ::