Cleanup
This commit is contained in:
@@ -26,7 +26,6 @@ import Dodge.Data.Damage.Type
|
||||
import Dodge.Data.World
|
||||
import Dodge.DoubleTree
|
||||
import Dodge.Euse
|
||||
import Dodge.HeldUse
|
||||
import Dodge.Inventory.SelectionList
|
||||
import Dodge.Item.BackgroundEffect
|
||||
import Dodge.Item.Grammar
|
||||
@@ -218,9 +217,8 @@ doAnyEquipmentEffect loc cr = case itm ^? itLocation . ilEquipSite . _Just of
|
||||
tryUseParent :: LocationLDT ItemLink OItem -> World -> World
|
||||
tryUseParent loc w = fromMaybe w $ do
|
||||
t <- locUp loc
|
||||
let t' = t ^. locLDT
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
return $ heldEffect InitialPress t' cr w
|
||||
return $ gadgetEffect InitialPress t cr w
|
||||
|
||||
trySynthBullet :: LocationLDT ItemLink OItem -> World -> World
|
||||
trySynthBullet loc w = fromMaybe w $ do
|
||||
|
||||
@@ -21,10 +21,8 @@ module Dodge.Data (
|
||||
module Dodge.Data.MountedObject,
|
||||
module Dodge.Data.AimStance,
|
||||
module Dodge.Data.TriggerType,
|
||||
module Dodge.Data.UseDelay,
|
||||
) where
|
||||
|
||||
import Dodge.Data.UseDelay
|
||||
import Dodge.Data.TriggerType
|
||||
import Dodge.Data.AimStance
|
||||
import Dodge.Data.Config
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
|
||||
module Dodge.Data.UseDelay where
|
||||
|
||||
import Control.Lens
|
||||
|
||||
data ItemUseDelay -- should just be Delay
|
||||
= NoDelay
|
||||
| FixedRate
|
||||
{ _rateMax :: Int
|
||||
}
|
||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
makeLenses ''ItemUseDelay
|
||||
+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
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
module Dodge.Item.UseDelay
|
||||
(-- useDelay
|
||||
module Dodge.Data.UseDelay
|
||||
) where
|
||||
|
||||
import Dodge.Data.UseDelay
|
||||
import Control.Lens
|
||||
import Dodge.Data.Item
|
||||
|
||||
--useDelay :: Item -> ItemUseDelay
|
||||
--useDelay itm = case itm ^. itType of
|
||||
-- HELD hit -> heldUseDelay hit
|
||||
-- DETECTOR _ -> FixedRate 20
|
||||
-- _ -> NoDelay
|
||||
|
||||
--heldUseDelay :: HeldItemType -> ItemUseDelay
|
||||
--heldUseDelay = \case
|
||||
-- BANGSTICK _ -> FixedRate 8
|
||||
-- REWINDER -> FixedRate 20
|
||||
-- TIMESTOPPER -> FixedRate 20
|
||||
-- TIMESCROLLER -> FixedRate 20
|
||||
-- PISTOL -> FixedRate 6
|
||||
-- AUTOPISTOL -> FixedRate 8
|
||||
-- SMG -> FixedRate 8
|
||||
-- MACHINEPISTOL -> WarmUpCoolDown 50 100 200
|
||||
-- --BURSTRIFLE -> FixedRate 8 -- time last used gets updated after the last burst fire
|
||||
-- BURSTRIFLE -> NoDelay
|
||||
-- BANGCONE -> FixedRate 20
|
||||
-- BLUNDERBUSS -> FixedRate 20
|
||||
-- GRAPECANNON _ -> FixedRate 20
|
||||
-- MINIGUNX _ -> WarmUpNoDelay 100
|
||||
-- VOLLEYGUN{} -> FixedRate 15
|
||||
-- RIFLE -> FixedRate 6
|
||||
-- ALTERIFLE -> FixedRate 6
|
||||
-- AUTORIFLE -> FixedRate 6
|
||||
-- BANGROD -> FixedRate 12
|
||||
-- ELEPHANTGUN -> FixedRate 12
|
||||
-- AMR -> FixedRate 12
|
||||
-- AUTOAMR -> FixedRate 12
|
||||
-- SNIPERRIFLE -> FixedRate 12
|
||||
-- FLAMESPITTER -> FixedRate 6
|
||||
-- FLAMETHROWER -> NoDelay
|
||||
-- FLAMETORRENT -> NoDelay
|
||||
-- FLAMEWALL -> NoDelay
|
||||
-- POISONSPRAYER -> NoDelay
|
||||
-- BLOWTORCH -> NoDelay
|
||||
-- SPARKGUN -> NoDelay
|
||||
-- TESLAGUN -> NoDelay
|
||||
-- LASER -> NoDelay
|
||||
-- TRACTORGUN -> NoDelay
|
||||
-- RLAUNCHER -> FixedRate 20
|
||||
-- RLAUNCHERX{} -> FixedRate 20
|
||||
-- GLAUNCHER -> FixedRate 20
|
||||
-- SHATTERGUN -> FixedRate 20
|
||||
-- BLINKER -> FixedRate 20
|
||||
-- BLINKERUNSAFE -> FixedRate 20
|
||||
-- TORCH -> NoDelay
|
||||
-- FLATSHIELD -> NoDelay
|
||||
-- KEYCARD _ -> NoDelay
|
||||
@@ -1,7 +1,6 @@
|
||||
{-# OPTIONS_GHC -Wno-unused-imports #-}
|
||||
module Dodge.TestString where
|
||||
|
||||
import Dodge.Item.UseDelay
|
||||
import qualified SDL
|
||||
import Linear
|
||||
import Dodge.ListDisplayParams
|
||||
|
||||
Reference in New Issue
Block a user