Add stopWatch

This commit is contained in:
2022-12-30 12:17:27 +00:00
parent 29d6307076
commit 828c4d9c5b
11 changed files with 70 additions and 22 deletions
+8
View File
@@ -6,8 +6,16 @@ import Dodge.Data.Item
import Dodge.Item import Dodge.Item
import LensHelp 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 :: [([(ItAmount, ItemBaseType)], Item)]
itemCombinations = itemCombinations =
watchCombinations ++
[ po [CRAFT PIPE, CRAFT HARDWARE] (bangStick 1) [ po [CRAFT PIPE, CRAFT HARDWARE] (bangStick 1)
, po [HELD (BANGSTICK 1), CRAFT TIN] pistol , po [HELD (BANGSTICK 1), CRAFT TIN] pistol
, po [HELD PISTOL, CRAFT SPRING] autoPistol , po [HELD PISTOL, CRAFT SPRING] autoPistol
+4 -3
View File
@@ -214,7 +214,7 @@ inventoryX c = case c of
, makeTypeCraftNum 1 CONCUSSMODULE , makeTypeCraftNum 1 CONCUSSMODULE
, makeTypeCraftNum 1 STATICMODULE , makeTypeCraftNum 1 STATICMODULE
] ]
'L' -> [timeScrollGun] 'L' -> [scrollWatch]
'M' -> stackedInventory 'M' -> stackedInventory
'T' -> testInventory 'T' -> testInventory
_ -> [] _ -> []
@@ -246,8 +246,9 @@ stackedInventory :: [Item]
stackedInventory = stackedInventory =
[ burstRifle [ burstRifle
, pipe , pipe
, timeScrollGun , scrollWatch
, rewindGun , rewindWatch
, stopWatch
, tractorGun , tractorGun
, autoPistol , autoPistol
, pistol , pistol
+5 -3
View File
@@ -28,10 +28,8 @@ data CWorld = CWorld
} }
data TimeFlowStatus data TimeFlowStatus
= RewindingNow = DeathTime
| DeathTime
{ _deathDelay :: Int } { _deathDelay :: Int }
| RewindingLastFrame
| NormalTimeFlow | NormalTimeFlow
| ScrollTimeFlow | ScrollTimeFlow
{ _scrollSmoothing :: Int { _scrollSmoothing :: Int
@@ -43,6 +41,10 @@ data TimeFlowStatus
{ _reverseAmount :: Int { _reverseAmount :: Int
, _scrollItemLocation :: Int , _scrollItemLocation :: Int
} }
| PausedTimeFlow
{ _timeFlowCharge :: Int
, _scrollItemLocation :: Int
}
data CWGen = CWGen data CWGen = CWGen
{ _cwgParams :: GenParams { _cwgParams :: GenParams
+3 -2
View File
@@ -109,8 +109,9 @@ data EquipItemType
data LeftItemType data LeftItemType
= BOOSTER = BOOSTER
| REWINDER | STOPWATCH
| TIMESCROLLER | REWINDWATCH
| SCROLLWATCH
| BLINKER | BLINKER
| BLINKERUNSAFE | BLINKERUNSAFE
| SHRINKER | SHRINKER
+1
View File
@@ -47,6 +47,7 @@ data Euse
data Luse data Luse
= LDoNothing = LDoNothing
| LRewind | LRewind
| LTimePause
| LTimeScroll | LTimeScroll
| LShrink | LShrink
| LBlink | LBlink
+3 -2
View File
@@ -48,8 +48,9 @@ itemFromEquipType et = case et of
itemFromLeftType :: LeftItemType -> Item itemFromLeftType :: LeftItemType -> Item
itemFromLeftType lt = case lt of itemFromLeftType lt = case lt of
BOOSTER -> boosterGun BOOSTER -> boosterGun
REWINDER -> rewindGun STOPWATCH -> stopWatch
TIMESCROLLER -> timeScrollGun REWINDWATCH -> rewindWatch
SCROLLWATCH -> scrollWatch
BLINKER -> blinkGun BLINKER -> blinkGun
BLINKERUNSAFE -> unsafeBlinkGun BLINKERUNSAFE -> unsafeBlinkGun
SHRINKER -> shrinkGun SHRINKER -> shrinkGun
+23 -6
View File
@@ -14,8 +14,25 @@ import Picture
import Shape import Shape
import ShapePicture import ShapePicture
timeScrollGun :: Item stopWatch :: Item
timeScrollGun = 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 defaultLeftItem
& itUse & itUse
.~ ( defaultLeftUse .~ ( defaultLeftUse
@@ -24,15 +41,15 @@ timeScrollGun =
) )
& itInvColor .~ cyan & itInvColor .~ cyan
& itEffect . ieInv .~ ChargeIfInInventory & itEffect . ieInv .~ ChargeIfInInventory
& itType . iyBase .~ LEFT TIMESCROLLER & itType . iyBase .~ LEFT SCROLLWATCH
& itUse . leftConsumption & itUse . leftConsumption
.~ ChargeableAmmo .~ ChargeableAmmo
{ _wpMaxCharge = 100 { _wpMaxCharge = 100
, _wpCharge = 0 , _wpCharge = 0
} }
rewindGun :: Item rewindWatch :: Item
rewindGun = rewindWatch =
defaultLeftItem defaultLeftItem
& itUse & itUse
.~ ( defaultLeftUse .~ ( defaultLeftUse
@@ -41,7 +58,7 @@ rewindGun =
) )
& itInvColor .~ cyan & itInvColor .~ cyan
& itEffect . ieInv .~ ChargeIfEquipped & itEffect . ieInv .~ ChargeIfEquipped
& itType . iyBase .~ LEFT REWINDER & itType . iyBase .~ LEFT REWINDWATCH
& itUse . leftConsumption & itUse . leftConsumption
.~ ChargeableAmmo .~ ChargeableAmmo
{ _wpMaxCharge = 100 { _wpMaxCharge = 100
+10
View File
@@ -14,12 +14,21 @@ useL :: Luse -> Item -> Creature -> World -> World
useL lu = case lu of useL lu = case lu of
LDoNothing -> const $ const id LDoNothing -> const $ const id
LRewind -> useRewindGun LRewind -> useRewindGun
LTimePause -> hammerCheckL useStopWatch
LTimeScroll -> hammerCheckL useTimeScrollGun LTimeScroll -> hammerCheckL useTimeScrollGun
LShrink -> hammerCheckL useShrinkGun LShrink -> hammerCheckL useShrinkGun
LBlink -> hammerCheckL (shootL $ const blinkActionMousePos) LBlink -> hammerCheckL (shootL $ const blinkActionMousePos)
LUnsafeBlink -> hammerCheckL (shootL $ const unsafeBlinkAction) LUnsafeBlink -> hammerCheckL (shootL $ const unsafeBlinkAction)
LBoost -> boostSelfL 10 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 :: Item -> Creature -> World -> World
useTimeScrollGun itm _ w = w & cWorld . timeFlow .~ ScrollTimeFlow useTimeScrollGun itm _ w = w & cWorld . timeFlow .~ ScrollTimeFlow
{ _scrollSmoothing = 0 { _scrollSmoothing = 0
@@ -28,6 +37,7 @@ useTimeScrollGun itm _ w = w & cWorld . timeFlow .~ ScrollTimeFlow
, _scrollItemLocation = _itID itm , _scrollItemLocation = _itID itm
} }
useRewindGun :: Item -> Creature -> World -> World useRewindGun :: Item -> Creature -> World -> World
useRewindGun itm _ w = w useRewindGun itm _ w = w
& cWorld . timeFlow .~ RewindLeftClick & cWorld . timeFlow .~ RewindLeftClick
+1 -3
View File
@@ -13,13 +13,11 @@ testStringInit u =
showTimeFlow :: TimeFlowStatus -> String showTimeFlow :: TimeFlowStatus -> String
showTimeFlow tfs = case tfs of showTimeFlow tfs = case tfs of
RewindingNow -> "RewindingNow"
DeathTime i -> "DeathTime"++show i DeathTime i -> "DeathTime"++show i
RewindingLastFrame -> "RewindingLastFrame"
NormalTimeFlow -> "NormalTimeFlow" NormalTimeFlow -> "NormalTimeFlow"
ScrollTimeFlow {_reverseAmount = ra } -> "ScrollTimeFlow" ++ show ra ScrollTimeFlow {_reverseAmount = ra } -> "ScrollTimeFlow" ++ show ra
RewindLeftClick {_reverseAmount = ra } -> "RewindLeftClick" ++ show ra RewindLeftClick {_reverseAmount = ra } -> "RewindLeftClick" ++ show ra
PausedTimeFlow {_timeFlowCharge = ra } -> "PausedTimeFlow" ++ show ra
-- [ show $ u ^? uvScreenLayers . _head . scOffset -- [ show $ u ^? uvScreenLayers . _head . scOffset
-- ] -- ]
-- ++ [ shortShow $ u ^?! uvWorld . cWorld . lWorld . creatures . ix 0 . crPos -- ++ [ shortShow $ u ^?! uvWorld . cWorld . lWorld . creatures . ix 0 . crPos
+12 -1
View File
@@ -198,7 +198,17 @@ functionalUpdate' u = case u ^. uvWorld . cWorld . timeFlow of
ScrollTimeFlow smoothing _ _ _ -> over uvWorld (doTimeScroll smoothing) u ScrollTimeFlow smoothing _ _ _ -> over uvWorld (doTimeScroll smoothing) u
RewindLeftClick 0 _ -> u & uvWorld . cWorld . timeFlow .~ NormalTimeFlow RewindLeftClick 0 _ -> u & uvWorld . cWorld . timeFlow .~ NormalTimeFlow
RewindLeftClick _ _ -> over uvWorld scrollTimeBack 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 :: Int -> World -> World
doTimeScroll smoothing w = case w ^? input . mouseButtons . ix ButtonLeft of 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 _ | smoothing < 0 -> scrollTimeForward w & cWorld . timeFlow . scrollSmoothing +~ 1
_ -> w _ -> w
scrollTimeBack :: World -> World scrollTimeBack :: World -> World
scrollTimeBack w = case w ^? cWorld . pastWorlds . _head of scrollTimeBack w = case w ^? cWorld . pastWorlds . _head of
Nothing -> w Nothing -> w
-2
View File
@@ -54,7 +54,6 @@ pressedMBEffectsNoInventory pkeys w
| isDown ButtonLeft && isDown ButtonRight && inTopInv = | isDown ButtonLeft && isDown ButtonRight && inTopInv =
useItem (you w) w & input . hammers . ix DoubleMouseHam .~ HammerDown useItem (you w) w & input . hammers . ix DoubleMouseHam .~ HammerDown
| isDown ButtonLeft && inTopInv | isDown ButtonLeft && inTopInv
-- | justPressedDown ButtonLeft && inTopInv
&& w ^?! input . hammers . ix DoubleMouseHam == HammerUp = && w ^?! input . hammers . ix DoubleMouseHam == HammerUp =
useLeftItem 0 w useLeftItem 0 w
| isDown ButtonLeft && inTopInv = | isDown ButtonLeft && inTopInv =
@@ -69,7 +68,6 @@ pressedMBEffectsNoInventory pkeys w
inTopInv = case w ^. hud . hudElement of inTopInv = case w ^. hud . hudElement of
DisplayInventory NoSubInventory -> True DisplayInventory NoSubInventory -> True
_ -> False _ -> False
justPressedDown but = (pkeys ^. at but) == Just False
isDown but = but `M.member` pkeys isDown but = but `M.member` pkeys
rotation = angleBetween (_mousePos (_input w)) (_clickMousePos (_input w)) rotation = angleBetween (_mousePos (_input w)) (_clickMousePos (_input w))