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