Make aimStance record into function

This commit is contained in:
2025-06-03 15:19:35 +01:00
parent 589603e474
commit a17961eac7
20 changed files with 297 additions and 262 deletions
+12 -11
View File
@@ -6,6 +6,7 @@ module Dodge.Item.HeldOffset (
heldItemOrient2D,
) where
import Dodge.Item.AimStance
import qualified Quaternion as Q
import Data.Maybe
import Dodge.Data.Creature
@@ -52,11 +53,12 @@ heldItemRelativeOrient itm cr (p,q)
handPos = case cr ^? crStance . carriage of
Just (Walking x LeftForward) -> f x * 50 -2
_ -> 0 - 2
isOneHand =
itm ^? itUseAimStance == Just OneHand
|| isNothing (itm ^? itUseAimStance)
isTwoHandFlat = itm ^? itUseAimStance == Just TwoHandFlat
itUseAimStance = itUse . heldAim . aimStance
isOneHand = aStance itm == OneHand
-- itm ^? itUseAimStance == Just OneHand
-- || isNothing (itm ^? itUseAimStance)
isTwoHandFlat = aStance itm == TwoHandFlat
--itm ^? itUseAimStance == Just TwoHandFlat
--itUseAimStance = itUse . heldAim . aimStance
f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
sLen = _strideLength $ _crStance cr
@@ -67,12 +69,11 @@ aimingWeaponZeroPos cr it =
-- the position of a weapon handle
aimingWeaponHandlePos :: Creature -> Item -> Point2
aimingWeaponHandlePos _ it = case it ^? itUse . heldAim . aimStance of
Just TwoHandUnder -> V2 (-2) 0
Just TwoHandOver -> V2 (-7) 0
Just OneHand -> V2 10 (-2)
Just TwoHandFlat -> V2 10 0
Nothing -> 0
aimingWeaponHandlePos _ it = case aStance it of
TwoHandUnder -> V2 (-2) 0
TwoHandOver -> V2 (-7) 0
OneHand -> V2 10 (-2)
TwoHandFlat -> V2 10 0
heldItemOffset :: Item -> Creature -> Point3 -> Point3
heldItemOffset itm cr p = fst (heldItemRelativeOrient itm cr (p,Q.qID))