Move towards being able to orient positions on attached items
This commit is contained in:
+11
-39
@@ -22,7 +22,7 @@ useBreakL' :: [(ItemStructuralFunction, ComposeLinkType)] -> [(ItemStructuralFun
|
||||
-> LinkTest ItemLink
|
||||
useBreakL' x y = useBreakListsLinkTest (map (uncurry noa) x) (map (uncurry noa) y)
|
||||
where
|
||||
noa x y = (x, ILink y orientAttachment)
|
||||
noa a b = (a, ILink b orientAttachment)
|
||||
|
||||
|
||||
useBreakListsLinkTest :: [(ItemStructuralFunction, a)] -> [(ItemStructuralFunction, a)] -> LinkTest a
|
||||
@@ -40,12 +40,10 @@ useBreakListsLinkTest llist rlist = LTest ltest rtest
|
||||
itemToBreakLists :: Item
|
||||
-> ([(ItemStructuralFunction, ComposeLinkType)] , [(ItemStructuralFunction, ComposeLinkType)])
|
||||
itemToBreakLists itm = case itm ^. itType of
|
||||
HELD TORCH -> (getAmmoLinks itm,[])
|
||||
HELD {} ->
|
||||
( map
|
||||
(\(i, a) -> (AmmoMagSF a,AmmoInLink i a))
|
||||
(IM.toList $ itm ^. itUse . heldAmmoTypes)
|
||||
,
|
||||
[(WeaponTargetingSF,WeaponTargetingLink), (WeaponScopeSF,WeaponScopeLink)]
|
||||
( getAmmoLinks itm
|
||||
, [(WeaponTargetingSF,WeaponTargetingLink), (WeaponScopeSF,WeaponScopeLink)]
|
||||
)
|
||||
AMMOMAG {} -> fromMaybe ([],[]) $ do
|
||||
atype <- itm ^? itUse . amagType
|
||||
@@ -59,8 +57,14 @@ itemToBreakLists itm = case itm ^. itType of
|
||||
TARGETING{} -> ([(AugmentedHUDSF,AugmentedHUDLink)],[])
|
||||
_ -> ([],[])
|
||||
|
||||
getAmmoLinks :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
|
||||
getAmmoLinks itm = map
|
||||
(\(i, a) -> (AmmoMagSF a,AmmoInLink i a))
|
||||
(IM.toList $ itm ^. itUse . heldAmmoTypes)
|
||||
|
||||
itemToFunction :: Item -> ItemStructuralFunction
|
||||
itemToFunction itm = case itm ^. itType of
|
||||
HELD TORCH -> WeaponScopeSF
|
||||
HELD {} -> WeaponPlatformSF
|
||||
AMMOMAG {} -> maybe UncomposableIsolateSF AmmoMagSF $ itm ^? itUse . amagType
|
||||
ATTACH REMOTESCREEN -> RemoteScreenSF
|
||||
@@ -78,39 +82,7 @@ simplePCI :: Item -> PartiallyComposedItem ItemLink
|
||||
simplePCI itm = (itm, itemToFunction itm, uncurry useBreakL' $ itemToBreakLists itm)
|
||||
|
||||
basePartiallyComposedItem' :: Item -> PartiallyComposedItem ItemLink
|
||||
basePartiallyComposedItem' itm = case itm ^. itType of
|
||||
-- AMMOMAG _ -> ammoComposedItem' itm
|
||||
-- TARGETING{} -> (itm, WeaponTargetingSF, useBreakListsLinkTest [noa AugmentedHUDSF AugmentedHUDLink] [])
|
||||
-- ATTACH REMOTESCREEN -> nolinks RemoteScreenSF
|
||||
-- ATTACH BULLETSYNTHESIZER -> (itm, AmmoModifierSF BulletAmmo, LTest (const Nothing) (const Nothing))
|
||||
-- LEFT{} -> isolate
|
||||
-- EQUIP{} -> isolate
|
||||
-- CONSUMABLE{} -> isolate
|
||||
-- CRAFT{} -> isolate
|
||||
_ -> simplePCI itm
|
||||
where
|
||||
|
||||
noa x y = (x, ILink y orientAttachment)
|
||||
nolinks x = (itm, x, LTest (const Nothing) (const Nothing))
|
||||
isolate = (itm, UncomposableIsolateSF, LTest (const Nothing) (const Nothing))
|
||||
|
||||
ammoComposedItem' :: Item -> PartiallyComposedItem ItemLink
|
||||
ammoComposedItem' itm = fromMaybe (error "in ammoComposedItem, wrong item") $ do
|
||||
atype <- itm ^? itUse . amagType
|
||||
return
|
||||
( itm
|
||||
, AmmoMagSF atype
|
||||
, useBreakListsLinkTest
|
||||
[ noa (AmmoModifierSF atype) AmmoModLink
|
||||
, noa (AmmoTargetingSF atype) AmmoTargetingLink
|
||||
, noa (AmmoPayloadSF atype) AmmoPayloadLink
|
||||
, noa (AmmoEffectSF atype) AmmoEffectLink
|
||||
, noa RemoteScreenSF RemoteScreenLink
|
||||
]
|
||||
[]
|
||||
)
|
||||
where
|
||||
noa x y = (x, ILink y orientAttachment)
|
||||
basePartiallyComposedItem' itm = simplePCI itm
|
||||
|
||||
type LDTComb a b = LabelDoubleTree b a -> LabelDoubleTree b a -> Maybe (LabelDoubleTree b a)
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@ latchkey _ = defaultHeldItem
|
||||
torch :: Item
|
||||
torch =
|
||||
defaultHeldItem
|
||||
& itEffect . ieInv .~ EffectWhileRoot CreateHeldLight
|
||||
& itEffect . ieInv .~ EffectWhileAttached CreateHeldLight
|
||||
& itType .~ HELD TORCH
|
||||
-- & itUse . heldAim . aimHandlePos .~ 5
|
||||
& itUse . heldAim . aimMuzzles . ix 0 . mzPos . _x .~ 10
|
||||
& itUse . heldAmmoTypes .~ singleAmmo ElectricalAmmo
|
||||
|
||||
{- |
|
||||
Sends out pulses that display walls.
|
||||
|
||||
@@ -2,9 +2,10 @@ module Dodge.Item.HeldOffset (
|
||||
turretItemOffset,
|
||||
twoFlatHRot,
|
||||
heldItemOffset,
|
||||
heldItemRelativeOrient,
|
||||
) where
|
||||
|
||||
import qualified Linear.Quaternion as Q
|
||||
import qualified Quaternion as Q
|
||||
import Data.Maybe
|
||||
import Dodge.Creature.HandPos
|
||||
import Dodge.Data.Creature
|
||||
@@ -22,24 +23,33 @@ transToHandle itm = fromMaybe id $ do
|
||||
V2 x y <- itm ^? itUse . heldAim . aimHandlePos
|
||||
return (-.-.- V3 x y 0)
|
||||
|
||||
-- there is a lot of duplication going on here, and also need to check
|
||||
-- rotations
|
||||
heldItemRelativeOrient :: Item -> Creature -> (Point3, Q.Quaternion Float) -> (Point3, Q.Quaternion Float)
|
||||
heldItemRelativeOrient itm cr (p,q)
|
||||
| _posture (_crStance cr) == Aiming = (p,q)
|
||||
| isTwoHandFlat = (p,q)
|
||||
-- (+.+.+ V3 (_crRad cr) 0 handD)
|
||||
-- . rotate3 (twoFlatHRot cr)
|
||||
-- . transToHandle itm
|
||||
| isOneHand = (p,q)
|
||||
-- (+.+.+ V3 0 0 handD)
|
||||
-- . (+.+.+ V3 (_crRad cr * 0.7 + handPos) (_crRad cr * negate 0.7) 0)
|
||||
-- . (+.+.+ V3 (-2) 0 0)
|
||||
-- . transToHandle itm
|
||||
| otherwise = (p,q)
|
||||
-- (+.+.+ V3 0 0 handD)
|
||||
-- . (+.+.+ V3 (_crRad cr) 0 0)
|
||||
-- . rotate3 (strideRot cr + 1.2)
|
||||
-- . (+.+.+ V3 (-8) 0 0)
|
||||
-- . transToHandle itm
|
||||
| _posture (_crStance cr) == Aiming =
|
||||
(p +.+.+ aimingWeaponZeroPos cr itm `v2z` shoulderHeight, Q.qID * q)
|
||||
| isTwoHandFlat =
|
||||
( (+.+.+ V3 (_crRad cr) 0 handD)
|
||||
. rotate3 (twoFlatHRot cr)
|
||||
$ transToHandle itm p
|
||||
, (Q.axisAngle (V3 0 0 1) (twoFlatHRot cr)) * q
|
||||
)
|
||||
| isOneHand =
|
||||
( (+.+.+ V3 0 0 handD)
|
||||
. (+.+.+ V3 (_crRad cr * 0.7 + handPos) (_crRad cr * negate 0.7) 0)
|
||||
. (+.+.+ V3 (-2) 0 0)
|
||||
$ transToHandle itm p
|
||||
, Q.qID * q
|
||||
)
|
||||
| otherwise =
|
||||
( (+.+.+ V3 0 0 handD)
|
||||
. (+.+.+ V3 (_crRad cr) 0 0)
|
||||
. rotate3 (strideRot cr + 1.2)
|
||||
. (+.+.+ V3 (-8) 0 0)
|
||||
$ transToHandle itm p
|
||||
, (Q.axisAngle (V3 0 0 1) (strideRot cr + 1.2)) * q
|
||||
)
|
||||
where
|
||||
handD = 15
|
||||
handPos = case cr ^? crStance . carriage of
|
||||
@@ -54,36 +64,7 @@ heldItemRelativeOrient itm cr (p,q)
|
||||
sLen = _strideLength $ _crStance cr
|
||||
|
||||
heldItemOffset :: Item -> Creature -> Point3 -> Point3
|
||||
heldItemOffset itm cr
|
||||
| _posture (_crStance cr) == Aiming =
|
||||
(+.+.+ aimingWeaponZeroPos cr itm `v2z` shoulderHeight)
|
||||
| isTwoHandFlat =
|
||||
(+.+.+ V3 (_crRad cr) 0 handD)
|
||||
. rotate3 (twoFlatHRot cr)
|
||||
. transToHandle itm
|
||||
| isOneHand =
|
||||
(+.+.+ V3 0 0 handD)
|
||||
. (+.+.+ V3 (_crRad cr * 0.7 + handPos) (_crRad cr * negate 0.7) 0)
|
||||
. (+.+.+ V3 (-2) 0 0)
|
||||
. transToHandle itm
|
||||
| otherwise =
|
||||
(+.+.+ V3 0 0 handD)
|
||||
. (+.+.+ V3 (_crRad cr) 0 0)
|
||||
. rotate3 (strideRot cr + 1.2)
|
||||
. (+.+.+ V3 (-8) 0 0)
|
||||
. transToHandle itm
|
||||
where
|
||||
handD = 15
|
||||
handPos = case cr ^? crStance . carriage of
|
||||
Just (Walking x LeftForward) -> f x * 50
|
||||
_ -> 0
|
||||
isOneHand =
|
||||
itm ^? itUseAimStance == Just OneHand
|
||||
|| isNothing (itm ^? itUseAimStance)
|
||||
isTwoHandFlat = itm ^? itUseAimStance == Just TwoHandFlat
|
||||
itUseAimStance = itUse . heldAim . aimStance
|
||||
f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
|
||||
sLen = _strideLength $ _crStance cr
|
||||
heldItemOffset itm cr p = fst (heldItemRelativeOrient itm cr (p,Q.qID))
|
||||
|
||||
shoulderHeight :: Float
|
||||
shoulderHeight = 18
|
||||
|
||||
@@ -16,6 +16,7 @@ orientByLink :: Item -> ComposeLinkType -> (Point3, Q.Quaternion Float)
|
||||
orientByLink itm lt = case (_itType itm,lt) of
|
||||
(HELD FLAMETHROWER, AmmoInLink{}) -> (V3 4 (-6) 0, Q.axisAngle (V3 1 0 0) 0)
|
||||
(HELD _,AmmoInLink{}) -> (V3 7 (-2) 0, Q.axisAngle (V3 1 0 0) 0)
|
||||
(HELD _,WeaponScopeLink) -> (V3 5 0 5, Q.axisAngle (V3 1 0 0) 0)
|
||||
_ -> (0,Q.axisAngle (V3 1 0 0) 0)
|
||||
|
||||
orientAttachment :: Item -> ComposeLinkType -> Item -> Maybe (Point3, Q.Quaternion Float)
|
||||
|
||||
Reference in New Issue
Block a user