Move function fields outside equipment
This commit is contained in:
@@ -4,6 +4,8 @@ module Dodge.Creature.Impulse.UseItem
|
|||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Luse
|
import Dodge.Luse
|
||||||
|
import Dodge.Cuse
|
||||||
|
import Dodge.Euse
|
||||||
import Dodge.Inventory
|
import Dodge.Inventory
|
||||||
import Dodge.Reloading
|
import Dodge.Reloading
|
||||||
import Dodge.Item.Location
|
import Dodge.Item.Location
|
||||||
@@ -31,7 +33,7 @@ itemEffect cr it w = case it ^? itUse of
|
|||||||
Just LeftUse {} -> doequipmentchange
|
Just LeftUse {} -> doequipmentchange
|
||||||
Just EquipUse{} -> doequipmentchange
|
Just EquipUse{} -> doequipmentchange
|
||||||
-- ConsumeUse will cause problems if the item is not selected
|
-- ConsumeUse will cause problems if the item is not selected
|
||||||
Just (ConsumeUse eff) -> setuhamdown $ hammerTest $ eff it cr . rmInvItem (_crID cr) (crSel cr)
|
Just (ConsumeUse eff) -> setuhamdown $ hammerTest $ (useC eff) it cr . rmInvItem (_crID cr) (crSel cr)
|
||||||
Just NoUse -> setuhamdown w
|
Just NoUse -> setuhamdown w
|
||||||
Nothing -> setuhamdown w
|
Nothing -> setuhamdown w
|
||||||
where
|
where
|
||||||
@@ -92,8 +94,8 @@ toggleEquipmentAt rbops invid cr w = case rbops ^? opAllocateEquipment of
|
|||||||
crpoint = creatures . ix (_crID cr)
|
crpoint = creatures . ix (_crID cr)
|
||||||
itmat i = _crInv cr IM.! i
|
itmat i = _crInv cr IM.! i
|
||||||
itm = itmat (crSel cr)
|
itm = itmat (crSel cr)
|
||||||
onequip itm' = (_eqOnEquip . _eqEq . _itUse) itm' itm'
|
onequip itm' = useE ((_eqOnEquip . _eqEq . _itUse) itm') itm'
|
||||||
onremove itm' = (_eqOnRemove . _eqEq . _itUse) itm' itm'
|
onremove itm' = useE ((_eqOnRemove . _eqEq . _itUse) itm') itm'
|
||||||
|
|
||||||
useLeftItem :: Int -> World -> World
|
useLeftItem :: Int -> World -> World
|
||||||
useLeftItem cid w
|
useLeftItem cid w
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ module Dodge.Creature.State
|
|||||||
, doDamage
|
, doDamage
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
|
import Dodge.Euse
|
||||||
import Dodge.EnergyBall
|
import Dodge.EnergyBall
|
||||||
import Dodge.Damage
|
import Dodge.Damage
|
||||||
import Dodge.Hammer
|
import Dodge.Hammer
|
||||||
@@ -181,7 +182,7 @@ useUpdate = (useHammer %~ moveHammerUp)
|
|||||||
. (useDelay . rateTime %~ decreaseToZero)
|
. (useDelay . rateTime %~ decreaseToZero)
|
||||||
|
|
||||||
useEquipment :: Creature -> Int -> World -> World
|
useEquipment :: Creature -> Int -> World -> World
|
||||||
useEquipment cr i = _eqUse (_eqEq $ _itUse itm) itm cr
|
useEquipment cr i = useE (_eqUse (_eqEq $ _itUse itm)) itm cr
|
||||||
where
|
where
|
||||||
itm = _crInv cr IM.! i
|
itm = _crInv cr IM.! i
|
||||||
-- a map updating all inventory items
|
-- a map updating all inventory items
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
module Dodge.Cuse where
|
||||||
|
import Dodge.Data
|
||||||
|
|
||||||
|
import Control.Lens
|
||||||
|
|
||||||
|
useC :: Cuse -> Item -> Creature -> World -> World
|
||||||
|
useC cu = case cu of
|
||||||
|
CDoNothing -> const $ const id
|
||||||
|
CHeal x -> const $ \cr -> creatures . ix (_crID cr) . crHP +~ x
|
||||||
+4
-4
@@ -416,16 +416,16 @@ data ItemUse
|
|||||||
, _eqEq :: Equipment
|
, _eqEq :: Equipment
|
||||||
}
|
}
|
||||||
| ConsumeUse
|
| ConsumeUse
|
||||||
{ _cUse :: Item -> Creature -> World -> World
|
{ _cUse :: Cuse --Item -> Creature -> World -> World
|
||||||
}
|
}
|
||||||
| EquipUse
|
| EquipUse
|
||||||
{ _eqEq :: Equipment
|
{ _eqEq :: Equipment
|
||||||
}
|
}
|
||||||
| NoUse
|
| NoUse
|
||||||
data Equipment = Equipment
|
data Equipment = Equipment
|
||||||
{ _eqUse :: Item -> Creature -> World -> World
|
{ _eqUse :: Euse --Item -> Creature -> World -> World
|
||||||
, _eqOnEquip :: Item -> Creature -> World -> World
|
, _eqOnEquip :: Euse --Item -> Creature -> World -> World
|
||||||
, _eqOnRemove :: Item -> Creature -> World -> World
|
, _eqOnRemove :: Euse --Item -> Creature -> World -> World
|
||||||
, _eqSite :: EquipSite
|
, _eqSite :: EquipSite
|
||||||
, _eqParams :: EquipParams
|
, _eqParams :: EquipParams
|
||||||
, _eqViewDist :: Maybe Float
|
, _eqViewDist :: Maybe Float
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
module Dodge.Data.CamouflageStatus where
|
||||||
|
data CamouflageStatus
|
||||||
|
= FullyVisible
|
||||||
|
| Invisible
|
||||||
|
deriving (Eq,Ord,Enum)
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
{-# LANGUAGE StrictData #-}
|
{-# LANGUAGE StrictData #-}
|
||||||
module Dodge.Data.Creature where
|
module Dodge.Data.Creature
|
||||||
|
( module Dodge.Data.Creature
|
||||||
|
, module Dodge.Data.CamouflageStatus
|
||||||
|
) where
|
||||||
|
import Dodge.Data.CamouflageStatus
|
||||||
import Sound.Data
|
import Sound.Data
|
||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
import Color
|
import Color
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
data CamouflageStatus
|
|
||||||
= FullyVisible
|
|
||||||
| Invisible
|
|
||||||
deriving (Eq,Ord,Enum)
|
|
||||||
data CreatureStatistics = CreatureStatistics
|
data CreatureStatistics = CreatureStatistics
|
||||||
{ _strength :: Int
|
{ _strength :: Int
|
||||||
, _dexterity :: Int
|
, _dexterity :: Int
|
||||||
|
|||||||
Binary file not shown.
@@ -1,5 +1,6 @@
|
|||||||
module Dodge.Data.Item.HeldUse where
|
module Dodge.Data.Item.HeldUse where
|
||||||
import Dodge.Combine.Data
|
import Dodge.Combine.Data
|
||||||
|
import Dodge.Data.CamouflageStatus
|
||||||
|
|
||||||
data HeldUse = HeldDoNothing
|
data HeldUse = HeldDoNothing
|
||||||
| HeldUseAmmoParams
|
| HeldUseAmmoParams
|
||||||
@@ -18,6 +19,20 @@ data HeldUse = HeldDoNothing
|
|||||||
| HeldForceField
|
| HeldForceField
|
||||||
| HeldShatter
|
| HeldShatter
|
||||||
|
|
||||||
|
data Cuse = CDoNothing
|
||||||
|
| CHeal Int
|
||||||
|
|
||||||
|
data Euse = EDoNothing
|
||||||
|
| EDetector Detector
|
||||||
|
| EMagShield
|
||||||
|
| EWristShield
|
||||||
|
| EHeadLamp
|
||||||
|
| ECamouflage CamouflageStatus
|
||||||
|
|
||||||
|
| EonWristShield
|
||||||
|
|
||||||
|
| EoffWristShield
|
||||||
|
|
||||||
data Luse = LDoNothing
|
data Luse = LDoNothing
|
||||||
| LRewind
|
| LRewind
|
||||||
| LShrink
|
| LShrink
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ defaultlUse = LeftUse
|
|||||||
defaultEquip :: Equipment
|
defaultEquip :: Equipment
|
||||||
defaultEquip = Equipment
|
defaultEquip = Equipment
|
||||||
{ _eqSite = GoesOnSpecial
|
{ _eqSite = GoesOnSpecial
|
||||||
, _eqUse = \_ _ -> id
|
, _eqUse = EDoNothing
|
||||||
, _eqOnEquip = \_ _ -> id
|
, _eqOnEquip = EDoNothing
|
||||||
, _eqOnRemove = \_ _ -> id
|
, _eqOnRemove = EDoNothing
|
||||||
, _eqParams = NoEquipParams
|
, _eqParams = NoEquipParams
|
||||||
, _eqViewDist = Nothing
|
, _eqViewDist = Nothing
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
module Dodge.Euse where
|
||||||
|
import Dodge.Data
|
||||||
|
import Dodge.Item.Weapon.ExtraEffect
|
||||||
|
import Dodge.Item.Weapon.Radar
|
||||||
|
import Dodge.SoundLogic.ExternallyGeneratedSounds
|
||||||
|
import Dodge.Item.Equipment
|
||||||
|
import LensHelp
|
||||||
|
|
||||||
|
useE :: Euse -> Item -> Creature -> World -> World
|
||||||
|
useE eo = case eo of
|
||||||
|
EDoNothing -> const $ const id
|
||||||
|
EDetector dt -> autoEffect (detectorEffect dt) 100 click1S
|
||||||
|
EMagShield -> useMagShield
|
||||||
|
EWristShield -> setWristShieldPos
|
||||||
|
EHeadLamp -> createHeadLamp
|
||||||
|
ECamouflage vis -> overCID (crCamouflage .~ vis)
|
||||||
|
|
||||||
|
EonWristShield -> onEquipWristShield
|
||||||
|
|
||||||
|
EoffWristShield -> onRemoveWristShield
|
||||||
@@ -25,6 +25,7 @@ module Dodge.Inventory
|
|||||||
)
|
)
|
||||||
where
|
where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
|
import Dodge.Euse
|
||||||
import Dodge.Inventory.CloseObject
|
import Dodge.Inventory.CloseObject
|
||||||
import Dodge.Inventory.CheckSlots
|
import Dodge.Inventory.CheckSlots
|
||||||
import Dodge.Inventory.ItemSpace
|
import Dodge.Inventory.ItemSpace
|
||||||
@@ -71,7 +72,7 @@ rmInvItem cid invid w = case w ^? creatures . ix cid . crInv . ix invid . itCons
|
|||||||
itm = _crInv cr IM.! invid
|
itm = _crInv cr IM.! invid
|
||||||
dounequipfunction = fromMaybe id $ do
|
dounequipfunction = fromMaybe id $ do
|
||||||
rmf <- itm ^? itUse . eqEq . eqOnRemove
|
rmf <- itm ^? itUse . eqEq . eqOnRemove
|
||||||
return $ rmf itm cr
|
return $ useE rmf itm cr
|
||||||
doanyitemeffect = fromMaybe id $ do
|
doanyitemeffect = fromMaybe id $ do
|
||||||
rmf <- itm ^? itEffect . ieDrop
|
rmf <- itm ^? itEffect . ieDrop
|
||||||
return $ rmf itm cr
|
return $ rmf itm cr
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import qualified Data.IntMap.Strict as IM
|
|||||||
medkit :: Int -> Item
|
medkit :: Int -> Item
|
||||||
medkit i = defaultConsumable
|
medkit i = defaultConsumable
|
||||||
{ _itUse = ConsumeUse
|
{ _itUse = ConsumeUse
|
||||||
{_cUse = \_ cr w -> w & creatures . ix (_crID cr) . crHP +~ i
|
{_cUse = CHeal i
|
||||||
}
|
}
|
||||||
, _itID = Nothing
|
, _itID = Nothing
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,13 @@ module Dodge.Item.Equipment
|
|||||||
, speedLegs
|
, speedLegs
|
||||||
, jumpLegs
|
, jumpLegs
|
||||||
, flameShield
|
, flameShield
|
||||||
|
|
||||||
|
, useMagShield
|
||||||
|
, setWristShieldPos
|
||||||
|
, createHeadLamp
|
||||||
|
, overCID
|
||||||
|
, onEquipWristShield
|
||||||
|
, onRemoveWristShield
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.LightSource.Torch
|
import Dodge.LightSource.Torch
|
||||||
@@ -38,7 +45,7 @@ magShield = defaultEquipment
|
|||||||
{ _itID = Nothing
|
{ _itID = Nothing
|
||||||
, _itAttachment = AttachMInt Nothing
|
, _itAttachment = AttachMInt Nothing
|
||||||
}
|
}
|
||||||
& itUse . eqEq . eqUse .~ useMagShield
|
& itUse . eqEq . eqUse .~ EMagShield --useMagShield
|
||||||
& itUse . eqEq . eqSite .~ GoesOnWrist
|
& itUse . eqEq . eqSite .~ GoesOnWrist
|
||||||
& itType . iyBase .~ EQUIP MAGSHIELD
|
& itType . iyBase .~ EQUIP MAGSHIELD
|
||||||
useMagShield :: Item -> Creature -> World -> World
|
useMagShield :: Item -> Creature -> World -> World
|
||||||
@@ -73,9 +80,9 @@ wristArmour = defaultEquipment
|
|||||||
{_itID = Nothing
|
{_itID = Nothing
|
||||||
}
|
}
|
||||||
& itUse . eqEq . eqSite .~ GoesOnWrist
|
& itUse . eqEq . eqSite .~ GoesOnWrist
|
||||||
& itUse . eqEq . eqOnEquip .~ onEquipWristShield
|
& itUse . eqEq . eqOnEquip .~ EonWristShield --onEquipWristShield
|
||||||
& itUse . eqEq . eqUse .~ setWristShieldPos
|
& itUse . eqEq . eqUse .~ EWristShield --setWristShieldPos
|
||||||
& itUse . eqEq . eqOnRemove .~ onRemoveWristShield
|
& itUse . eqEq . eqOnRemove .~ EoffWristShield --onRemoveWristShield
|
||||||
& itType . iyBase .~ EQUIP WRISTARMOUR
|
& itType . iyBase .~ EQUIP WRISTARMOUR
|
||||||
|
|
||||||
onEquipWristShield :: Item -> Creature -> World -> World
|
onEquipWristShield :: Item -> Creature -> World -> World
|
||||||
@@ -232,7 +239,7 @@ headLamp1 = defaultEquipment
|
|||||||
{ _itEffect = NoItEffect
|
{ _itEffect = NoItEffect
|
||||||
, _itID = Nothing
|
, _itID = Nothing
|
||||||
}
|
}
|
||||||
& itUse . eqEq . eqUse .~ createHeadLamp
|
& itUse . eqEq . eqUse .~ EHeadLamp --createHeadLamp
|
||||||
& itUse . eqEq . eqSite .~ GoesOnHead
|
& itUse . eqEq . eqSite .~ GoesOnHead
|
||||||
& itType . iyBase .~ EQUIP HEADLAMP1
|
& itType . iyBase .~ EQUIP HEADLAMP1
|
||||||
headLamp :: Item
|
headLamp :: Item
|
||||||
@@ -240,7 +247,7 @@ headLamp = defaultEquipment
|
|||||||
{ _itEffect = NoItEffect
|
{ _itEffect = NoItEffect
|
||||||
, _itID = Nothing
|
, _itID = Nothing
|
||||||
}
|
}
|
||||||
& itUse . eqEq . eqUse .~ createHeadLamp
|
& itUse . eqEq . eqUse .~ EHeadLamp --createHeadLamp
|
||||||
& itUse . eqEq . eqSite .~ GoesOnHead
|
& itUse . eqEq . eqSite .~ GoesOnHead
|
||||||
& itType . iyBase .~ EQUIP HEADLAMP
|
& itType . iyBase .~ EQUIP HEADLAMP
|
||||||
|
|
||||||
@@ -268,8 +275,8 @@ wristInvisibility = defaultEquipment
|
|||||||
{ _itID = Nothing
|
{ _itID = Nothing
|
||||||
}
|
}
|
||||||
& itUse . eqEq . eqSite .~ GoesOnWrist
|
& itUse . eqEq . eqSite .~ GoesOnWrist
|
||||||
& itUse . eqEq . eqOnEquip .~ overCID (crCamouflage .~ Invisible)
|
& itUse . eqEq . eqOnEquip .~ ECamouflage Invisible --overCID (crCamouflage .~ Invisible)
|
||||||
& itUse . eqEq . eqOnRemove .~ overCID (crCamouflage .~ FullyVisible)
|
& itUse . eqEq . eqOnRemove .~ ECamouflage FullyVisible --overCID (crCamouflage .~ FullyVisible)
|
||||||
& itType . iyBase .~ EQUIP (INVISIBILITYEQUIPMENT GoesOnWrist)
|
& itType . iyBase .~ EQUIP (INVISIBILITYEQUIPMENT GoesOnWrist)
|
||||||
|
|
||||||
overCID :: (Creature -> Creature) -> Item -> Creature -> World -> World
|
overCID :: (Creature -> Creature) -> Item -> Creature -> World -> World
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ module Dodge.Item.Weapon.Radar where
|
|||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.RadarSweep
|
import Dodge.RadarSweep
|
||||||
import Dodge.Default
|
import Dodge.Default
|
||||||
import Dodge.Item.Weapon.ExtraEffect
|
|
||||||
import Dodge.SoundLogic
|
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
|
|
||||||
@@ -21,7 +19,7 @@ clickDetector dt = defaultWeapon
|
|||||||
autoDetector :: Detector -> Item
|
autoDetector :: Detector -> Item
|
||||||
autoDetector dt = defaultEquipment
|
autoDetector dt = defaultEquipment
|
||||||
& itUse . eqEq . eqSite .~ GoesOnWrist
|
& itUse . eqEq . eqSite .~ GoesOnWrist
|
||||||
& itUse . eqEq . eqUse .~ autoEffect (detectorEffect dt) 100 click1S
|
& itUse . eqEq . eqUse .~ EDetector dt --autoEffect (detectorEffect dt) 100 click1S
|
||||||
& itUse . eqEq . eqParams .~ EquipCounter 0
|
& itUse . eqEq . eqParams .~ EquipCounter 0
|
||||||
& itUse . eqEq . eqViewDist ?~ 350
|
& itUse . eqEq . eqViewDist ?~ 350
|
||||||
& itType . iyBase .~ EQUIP (AUTODETECTOR dt)
|
& itType . iyBase .~ EQUIP (AUTODETECTOR dt)
|
||||||
|
|||||||
Reference in New Issue
Block a user