Files
loop/src/Dodge/Euse.hs
T

62 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 :: LocationLDT ItemLink OItem -> Creature -> World -> World
equipBackgroundEffect loc cr = case eo of
EQUIP (MAGSHIELD mt) -> useMagShield mt itm cr
EQUIP WRISTARMOUR -> setWristShieldPos itm cr
EQUIP HEADLAMP -> createHeadLamp itm cr
_ -> id
where
itm = loc ^. locLDT . ldtValue . _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 -> World -> World
setWristShieldPos itm cr w = w & moveWallIDUnsafe i wlline
where
i = _itParamID $ _itParams itm
wlline = (f (V3 (-10) 7 0), f (V3 10 7 0))
invid = _ilInvID (_itLocation itm)
handtrans = case cr ^? crInv . ix invid . itLocation . ilEquipSite . _Just of
Just 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 =
cWorld . lWorld . lights
.:~ LSParam
((_crPos cr `v2z` 0) +.+.+ rotate3 (_crDir cr) (translatePointToHead cr (V3 5 0 3)))
200
0.7