Improve wrist forcefield positioning

Not perfect for left wrist when aiming two handed twist weapons
This commit is contained in:
2026-01-22 21:19:40 +00:00
parent f1c63abdc3
commit a464d4dc38
8 changed files with 178 additions and 174 deletions
+90 -24
View File
@@ -1,22 +1,25 @@
module Dodge.Euse (equipBackgroundEffect) where
module Dodge.Euse (
equipBackgroundEffect,
effectOnRemove,
effectOnEquip,
) 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.Item.Location
import Dodge.Wall.Delete
import Dodge.Wall.ForceField
import Dodge.Wall.Move
import Geometry
import qualified IntMapHelp as IM
import LensHelp
import Linear
import NewInt
equipBackgroundEffect ::
LocationDT OItem ->
Creature ->
EquipSite ->
World ->
World
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
@@ -29,28 +32,31 @@ equipBackgroundEffect loc cr = case eo of
-- this should probably drain energy
useMagShield :: MagnetBuBu -> Item -> Creature -> World -> World
useMagShield mt _ cr w =
w & cWorld . lWorld . magnets
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
--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
-- 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
@@ -58,7 +64,9 @@ setWristShieldPos itm cr x = moveWallIDUnsafe i wlline
createHeadLamp :: Item -> Creature -> World -> World
createHeadLamp _ cr w =
w
& cWorld . lWorld . lights
& cWorld
. lWorld
. lights
.:~ LSParam
( _crPos cr
+.+.+ rotate3
@@ -67,3 +75,61 @@ createHeadLamp _ cr w =
)
200
0.7
effectOnRemove :: Item -> Creature -> World -> World
effectOnRemove itm = case itm ^. itType of
EQUIP WRISTARMOUR -> onRemoveWristShield itm
_ -> const id
onRemoveWristShield :: Item -> Creature -> World -> World
onRemoveWristShield itm _ =
(pointerToItem itm . itParams .~ NoParams)
. maybe id deleteWallID (itm ^? itParams . itParamID)
effectOnEquip :: Item -> Creature -> World -> World
effectOnEquip itm = case itm ^. itType of
EQUIP WRISTARMOUR -> onEquipWristShield itm
_ -> const id
onEquipWristShield :: Item -> Creature -> World -> World
onEquipWristShield itm cr w =
w
& pointerToItem itm
. itParams
.~ ItemParamID i
& cWorld
. lWorld
. walls
. at i
?~ forceField{_wlID = i}
& setWristShieldPos
( itm & itParams .~ ItemParamID{_itParamID = i}
)
cr esite
where
i = IM.newKey (w ^. cWorld . lWorld . walls)
esite = w ^?! cWorld . lWorld . items . ix (itm ^. itID . unNInt) . itLocation . ilEquipSite . _Just
setWristShieldPos :: Item -> Creature -> EquipSite -> World -> World
setWristShieldPos itm cr esite w = w & moveWallIDUnsafe i wlline
where
i = _itParamID $ _itParams itm
wlline = (f (V3 (-10) y 0), f (V3 10 y 0))
y = case esite of
OnLeftWrist -> 7
OnRightWrist -> -7
_ -> error "setWristShieldPos esite is not a wrist"
handtrans = case w
^? cWorld
. lWorld
. items
. ix (itm ^. itID . unNInt)
. itLocation
. ilEquipSite
. _Just of
Just x -> translateToES cr x -- . g
_ -> undefined
-- g
-- | twists cr = (+.+.+ V3 (-5) 10 0)
-- | otherwise = id
f = (+.+ cr ^. crPos . _xy) . stripZ . rotate3 (_crDir cr) . handtrans