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 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
+4 -3
View File
@@ -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
+5 -3
View File
@@ -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
+3 -2
View File
@@ -109,8 +109,9 @@ data EquipItemType
data LeftItemType
= BOOSTER
| REWINDER
| TIMESCROLLER
| STOPWATCH
| REWINDWATCH
| SCROLLWATCH
| BLINKER
| BLINKERUNSAFE
| SHRINKER
+1
View File
@@ -47,6 +47,7 @@ data Euse
data Luse
= LDoNothing
| LRewind
| LTimePause
| LTimeScroll
| LShrink
| LBlink
+3 -2
View File
@@ -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
+23 -6
View File
@@ -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
+10
View File
@@ -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
+1 -3
View File
@@ -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
+12 -1
View File
@@ -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
-2
View File
@@ -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))