Cleanup/remove trigger types code
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
module Dodge.ChainEffect where
|
||||
import Dodge.Data.World
|
||||
|
||||
type ChainEffect =
|
||||
(Item -> Creature -> World -> World)
|
||||
-> Item
|
||||
-> Creature
|
||||
-> World
|
||||
-> World
|
||||
@@ -114,7 +114,7 @@ internalCreatureUpdate cr =
|
||||
TODO make sure this doesn't mess up any ItemPosition
|
||||
-}
|
||||
dropByState :: Creature -> World -> World
|
||||
dropByState cr w = foldr (dropItem cr) w $ case cr ^. crState . csDropsOnDeath of
|
||||
dropByState cr w = foldl' (flip (dropItem cr)) w $ case cr ^. crState . csDropsOnDeath of
|
||||
DropAll -> IM.keys $ _crInv cr
|
||||
DropSpecific xs -> xs
|
||||
DropAmount n -> take n $ evalState (shuffle $ IM.keys $ _crInv cr) (_randGen w)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
module Dodge.Debug.Terminal where
|
||||
|
||||
import Data.Foldable
|
||||
import Dodge.Item.Location.Initialize
|
||||
import Control.Applicative
|
||||
import Control.Lens
|
||||
@@ -40,7 +41,7 @@ applyTerminalCommandArguments :: String -> [String] -> Universe -> Universe
|
||||
applyTerminalCommandArguments command args u = case command of
|
||||
"IT" -> fromMaybe u $ do
|
||||
(ibt, n) <- parseItem args
|
||||
return $ u & uvWorld %~ flip (foldr ($)) (replicate n (snd . createItemYou (itemFromBase ibt)))
|
||||
return $ u & uvWorld %~ flip (foldl' (&)) (replicate n (snd . createItemYou (itemFromBase ibt)))
|
||||
"DEX" -> fromMaybe u $ do
|
||||
x <- readMaybe =<< args ^? _head
|
||||
return $ u & ypoint . crStatistics . dexterity .~ x
|
||||
|
||||
@@ -5,6 +5,7 @@ module Dodge.HeldUse (
|
||||
mcUseHeld,
|
||||
) where
|
||||
|
||||
import Dodge.ChainEffect
|
||||
import Color
|
||||
import Data.Maybe
|
||||
import Dodge.Base.Collide
|
||||
@@ -33,6 +34,14 @@ import qualified SDL
|
||||
heldEffect :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||
heldEffect = hammerCheck $ useTimeCheck heldEffectMuzzles
|
||||
|
||||
hammerCheck :: ChainEffect
|
||||
hammerCheck f it cr w = case it ^? ldtValue . itUse . heldTriggerType of
|
||||
Just HammerTrigger -> case w ^? input . mouseButtons . ix SDL.ButtonLeft of
|
||||
Just 0 -> f it cr w
|
||||
_ -> w
|
||||
_ -> f it cr w
|
||||
|
||||
|
||||
heldEffectMuzzles :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||
heldEffectMuzzles t cr w =
|
||||
uncurry (applyCME (_ldtValue t) cr) cmew
|
||||
|
||||
@@ -141,8 +141,8 @@ updateCloseObjects w =
|
||||
changeSwapSel :: Int -> World -> World
|
||||
changeSwapSel yi w
|
||||
| yi == 0 = w
|
||||
| yi > 0 = foldr ($) w $ replicate yi (changeSwapWith $ f IM.cycleLT)
|
||||
| otherwise = foldr ($) w $ replicate (negate yi) (changeSwapWith $ f IM.cycleGT)
|
||||
| yi > 0 = foldl' (&) w $ replicate yi (changeSwapWith $ f IM.cycleLT)
|
||||
| otherwise = foldl' (&) w $ replicate (negate yi) (changeSwapWith $ f IM.cycleGT)
|
||||
where
|
||||
f g i m = fst <$> g i m
|
||||
|
||||
|
||||
@@ -5,40 +5,36 @@ Weapon effects when pulling the trigger.
|
||||
-}
|
||||
module Dodge.Item.Weapon.TriggerType (
|
||||
lockInvFor,
|
||||
withFlare,
|
||||
withMuzFlare,
|
||||
withCrPos,
|
||||
withCrPosShift,
|
||||
withOldDir,
|
||||
trigDoAlso,
|
||||
withTempLight,
|
||||
withItem,
|
||||
withSoundStart,
|
||||
withSoundItemChoiceStart,
|
||||
withSoundContinue,
|
||||
withSoundForI,
|
||||
withSoundForVol,
|
||||
withSmoke,
|
||||
withThickSmokeI,
|
||||
withThinSmokeI,
|
||||
withPositionOffset,
|
||||
withPositionWallCheck,
|
||||
withPosDirWallCheck,
|
||||
-- withCrPos,
|
||||
-- withCrPosShift,
|
||||
-- withOldDir,
|
||||
-- trigDoAlso,
|
||||
-- withTempLight,
|
||||
-- withItem,
|
||||
-- withSoundStart,
|
||||
-- withSoundItemChoiceStart,
|
||||
-- withSoundContinue,
|
||||
-- withSoundForI,
|
||||
-- withSoundForVol,
|
||||
-- withSmoke,
|
||||
-- withThickSmokeI,
|
||||
-- withThinSmokeI,
|
||||
-- withPositionOffset,
|
||||
-- withPositionWallCheck,
|
||||
-- withPosDirWallCheck,
|
||||
--withWarmUp,
|
||||
hammerCheckL,
|
||||
hammerCheck,
|
||||
shootL,
|
||||
useTimeCheck,
|
||||
-- ammoCheckI,
|
||||
modClock,
|
||||
blCheck,
|
||||
repeatTransformed,
|
||||
-- modClock,
|
||||
-- blCheck,
|
||||
ChainEffect,
|
||||
) where
|
||||
|
||||
import Dodge.Data.ComposedItem
|
||||
import Dodge.Data.DoubleTree
|
||||
import Dodge.Creature.HandPos
|
||||
import Data.Foldable
|
||||
import Data.Maybe
|
||||
import Dodge.Base
|
||||
--import Dodge.Creature.Test
|
||||
@@ -50,9 +46,7 @@ import Dodge.WorldEvent
|
||||
import Geometry
|
||||
--import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
import RandomHelp
|
||||
import qualified SDL
|
||||
import Sound.Data
|
||||
|
||||
type ChainEffect =
|
||||
(LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World) ->
|
||||
@@ -66,52 +60,32 @@ lockInvFor i f it cr =
|
||||
f it cr . (cWorld . lWorld . delayedEvents .:~ (i, UnlockInv (_crID cr)))
|
||||
. lockInv (_crID cr)
|
||||
|
||||
repeatTransformed ::
|
||||
[(Item -> Item,Creature -> Creature)] ->
|
||||
ChainEffect
|
||||
repeatTransformed xs f itm cr w = foldr g w xs
|
||||
where
|
||||
g (fit,fcr) = f (over ldtValue fit itm) (fcr cr)
|
||||
|
||||
trigDoAlso ::
|
||||
(Item -> Item) ->
|
||||
(Creature -> Creature) ->
|
||||
(Item -> Creature -> World -> World) ->
|
||||
ChainEffect
|
||||
trigDoAlso fit fcr f g itm cr = g itm cr . f (fit $ itm ^. ldtValue) (fcr cr)
|
||||
|
||||
-- Note that this uses the "base" creature and item values
|
||||
--trigDoAlso ::
|
||||
-- (Item -> Creature -> World -> World) ->
|
||||
-- ChainEffect
|
||||
--trigDoAlso afterEff eff item cr = afterEff item cr . eff item cr
|
||||
|
||||
withSmoke :: Int -> Point4 -> Float -> Int -> Float -> ChainEffect
|
||||
withSmoke num col rad t alt eff item cr w =
|
||||
eff item cr $
|
||||
foldl' (flip $ smokeCloudAt col rad t alt . (+.+.+ pos) . (* 8)) w ps
|
||||
where
|
||||
dir = _crDir cr
|
||||
pos = addZ 0 $ _crPos cr +.+ (_crRad cr + 15) *.* unitVectorAtAngle dir
|
||||
ps = replicateM num randOnUnitSphere & evalState $ _randGen w
|
||||
|
||||
withThinSmokeI :: ChainEffect
|
||||
withThinSmokeI eff item cr w =
|
||||
eff item cr $
|
||||
foldl' (flip $ makeThinSmokeAt . (+.+.+ pos) . (* 8)) w ps
|
||||
where
|
||||
dir = _crDir cr
|
||||
pos = addZ 0 $ _crPos cr +.+ (_crRad cr + 0.5) *.* unitVectorAtAngle dir
|
||||
ps = replicateM 5 randOnUnitSphere & evalState $ _randGen w
|
||||
|
||||
withThickSmokeI :: ChainEffect
|
||||
withThickSmokeI eff item cr w =
|
||||
eff item cr $
|
||||
foldl' (flip $ makeThickSmokeAt . (+.+.+ pos) . (* 8)) w ps
|
||||
where
|
||||
dir = _crDir cr
|
||||
pos = addZ 0 $ _crPos cr +.+ (_crRad cr + 15) *.* unitVectorAtAngle dir
|
||||
ps = replicateM 20 randOnUnitSphere & evalState $ _randGen w
|
||||
--withSmoke :: Int -> Point4 -> Float -> Int -> Float -> ChainEffect
|
||||
--withSmoke num col rad t alt eff item cr w =
|
||||
-- eff item cr $
|
||||
-- foldl' (flip $ smokeCloudAt col rad t alt . (+.+.+ pos) . (* 8)) w ps
|
||||
-- where
|
||||
-- dir = _crDir cr
|
||||
-- pos = addZ 0 $ _crPos cr +.+ (_crRad cr + 15) *.* unitVectorAtAngle dir
|
||||
-- ps = replicateM num randOnUnitSphere & evalState $ _randGen w
|
||||
--
|
||||
--withThinSmokeI :: ChainEffect
|
||||
--withThinSmokeI eff item cr w =
|
||||
-- eff item cr $
|
||||
-- foldl' (flip $ makeThinSmokeAt . (+.+.+ pos) . (* 8)) w ps
|
||||
-- where
|
||||
-- dir = _crDir cr
|
||||
-- pos = addZ 0 $ _crPos cr +.+ (_crRad cr + 0.5) *.* unitVectorAtAngle dir
|
||||
-- ps = replicateM 5 randOnUnitSphere & evalState $ _randGen w
|
||||
--
|
||||
--withThickSmokeI :: ChainEffect
|
||||
--withThickSmokeI eff item cr w =
|
||||
-- eff item cr $
|
||||
-- foldl' (flip $ makeThickSmokeAt . (+.+.+ pos) . (* 8)) w ps
|
||||
-- where
|
||||
-- dir = _crDir cr
|
||||
-- pos = addZ 0 $ _crPos cr +.+ (_crRad cr + 15) *.* unitVectorAtAngle dir
|
||||
-- ps = replicateM 20 randOnUnitSphere & evalState $ _randGen w
|
||||
|
||||
-- TODO create a trigger that does different things on first and continued
|
||||
-- fire.
|
||||
@@ -173,73 +147,6 @@ itUseCharge x = itUse . leftConsumption . arLoaded %~ (max 0 . subtract x)
|
||||
-- repeatFire = crWeaponReady cr && _rateTime (_heldDelay (_itUse item')) == 1
|
||||
-- firstFire = crWeaponReady cr && _rateTime (_heldDelay (_itUse item')) == 0
|
||||
|
||||
withSoundItemChoiceStart ::
|
||||
(Item -> SoundID) ->
|
||||
ChainEffect
|
||||
withSoundItemChoiceStart soundf f it cr =
|
||||
soundMultiFrom
|
||||
[CrWeaponSound cid 0, CrWeaponSound cid 1, CrWeaponSound cid 2]
|
||||
(_crPos cr)
|
||||
(soundf $ _ldtValue it)
|
||||
Nothing
|
||||
. f it cr
|
||||
where
|
||||
cid = _crID cr
|
||||
|
||||
{- | Adds a sound to a creature based world effect.
|
||||
The sound is emitted from the creature's position.
|
||||
-}
|
||||
withSoundStart ::
|
||||
-- | Sound id
|
||||
SoundID ->
|
||||
ChainEffect
|
||||
withSoundStart soundid f item cr =
|
||||
soundMultiFrom [CrWeaponSound cid j | j <- [0..3]] (_crPos cr) soundid Nothing
|
||||
. f item cr
|
||||
where
|
||||
cid = _crID cr
|
||||
|
||||
{- | Adds a sound to a creature based world effect.
|
||||
The sound is emitted from the creature's position.
|
||||
-}
|
||||
withSoundContinue ::
|
||||
-- | Sound id
|
||||
SoundID ->
|
||||
ChainEffect
|
||||
withSoundContinue soundid f item cr =
|
||||
soundContinue (CrWeaponSound cid 0) (_crPos cr) soundid Nothing
|
||||
. f item cr
|
||||
where
|
||||
cid = _crID cr
|
||||
|
||||
{- | Adds a sound to a creature based world effect.
|
||||
The sound is emitted from the creature's position.
|
||||
-}
|
||||
withSoundForI ::
|
||||
-- | Sound id
|
||||
SoundID ->
|
||||
-- | Frames to play
|
||||
Int ->
|
||||
ChainEffect
|
||||
withSoundForI soundid playTime f item cr =
|
||||
soundContinue (CrWeaponSound (_crID cr) 0) (_crPos cr) soundid (Just playTime)
|
||||
. f item cr
|
||||
|
||||
{- | Adds a sound to a creature based world effect.
|
||||
The sound is emitted from the creature's position.
|
||||
-}
|
||||
withSoundForVol ::
|
||||
-- | volume
|
||||
Float ->
|
||||
-- | Sound id
|
||||
SoundID ->
|
||||
-- | Frames to play
|
||||
Int ->
|
||||
ChainEffect
|
||||
withSoundForVol vol soundid playTime f item cr =
|
||||
soundContinueVol vol (CrWeaponSound (_crID cr) 0) (_crPos cr) soundid (Just playTime)
|
||||
. f item cr
|
||||
|
||||
{- |
|
||||
Applies a world effect after an item use cooldown check.
|
||||
-}
|
||||
@@ -264,20 +171,6 @@ useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay of
|
||||
itRef = item ^?! ldtValue . itLocation . ilInvID
|
||||
userate = fromMaybe 0 $ item ^? ldtValue . itUse . heldDelay . rateMax
|
||||
|
||||
-- | Applies a world effect after a hammer position check.
|
||||
blCheck :: ChainEffect
|
||||
blCheck f it cr w = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
|
||||
Just 0 -> f it cr w
|
||||
_ -> w
|
||||
|
||||
hammerCheck :: ChainEffect
|
||||
hammerCheck f it cr w = case it ^? ldtValue . itUse . heldTriggerType of
|
||||
Just HammerTrigger -> case w ^? input . mouseButtons . ix SDL.ButtonLeft of
|
||||
Just 0 -> f it cr w
|
||||
_ -> w
|
||||
_ -> f it cr w
|
||||
|
||||
|
||||
{- | Applies a world effect after a hammer position check.
|
||||
Arbitrary inventory position.
|
||||
-}
|
||||
|
||||
Reference in New Issue
Block a user