Add clicker items that use other items with a one frame delay
This commit is contained in:
@@ -9,6 +9,8 @@ import Control.Lens
|
|||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
import SDL (MouseButton, Scancode)
|
import SDL (MouseButton, Scancode)
|
||||||
|
import Data.Aeson
|
||||||
|
import Data.Aeson.TH
|
||||||
|
|
||||||
data PressType
|
data PressType
|
||||||
= InitialPress
|
= InitialPress
|
||||||
@@ -69,3 +71,4 @@ data TermSignal
|
|||||||
|
|
||||||
makeLenses ''Input
|
makeLenses ''Input
|
||||||
makeLenses ''MouseContext
|
makeLenses ''MouseContext
|
||||||
|
deriveJSON defaultOptions ''PressType
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ data ItemType
|
|||||||
| ITEMSCAN
|
| ITEMSCAN
|
||||||
| MAPPER
|
| MAPPER
|
||||||
| DROPPER InventoryPathing
|
| DROPPER InventoryPathing
|
||||||
|
| CLICKER InventoryPathing
|
||||||
| INTROSCAN {_ibtIntroScanType :: IntroScanType}
|
| INTROSCAN {_ibtIntroScanType :: IntroScanType}
|
||||||
| DETECTOR {_ibtDetector :: Detector}
|
| DETECTOR {_ibtDetector :: Detector}
|
||||||
| ARHUD
|
| ARHUD
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
module Dodge.Data.WorldEffect where
|
module Dodge.Data.WorldEffect where
|
||||||
|
|
||||||
|
import Dodge.Data.Input
|
||||||
import Dodge.Data.LightSource
|
import Dodge.Data.LightSource
|
||||||
import Dodge.Data.ComposedItem
|
import Dodge.Data.ComposedItem
|
||||||
import Dodge.Data.DoubleTree
|
import Dodge.Data.DoubleTree
|
||||||
@@ -32,6 +33,7 @@ data WdWd
|
|||||||
| WdWdNegateTrig Int
|
| WdWdNegateTrig Int
|
||||||
| WdWdFromItCrixWdWd (LabelDoubleTree ComposeLinkType Item) Int ItCrWdWd
|
| WdWdFromItCrixWdWd (LabelDoubleTree ComposeLinkType Item) Int ItCrWdWd
|
||||||
| MakeTempLight LSParam Int
|
| MakeTempLight LSParam Int
|
||||||
|
| UseInvItem Int PressType
|
||||||
--deriving (Eq, Show, Read) --, Generic)
|
--deriving (Eq, Show, Read) --, Generic)
|
||||||
--h--deriving (Eq, Show, Read) --Generic, Flat)
|
--h--deriving (Eq, Show, Read) --Generic, Flat)
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ gadgetEffect pt loc
|
|||||||
| DROPPER x <- loc ^. locLDT . ldtValue . _1 . itType
|
| DROPPER x <- loc ^. locLDT . ldtValue . _1 . itType
|
||||||
, Just i <- loc ^? locLDT . ldtValue . _1 . itUse . uInt
|
, Just i <- loc ^? locLDT . ldtValue . _1 . itUse . uInt
|
||||||
, pt == InitialPress = dropInventoryPath i x loc
|
, pt == InitialPress = dropInventoryPath i x loc
|
||||||
|
| CLICKER x <- loc ^. locLDT . ldtValue . _1 . itType
|
||||||
|
, Just i <- loc ^? locLDT . ldtValue . _1 . itUse . uInt
|
||||||
|
= useInventoryPath pt i x loc
|
||||||
| otherwise = const id
|
| otherwise = const id
|
||||||
|
|
||||||
heldEffect ::
|
heldEffect ::
|
||||||
@@ -793,6 +796,25 @@ dropInventoryPath i ip loc cr w = case ip of
|
|||||||
guard $ (i + j) `IM.member` (cr ^. crInv)
|
guard $ (i + j) `IM.member` (cr ^. crInv)
|
||||||
return $ dropItem cr (i + j) w
|
return $ dropItem cr (i + j) w
|
||||||
|
|
||||||
|
useInventoryPath :: PressType ->
|
||||||
|
Int -> InventoryPathing -> LocationLDT ItemLink ComposedItem
|
||||||
|
-> Creature
|
||||||
|
-> World -> World
|
||||||
|
useInventoryPath pt i ip loc cr w = case ip of
|
||||||
|
ABSOLUTE -> fromMaybe w $ do
|
||||||
|
guard $ i `IM.member` (cr ^. crInv)
|
||||||
|
return $ w & cWorld . lWorld . delayedEvents .:~ (1,UseInvItem i pt)
|
||||||
|
RELCURS -> fromMaybe w $ do
|
||||||
|
j <- cr ^? crManipulation . manObject . imSelectedItem
|
||||||
|
guard $ (i + j) `IM.member` (cr ^. crInv)
|
||||||
|
return $ w
|
||||||
|
& cWorld . lWorld . delayedEvents .:~ (1,UseInvItem (i+j) pt)
|
||||||
|
RELITEM -> fromMaybe w $ do
|
||||||
|
j <- loc ^? locLDT . ldtValue . _1 . itLocation . ilInvID
|
||||||
|
guard $ (i + j) `IM.member` (cr ^. crInv)
|
||||||
|
return $ w
|
||||||
|
& cWorld . lWorld . delayedEvents .:~ (1,UseInvItem (i+j) pt)
|
||||||
|
|
||||||
--useRewindGun _ _ w = case w ^. cwTime . rewindWorlds of
|
--useRewindGun _ _ w = case w ^. cwTime . rewindWorlds of
|
||||||
-- [w'] -> w & cwTime . maybeWorld .~ Just' w'
|
-- [w'] -> w & cwTime . maybeWorld .~ Just' w'
|
||||||
-- (w' : ws) -> w
|
-- (w' : ws) -> w
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ itemFromBase = \case
|
|||||||
DETECTOR d -> detector d
|
DETECTOR d -> detector d
|
||||||
ARHUD -> arHUD
|
ARHUD -> arHUD
|
||||||
DROPPER x -> dropper x
|
DROPPER x -> dropper x
|
||||||
|
CLICKER x -> clicker x
|
||||||
|
|
||||||
itemFromAmmoMag :: AmmoMagType -> Item
|
itemFromAmmoMag :: AmmoMagType -> Item
|
||||||
itemFromAmmoMag at = case at of
|
itemFromAmmoMag at = case at of
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ itemBaseName = \case
|
|||||||
DETECTOR t -> show t
|
DETECTOR t -> show t
|
||||||
ARHUD -> "AR-HUD"
|
ARHUD -> "AR-HUD"
|
||||||
DROPPER x -> "DROPPER-" ++ showInventoryPathing x
|
DROPPER x -> "DROPPER-" ++ showInventoryPathing x
|
||||||
|
CLICKER x -> "CLICKER-" ++ showInventoryPathing x
|
||||||
|
|
||||||
showInventoryPathing :: InventoryPathing -> String
|
showInventoryPathing :: InventoryPathing -> String
|
||||||
showInventoryPathing = \case
|
showInventoryPathing = \case
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ itemSPic it = case it ^. itType of
|
|||||||
INTROSCAN {} -> defSPic
|
INTROSCAN {} -> defSPic
|
||||||
DETECTOR dt -> noPic (colorSH (detectorColor dt) $ upperPrismPolySU 3 $ rectWH 2 2)
|
DETECTOR dt -> noPic (colorSH (detectorColor dt) $ upperPrismPolySU 3 $ rectWH 2 2)
|
||||||
DROPPER{} -> defSPic
|
DROPPER{} -> defSPic
|
||||||
|
CLICKER{} -> defSPic
|
||||||
|
|
||||||
craftItemSPic :: CraftType -> Shape
|
craftItemSPic :: CraftType -> Shape
|
||||||
craftItemSPic = \case
|
craftItemSPic = \case
|
||||||
|
|||||||
@@ -167,6 +167,7 @@ itemToFunction itm = case itm ^. itType of
|
|||||||
EQUIP{} -> EquipmentPlatformSF
|
EQUIP{} -> EquipmentPlatformSF
|
||||||
ATTACH SHELLPAYLOAD{} -> AmmoPayloadSF LauncherAmmo
|
ATTACH SHELLPAYLOAD{} -> AmmoPayloadSF LauncherAmmo
|
||||||
DROPPER{} -> GadgetPlatformSF
|
DROPPER{} -> GadgetPlatformSF
|
||||||
|
CLICKER{} -> GadgetPlatformSF
|
||||||
_ -> NoSF
|
_ -> NoSF
|
||||||
|
|
||||||
structureToPotentialFunction ::
|
structureToPotentialFunction ::
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ module Dodge.Item.Scope (
|
|||||||
introScan,
|
introScan,
|
||||||
mapper,
|
mapper,
|
||||||
dropper,
|
dropper,
|
||||||
|
clicker,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Dodge.Item.Attach
|
import Dodge.Item.Attach
|
||||||
@@ -74,6 +75,12 @@ dropper x =
|
|||||||
& itType .~ DROPPER x
|
& itType .~ DROPPER x
|
||||||
& itUse .~ UseInt 0
|
& itUse .~ UseInt 0
|
||||||
|
|
||||||
|
clicker :: InventoryPathing -> Item
|
||||||
|
clicker x =
|
||||||
|
defaultHeldItem
|
||||||
|
& itType .~ CLICKER x
|
||||||
|
& itUse .~ UseInt 0
|
||||||
|
|
||||||
bulletModule :: BulletMod -> Item
|
bulletModule :: BulletMod -> Item
|
||||||
bulletModule bm =
|
bulletModule bm =
|
||||||
defaultHeldItem
|
defaultHeldItem
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ module Dodge.WorldEffect (
|
|||||||
lineOutputTerminal,
|
lineOutputTerminal,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Dodge.Creature.Impulse.UseItem
|
||||||
import Dodge.BlBl
|
import Dodge.BlBl
|
||||||
import Dodge.Data.Input
|
import Dodge.Data.Input
|
||||||
import Dodge.HeldUse
|
import Dodge.HeldUse
|
||||||
@@ -42,6 +43,7 @@ doWdWd we = case we of
|
|||||||
MakeTempLight _ 0 -> id
|
MakeTempLight _ 0 -> id
|
||||||
MakeTempLight x t -> (cWorld . lWorld . lights .:~ x)
|
MakeTempLight x t -> (cWorld . lWorld . lights .:~ x)
|
||||||
. (cWorld . lWorld . worldEvents .:~ MakeTempLight x (t-1))
|
. (cWorld . lWorld . worldEvents .:~ MakeTempLight x (t-1))
|
||||||
|
UseInvItem invid pt -> \w -> fromMaybe w (useItem invid pt w)
|
||||||
|
|
||||||
doItCrWdWd :: ItCrWdWd -> LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
doItCrWdWd :: ItCrWdWd -> LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||||
doItCrWdWd icww = case icww of
|
doItCrWdWd icww = case icww of
|
||||||
|
|||||||
Reference in New Issue
Block a user