Files
loop/src/Dodge/Euse.hs
T
2025-10-10 13:47:31 +01:00

70 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
import Linear
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 = cr ^. crPos . _xy
, _mgField = mt
}
setWristShieldPos :: Item -> Creature -> EquipSite -> World -> World
setWristShieldPos itm cr x = moveWallIDUnsafe i wlline
where
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 = (+.+ cr ^. crPos . _xy) . 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
+.+.+ rotate3
(_crDir cr)
(translateToES cr OnHead (V3 5 0 3))
)
200
0.7