Files
loop/src/Dodge/Euse.hs
T

64 lines
2.0 KiB
Haskell

module Dodge.Euse (
equipBackgroundEffect,
) where
import Dodge.Creature.HandPos
import Dodge.Creature.Test
import Dodge.Data.ComposedItem
import Dodge.Data.DoubleTree
import Dodge.Data.Equipment.Misc
import Dodge.Data.World
import Dodge.Wall.Move
import Geometry
import LensHelp
equipBackgroundEffect :: LocationDT OItem -> Creature -> EquipSite
-> World -> World
equipBackgroundEffect loc cr = case eo of
EQUIP (MAGSHIELD mt) -> const $ useMagShield mt itm cr
EQUIP WRISTARMOUR -> setWristShieldPos itm cr
EQUIP HEADLAMP -> const $ createHeadLamp itm cr
_ -> const id
where
itm = loc ^. locDT . dtValue . _1
eo = itm ^. itType
-- this should probably drain energy
useMagShield :: MagnetBuBu -> Item -> Creature -> World -> World
useMagShield mt _ cr w =
w & cWorld . lWorld . magnets
.:~ Magnet
{ _mgPos = _crPos cr
, _mgField = mt
}
setWristShieldPos :: Item -> Creature -> EquipSite -> World -> World
setWristShieldPos itm cr x w = moveWallIDUnsafe i wlline w
where
m = w ^. cWorld . lWorld . items
i = _itParamID $ _itParams itm
wlline = (f (V3 (-10) 7 0), f (V3 10 7 0))
handtrans = case x of
OnLeftWrist -> \cr' -> translatePointToLeftHand cr' . g
_ -> translatePointToRightHand
g
| twists cr = (+.+.+ V3 (-5) 10 0)
| otherwise = id
f = (+.+ _crPos cr) . stripZ . rotate3 (_crDir cr) . handtrans cr
-- TODO the reflection should be controled by the particle
--shieldWallDamage :: Damage -> Wall -> Int -> World -> World
--shieldWallDamage dm _ crid w = case _dmType dm of
---- Lasering -> w
-- _ | isMovementDam dm -> w & creatures . ix crid . crState . crDamage .:~ dm
-- _ -> w
createHeadLamp :: Item -> Creature -> World -> World
createHeadLamp _ cr w = w &
cWorld . lWorld . lights
.:~ LSParam
((_crPos cr `v2z` 0) +.+.+ rotate3 (_crDir cr)
(translatePointToHead (w ^. cWorld . lWorld . items) cr (V3 5 0 3)))
200
0.7