123 lines
3.5 KiB
Haskell
123 lines
3.5 KiB
Haskell
{-# LANGUAGE LambdaCase #-}
|
|
module Dodge.Luse (
|
|
useL,
|
|
) where
|
|
|
|
import Dodge.Creature.Action
|
|
import Dodge.Data.World
|
|
import Dodge.Item.Weapon.TriggerType
|
|
import LensHelp
|
|
|
|
useL :: Luse -> Item -> Creature -> World -> World
|
|
useL = \case
|
|
LDoNothing -> const $ const id
|
|
LRewind -> useRewindGun
|
|
LTimePause -> hammerCheckL useStopWatch
|
|
LTimeScroll -> hammerCheckL useTimeScrollGun
|
|
LBlink -> hammerCheckL (shootL $ const blinkActionMousePos)
|
|
LUnsafeBlink -> hammerCheckL (shootL $ const unsafeBlinkAction)
|
|
LBoost -> boostSelfL 10
|
|
|
|
useStopWatch :: Item -> Creature -> World -> World
|
|
useStopWatch itm _ =
|
|
timeFlow
|
|
.~ PausedTimeFlow
|
|
{ _timeFlowCharge = itm ^?! itUse . leftConsumption . wpCharge
|
|
, _scrollItemID = _itID itm
|
|
}
|
|
|
|
useTimeScrollGun :: Item -> Creature -> World -> World
|
|
useTimeScrollGun itm _ =
|
|
timeFlow
|
|
.~ ItemScrollTimeFlow
|
|
{ _scrollSmoothing = 0
|
|
, _reverseAmount = itm ^?! itUse . leftConsumption . wpCharge
|
|
, _futureWorlds = []
|
|
, _scrollItemID = _itID itm
|
|
}
|
|
|
|
useRewindGun :: Item -> Creature -> World -> World
|
|
useRewindGun itm _ =
|
|
timeFlow
|
|
.~ RewindLeftClick
|
|
{ _reverseAmount = itm ^?! itUse . leftConsumption . wpCharge
|
|
, _scrollItemID = _itID itm
|
|
}
|
|
|
|
--useRewindGun _ _ w = case w ^. cwTime . rewindWorlds of
|
|
-- [w'] -> w & cwTime . maybeWorld .~ Just' w'
|
|
-- (w' : ws) -> w
|
|
-- & cwTime . maybeWorld
|
|
-- .~ Just' w'
|
|
-- & cwTime . rewindWorlds .~ ws
|
|
-- _ -> w
|
|
|
|
boostSelfL ::
|
|
-- | boost amount
|
|
Float ->
|
|
Item ->
|
|
Creature ->
|
|
World ->
|
|
World
|
|
boostSelfL = undefined
|
|
|
|
--boostSelfL x itm cr w = case boostPoint x cr w of
|
|
-- Left p -> crEff p (itUse . leftConsumption . arLoaded .~ 0)
|
|
-- Right p -> crEff p (itUse . leftConsumption . arLoaded -~ 1)
|
|
-- where
|
|
-- invid = _ipInvID $ _itLocation itm
|
|
-- cid = _crID cr
|
|
-- cpos = _crPos cr
|
|
-- r = _crRad cr
|
|
-- pid =
|
|
-- fromMaybe
|
|
-- (IM.newKey $ _props (_cWorld w))
|
|
-- (cr ^? crInv . ix invid . itAttachment . atInt)
|
|
-- crEff p ammoEff =
|
|
-- addBoostShockwave pid p (r *.* normalizeV (p -.- cpos)) w
|
|
-- & cWorld . creatures . ix cid
|
|
-- %~ (crPos .~ p)
|
|
-- . ( crInv . ix invid
|
|
-- %~ ammoEff
|
|
-- . (itEffect . ieCounter .~ 1)
|
|
-- . (itAttachment .~ AttachInt pid)
|
|
-- )
|
|
|
|
---- | Move a creature towards the mouse position, with shockwave
|
|
--boostPoint ::
|
|
-- -- | boost amount
|
|
-- Float ->
|
|
-- Creature ->
|
|
-- World ->
|
|
-- Either Point2 Point2
|
|
--boostPoint x cr w = case mayp2 of
|
|
-- Nothing -> Right p1
|
|
-- Just p2 -> Left $ mvPointTowardAtSpeed r cpos $ fst p2
|
|
-- where
|
|
-- cpos = _crPos cr
|
|
-- r = 1.5 * _crRad cr
|
|
-- p1 = cpos +.+ x *.* squashNormalizeV (mouseWorldPos (w ^. input) (w ^. wCam) -.- cpos)
|
|
-- mayp2 = bouncePoint (const True) 1 cpos p1 w
|
|
|
|
--addBoostShockwave ::
|
|
-- Int ->
|
|
-- Point2 ->
|
|
-- Point2 ->
|
|
-- World ->
|
|
-- World
|
|
--addBoostShockwave pjid p v w =
|
|
-- w & cWorld . lWorld . linearShockwaves
|
|
-- %~ IM.insertWith f pjid thePJ
|
|
-- where
|
|
-- thePJ =
|
|
-- LinearShockwave
|
|
-- { _lwPos = p
|
|
-- , _lwID = pjid
|
|
-- , _lwPoints = [(p, v)]
|
|
-- , _lwTimer = maxT
|
|
-- }
|
|
-- f newVal oldVal = newVal & lwPoints %~ (++ _lwPoints oldVal)
|
|
|
|
--maxT :: Int
|
|
--maxT = 20
|