Magnets
This commit is contained in:
@@ -8,21 +8,39 @@ import Dodge.Item.Weapon.BatteryGuns
|
||||
import Dodge.Creature.Test
|
||||
import Dodge.Wall.Reflect
|
||||
import Dodge.Wall
|
||||
import Dodge.Magnet
|
||||
import Picture
|
||||
import Geometry
|
||||
import ShapePicture
|
||||
import Shape
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Control.Lens
|
||||
|
||||
magShield :: Item
|
||||
magShield = defaultEquipment
|
||||
{ _itType = MAGSHIELD
|
||||
, _itName = "MAGSHIELD"
|
||||
, _itUse = EquipUse useMagShield
|
||||
, _itEquipPict = \_ _ -> (,) emptySH blank
|
||||
, _itID = Nothing
|
||||
, _itAttachment = ItMInt Nothing
|
||||
}
|
||||
useMagShield :: Creature -> Int -> World -> World
|
||||
useMagShield cr invid w = w & magnets . at mgid ?~ themagnet
|
||||
where
|
||||
themagnet = Magnet
|
||||
{_mgID = mgid
|
||||
,_mgUpdate = Just . (mgUpdate .~ const Nothing)
|
||||
,_mgPos = _crPos cr
|
||||
,_mgField = curveAroundField
|
||||
}
|
||||
mgid = case it ^? itAttachment . itMInt . _Just of
|
||||
Just mgid' -> mgid'
|
||||
Nothing -> IM.newKey $ _magnets w
|
||||
it = _crInv cr IM.! invid
|
||||
|
||||
|
||||
flameShield :: Item
|
||||
flameShield = defaultEquipment
|
||||
{ _itType = FLAMESHIELD
|
||||
|
||||
Reference in New Issue
Block a user