Cleanup
This commit is contained in:
+13
-55
@@ -4,12 +4,11 @@
|
||||
|
||||
module Dodge.HeldUse (
|
||||
gadgetEffect,
|
||||
heldEffect,
|
||||
-- heldEffect,
|
||||
mcUseHeld,
|
||||
heldEffectMuzzles,
|
||||
) where
|
||||
|
||||
import qualified Quaternion as Q
|
||||
import Color
|
||||
import Control.Applicative
|
||||
import Control.Monad
|
||||
@@ -39,6 +38,7 @@ import LensHelp
|
||||
import ListHelp
|
||||
import NewInt
|
||||
import Picture.Base
|
||||
import qualified Quaternion as Q
|
||||
import RandomHelp
|
||||
import qualified SDL
|
||||
import Sound.Data
|
||||
@@ -60,7 +60,6 @@ gadgetEffect pt loc
|
||||
|
||||
heldEffect :: PressType -> LDTree ItemLink OItem -> Creature -> World -> World
|
||||
heldEffect = hammerCheck heldEffectMuzzles
|
||||
--heldEffect = useTimeCheck . hammerCheck heldEffectMuzzles
|
||||
|
||||
hammerCheck ::
|
||||
(LDTree ItemLink OItem -> Creature -> World -> World) ->
|
||||
@@ -88,25 +87,26 @@ hammerCheck f pt it cr w = case itemTriggerType $ it ^. ldtValue . _1 of
|
||||
WarmUpCoolDown{} -> w & setwarming
|
||||
BurstTrigger is t
|
||||
| w ^. cWorld . lWorld . lClock - t > timelastused
|
||||
, pt == InitialPress ->
|
||||
, pt == InitialPress ->
|
||||
w & f it cr & cWorld . lWorld . delayedEvents .++~ map g is
|
||||
BurstTrigger{} -> w
|
||||
VolleyGunTrigger i t
|
||||
VolleyGunTrigger i t
|
||||
| w ^. cWorld . lWorld . lClock - t > timelastused
|
||||
, pt == InitialPress ->
|
||||
, pt == InitialPress ->
|
||||
let (is, gen) = getVolleyBurst i (w ^. randGen)
|
||||
in w & f it cr
|
||||
in w & f it cr
|
||||
& cWorld . lWorld . delayedEvents .++~ map g is
|
||||
& randGen .~ gen
|
||||
VolleyGunTrigger{} -> w
|
||||
HammerTrigger t
|
||||
| w ^. cWorld . lWorld . lClock - t > timelastused
|
||||
, isNothing $ lookup MakeAutoLink (it ^. ldtRight)
|
||||
, pt == InitialPress ->
|
||||
f it cr w
|
||||
, isNothing $ lookup MakeAutoLink (it ^. ldtRight)
|
||||
, pt == InitialPress ->
|
||||
f it cr w
|
||||
AutoTrigger t
|
||||
| w ^. cWorld . lWorld . lClock - t > timelastused ->
|
||||
f it cr w
|
||||
f it cr w
|
||||
NoTrigger -> f it cr w
|
||||
_ -> w
|
||||
where
|
||||
cid = _crID cr
|
||||
@@ -124,48 +124,6 @@ getVolleyBurst i g =
|
||||
let (is, g') = runState (replicateM (i -1) (state $ randomR (0, 6))) g
|
||||
in (scanl1 (+) is, g')
|
||||
|
||||
{- | Applies a world effect after an item use cooldown check.
|
||||
input buffering?
|
||||
-}
|
||||
useTimeCheck ::
|
||||
(LDTree ItemLink OItem -> Creature -> World -> World) ->
|
||||
LDTree ItemLink OItem ->
|
||||
Creature ->
|
||||
World ->
|
||||
World
|
||||
useTimeCheck f item cr w = w
|
||||
-- case useDelay $ item ^. ldtValue . _1 of
|
||||
-- FixedRate rate
|
||||
-- | w ^. cWorld . lWorld . lClock - rate > lastused -> f item cr w
|
||||
-- -- note that the time last used must be updated later in the chain!
|
||||
-- FixedRate{} -> w
|
||||
-- WarmUpNoDelay wm
|
||||
-- | _wTime (_itParams $ _ldtValue $ fmap (^. _1) item) < wm ->
|
||||
-- w & setwarming
|
||||
-- & soundContinue (CrWeaponSound cid 0) (_crPos cr) (warmupSound $ item ^. ldtValue . _1 . itType) (Just 2)
|
||||
-- & cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime +~ 1
|
||||
-- WarmUpNoDelay{} -> f item cr w & setwarming
|
||||
-- WarmUpCoolDown ws _ _
|
||||
-- | _wTime (_itParams $ _ldtValue $ fmap (^. _1) item) < ws ->
|
||||
-- w & setwarming
|
||||
-- & soundContinue (CrWeaponSound cid 0) (_crPos cr) (warmupSound $ item ^. ldtValue . _1 . itType) (Just 2)
|
||||
-- & cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime +~ 1
|
||||
-- WarmUpCoolDown _ cs _
|
||||
-- | _wTime (_itParams $ _ldtValue $ fmap (^. _1) item) < cs ->
|
||||
-- f item cr w & setwarming
|
||||
-- & cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime +~ 1
|
||||
-- WarmUpCoolDown{} -> w & setwarming
|
||||
-- NoDelay -> f item cr w
|
||||
-- where
|
||||
-- lastused = item ^. ldtValue . _1 . itTimeLastUsed
|
||||
-- cid = _crID cr
|
||||
-- setwarming =
|
||||
-- cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . isWarming
|
||||
-- %~ const True
|
||||
-- -- the following is unsafe, but if ilInvID isn't correctly set we probably
|
||||
-- -- will have problems elsewhere also
|
||||
-- itRef = item ^?! ldtValue . _1 . itLocation . ilInvID
|
||||
|
||||
heldEffectMuzzles :: LDTree ItemLink OItem -> Creature -> World -> World
|
||||
heldEffectMuzzles t cr w =
|
||||
setusetime . doHeldUseEffect t cr
|
||||
@@ -733,7 +691,7 @@ makeMuzzleFlare mz itmtree cr = case mz ^. mzFlareType of
|
||||
LasGunFlare ->
|
||||
flareCircleAt (getLaserColor $ fmap (^. _1) itmtree) 0.8 (pos `v2z` 20)
|
||||
. ( cWorld . lWorld . lights
|
||||
.:~ LSParam (pos `v2z` 10) 100 (xyzV4 $ getLaserColor $ fmap (^. _1)itmtree)
|
||||
.:~ LSParam (pos `v2z` 10) 100 (xyzV4 $ getLaserColor $ fmap (^. _1) itmtree)
|
||||
)
|
||||
TeslaGunFlare -> cWorld . lWorld . lights .:~ LSParam (pos `v2z` 10) 100 (V3 0 0 1)
|
||||
where
|
||||
@@ -910,7 +868,7 @@ creatureShootLaser itmtree cr mz w =
|
||||
dir
|
||||
(getLaserColor istree)
|
||||
where
|
||||
istree = fmap (\(x,_,_) -> x) itmtree
|
||||
istree = fmap (\(x, _, _) -> x) itmtree
|
||||
itm = itmtree ^. ldtValue
|
||||
(moff, mrot) = heldItemOrient2D' itm cr (_mzPos mz) (_mzRot mz)
|
||||
pos = _crPos cr + rotateV (_crDir cr) moff
|
||||
|
||||
Reference in New Issue
Block a user