diff --git a/src/Dodge/Combine/Combinations.hs b/src/Dodge/Combine/Combinations.hs index eff4e4490..e09b7dea8 100644 --- a/src/Dodge/Combine/Combinations.hs +++ b/src/Dodge/Combine/Combinations.hs @@ -6,8 +6,16 @@ import Dodge.Data.Item import Dodge.Item import LensHelp +watchCombinations :: [([(ItAmount, ItemBaseType)], Item)] +watchCombinations = + [ po [LEFT STOPWATCH, LEFT REWINDWATCH] scrollWatch] + where + po xs it = (map o xs, it) + o = (1,) + itemCombinations :: [([(ItAmount, ItemBaseType)], Item)] itemCombinations = + watchCombinations ++ [ po [CRAFT PIPE, CRAFT HARDWARE] (bangStick 1) , po [HELD (BANGSTICK 1), CRAFT TIN] pistol , po [HELD PISTOL, CRAFT SPRING] autoPistol diff --git a/src/Dodge/Creature.hs b/src/Dodge/Creature.hs index 7202fcbf8..50572f762 100644 --- a/src/Dodge/Creature.hs +++ b/src/Dodge/Creature.hs @@ -214,7 +214,7 @@ inventoryX c = case c of , makeTypeCraftNum 1 CONCUSSMODULE , makeTypeCraftNum 1 STATICMODULE ] - 'L' -> [timeScrollGun] + 'L' -> [scrollWatch] 'M' -> stackedInventory 'T' -> testInventory _ -> [] @@ -246,8 +246,9 @@ stackedInventory :: [Item] stackedInventory = [ burstRifle , pipe - , timeScrollGun - , rewindGun + , scrollWatch + , rewindWatch + , stopWatch , tractorGun , autoPistol , pistol diff --git a/src/Dodge/Data/CWorld.hs b/src/Dodge/Data/CWorld.hs index 26de1f111..aaef8f68e 100644 --- a/src/Dodge/Data/CWorld.hs +++ b/src/Dodge/Data/CWorld.hs @@ -28,10 +28,8 @@ data CWorld = CWorld } data TimeFlowStatus - = RewindingNow - | DeathTime + = DeathTime { _deathDelay :: Int } - | RewindingLastFrame | NormalTimeFlow | ScrollTimeFlow { _scrollSmoothing :: Int @@ -43,6 +41,10 @@ data TimeFlowStatus { _reverseAmount :: Int , _scrollItemLocation :: Int } + | PausedTimeFlow + { _timeFlowCharge :: Int + , _scrollItemLocation :: Int + } data CWGen = CWGen { _cwgParams :: GenParams diff --git a/src/Dodge/Data/Item/Combine.hs b/src/Dodge/Data/Item/Combine.hs index cdf0024a1..259f2e1e4 100644 --- a/src/Dodge/Data/Item/Combine.hs +++ b/src/Dodge/Data/Item/Combine.hs @@ -109,8 +109,9 @@ data EquipItemType data LeftItemType = BOOSTER - | REWINDER - | TIMESCROLLER + | STOPWATCH + | REWINDWATCH + | SCROLLWATCH | BLINKER | BLINKERUNSAFE | SHRINKER diff --git a/src/Dodge/Data/Item/HeldUse.hs b/src/Dodge/Data/Item/HeldUse.hs index 98c93804c..19c86ca4b 100644 --- a/src/Dodge/Data/Item/HeldUse.hs +++ b/src/Dodge/Data/Item/HeldUse.hs @@ -47,6 +47,7 @@ data Euse data Luse = LDoNothing | LRewind + | LTimePause | LTimeScroll | LShrink | LBlink diff --git a/src/Dodge/Item.hs b/src/Dodge/Item.hs index 2e2391a26..2c1a4a362 100644 --- a/src/Dodge/Item.hs +++ b/src/Dodge/Item.hs @@ -48,8 +48,9 @@ itemFromEquipType et = case et of itemFromLeftType :: LeftItemType -> Item itemFromLeftType lt = case lt of BOOSTER -> boosterGun - REWINDER -> rewindGun - TIMESCROLLER -> timeScrollGun + STOPWATCH -> stopWatch + REWINDWATCH -> rewindWatch + SCROLLWATCH -> scrollWatch BLINKER -> blinkGun BLINKERUNSAFE -> unsafeBlinkGun SHRINKER -> shrinkGun diff --git a/src/Dodge/Item/Weapon/Utility.hs b/src/Dodge/Item/Weapon/Utility.hs index 445883664..cb8689fc1 100644 --- a/src/Dodge/Item/Weapon/Utility.hs +++ b/src/Dodge/Item/Weapon/Utility.hs @@ -14,8 +14,25 @@ import Picture import Shape import ShapePicture -timeScrollGun :: Item -timeScrollGun = +stopWatch :: Item +stopWatch = + defaultLeftItem + & itUse + .~ ( defaultLeftUse + & leftUse .~ LTimePause + & equipEffect . eeSite .~ GoesOnWrist + ) + & itInvColor .~ cyan + & itEffect . ieInv .~ ChargeIfInInventory + & itType . iyBase .~ LEFT STOPWATCH + & itUse . leftConsumption + .~ ChargeableAmmo + { _wpMaxCharge = 100 + , _wpCharge = 0 + } + +scrollWatch :: Item +scrollWatch = defaultLeftItem & itUse .~ ( defaultLeftUse @@ -24,15 +41,15 @@ timeScrollGun = ) & itInvColor .~ cyan & itEffect . ieInv .~ ChargeIfInInventory - & itType . iyBase .~ LEFT TIMESCROLLER + & itType . iyBase .~ LEFT SCROLLWATCH & itUse . leftConsumption .~ ChargeableAmmo { _wpMaxCharge = 100 , _wpCharge = 0 } -rewindGun :: Item -rewindGun = +rewindWatch :: Item +rewindWatch = defaultLeftItem & itUse .~ ( defaultLeftUse @@ -41,7 +58,7 @@ rewindGun = ) & itInvColor .~ cyan & itEffect . ieInv .~ ChargeIfEquipped - & itType . iyBase .~ LEFT REWINDER + & itType . iyBase .~ LEFT REWINDWATCH & itUse . leftConsumption .~ ChargeableAmmo { _wpMaxCharge = 100 diff --git a/src/Dodge/Luse.hs b/src/Dodge/Luse.hs index 268f2d344..0482454cc 100644 --- a/src/Dodge/Luse.hs +++ b/src/Dodge/Luse.hs @@ -14,12 +14,21 @@ useL :: Luse -> Item -> Creature -> World -> World useL lu = case lu of LDoNothing -> const $ const id LRewind -> useRewindGun + LTimePause -> hammerCheckL useStopWatch LTimeScroll -> hammerCheckL useTimeScrollGun LShrink -> hammerCheckL useShrinkGun LBlink -> hammerCheckL (shootL $ const blinkActionMousePos) LUnsafeBlink -> hammerCheckL (shootL $ const unsafeBlinkAction) LBoost -> boostSelfL 10 +useStopWatch :: Item -> Creature -> World -> World +useStopWatch itm _ w = w + & cWorld . timeFlow .~ PausedTimeFlow + { _timeFlowCharge = itm ^?! itUse . leftConsumption . wpCharge + , _scrollItemLocation = _itID itm + } + + useTimeScrollGun :: Item -> Creature -> World -> World useTimeScrollGun itm _ w = w & cWorld . timeFlow .~ ScrollTimeFlow { _scrollSmoothing = 0 @@ -28,6 +37,7 @@ useTimeScrollGun itm _ w = w & cWorld . timeFlow .~ ScrollTimeFlow , _scrollItemLocation = _itID itm } + useRewindGun :: Item -> Creature -> World -> World useRewindGun itm _ w = w & cWorld . timeFlow .~ RewindLeftClick diff --git a/src/Dodge/TestString.hs b/src/Dodge/TestString.hs index 9516e8dd5..3ea1d30e1 100644 --- a/src/Dodge/TestString.hs +++ b/src/Dodge/TestString.hs @@ -13,13 +13,11 @@ testStringInit u = 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 - + PausedTimeFlow {_timeFlowCharge = ra } -> "PausedTimeFlow" ++ 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 8760313c9..3d25aee13 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -198,7 +198,17 @@ functionalUpdate' u = case u ^. uvWorld . cWorld . timeFlow of ScrollTimeFlow smoothing _ _ _ -> over uvWorld (doTimeScroll smoothing) u RewindLeftClick 0 _ -> u & uvWorld . cWorld . timeFlow .~ NormalTimeFlow RewindLeftClick _ _ -> over uvWorld scrollTimeBack u -- & uvWorld . cWorld . timeFlow .~ NormalTimeFlow - _ -> u + DeathTime {} -> u + PausedTimeFlow _ itmloc -> over uvWorld (pauseTime itmloc) u + +pauseTime :: Int -> World -> World +pauseTime itmloc w + | justPressedButtonLeft || outofcharge = w & cWorld . timeFlow .~ NormalTimeFlow + | otherwise = w & pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix itmloc) . itUse . leftConsumption . wpCharge -~ 1 + where + justPressedButtonLeft = w ^? input . mouseButtons . ix ButtonLeft == Just False + outofcharge = maybe True (== 0) charge + charge = w ^? pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix itmloc) . itUse . leftConsumption . wpCharge doTimeScroll :: Int -> World -> World doTimeScroll smoothing w = case w ^? input . mouseButtons . ix ButtonLeft of @@ -215,6 +225,7 @@ doTimeScroll' smoothing w = case w ^. input . scrollAmount of _ | smoothing < 0 -> scrollTimeForward w & cWorld . timeFlow . scrollSmoothing +~ 1 _ -> w + scrollTimeBack :: World -> World scrollTimeBack w = case w ^? cWorld . pastWorlds . _head of Nothing -> w diff --git a/src/Dodge/Update/UsingInput.hs b/src/Dodge/Update/UsingInput.hs index f671b0e73..ade7e9442 100644 --- a/src/Dodge/Update/UsingInput.hs +++ b/src/Dodge/Update/UsingInput.hs @@ -54,7 +54,6 @@ pressedMBEffectsNoInventory pkeys w | isDown ButtonLeft && isDown ButtonRight && inTopInv = useItem (you w) w & input . hammers . ix DoubleMouseHam .~ HammerDown | isDown ButtonLeft && inTopInv - -- | justPressedDown ButtonLeft && inTopInv && w ^?! input . hammers . ix DoubleMouseHam == HammerUp = useLeftItem 0 w | isDown ButtonLeft && inTopInv = @@ -69,7 +68,6 @@ pressedMBEffectsNoInventory pkeys w inTopInv = case w ^. hud . hudElement of DisplayInventory NoSubInventory -> True _ -> False - justPressedDown but = (pkeys ^. at but) == Just False isDown but = but `M.member` pkeys rotation = angleBetween (_mousePos (_input w)) (_clickMousePos (_input w))