Cleanup, allow more general magShield deflection
This commit is contained in:
@@ -32,6 +32,7 @@ updateBullet w bu
|
||||
return $ partspawn p
|
||||
p = _buPos bu
|
||||
|
||||
-- do we want this to drain energy from the deflection source?
|
||||
applyMagnetsToBul :: Bullet -> World -> Bullet
|
||||
applyMagnetsToBul bu =
|
||||
foldl' (flip doMagnetBuBu) bu . _oldMagnets . _lWorld . _cWorld
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
module Dodge.Data.Item.HeldUse where
|
||||
|
||||
--import Dodge.Data.Item.Use.Consumption.Ammo
|
||||
import Dodge.Data.Magnet
|
||||
import Data.Aeson
|
||||
import Data.Aeson.TH
|
||||
import Control.Lens
|
||||
@@ -17,19 +18,11 @@ data Cuse
|
||||
|
||||
data Euse
|
||||
= EDoNothing
|
||||
| EMagShield
|
||||
| EMagShield MagnetBuBu
|
||||
| EWristShield
|
||||
| EHeadLamp
|
||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
--data Luse
|
||||
-- = LDoNothing
|
||||
-- | LRewind
|
||||
-- | LTimePause
|
||||
-- | LTimeScroll
|
||||
-- deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
makeLenses ''Euse
|
||||
deriveJSON defaultOptions ''Cuse
|
||||
deriveJSON defaultOptions ''Euse
|
||||
--deriveJSON defaultOptions ''Luse
|
||||
|
||||
+5
-4
@@ -35,21 +35,22 @@ useE :: LocationLDT ItemLink ComposedItem -> Creature -> World -> World
|
||||
useE loc cr = case eo of
|
||||
Nothing -> id
|
||||
Just EDoNothing -> id
|
||||
Just EMagShield -> useMagShield itm cr
|
||||
Just (EMagShield mt) -> useMagShield mt itm cr
|
||||
Just EWristShield -> setWristShieldPos itm cr
|
||||
Just EHeadLamp -> createHeadLamp itm cr
|
||||
where
|
||||
itm = loc ^. locLDT . ldtValue . _1
|
||||
eo = itm ^? itUse . uequipEffect . eeUse
|
||||
|
||||
useMagShield :: Item -> Creature -> World -> World
|
||||
useMagShield _ cr w = w & cWorld . lWorld . magnets .:~ themagnet
|
||||
-- this should probably drain energy
|
||||
useMagShield :: MagnetBuBu -> Item -> Creature -> World -> World
|
||||
useMagShield mt _ cr w = w & cWorld . lWorld . magnets .:~ themagnet
|
||||
where
|
||||
themagnet =
|
||||
Magnet
|
||||
{ _mgPos = _crPos cr
|
||||
--, _mgField = MagnetBuBuCurveAroundField 50 200
|
||||
, _mgField = MagnetDeflect
|
||||
, _mgField = mt
|
||||
}
|
||||
|
||||
onEquipWristShield :: Item -> Creature -> World -> World
|
||||
|
||||
@@ -17,6 +17,7 @@ module Dodge.Item.Equipment (
|
||||
pulseChecker,
|
||||
) where
|
||||
|
||||
import Dodge.Data.Magnet
|
||||
import Dodge.Item.Weapon.Bullet
|
||||
import Geometry.Data
|
||||
import Dodge.Data.Item
|
||||
@@ -27,7 +28,7 @@ magShield :: Item
|
||||
magShield =
|
||||
defaultEquipment
|
||||
& itParams .~ MagShieldParams Nothing
|
||||
& itUse . uequipEffect . eeUse .~ EMagShield
|
||||
& itUse . uequipEffect . eeUse .~ EMagShield MagnetRepulse
|
||||
& itUse . uequipEffect . eeType .~ GoesOnWrist
|
||||
& itType .~ EQUIP MAGSHIELD
|
||||
|
||||
|
||||
Reference in New Issue
Block a user