Work on AttachUse -> UseAttach

This commit is contained in:
2024-10-01 14:21:40 +01:00
parent 36238669f5
commit f90bbc1cd0
15 changed files with 436 additions and 374 deletions
+4 -4
View File
@@ -1,5 +1,7 @@
module Dodge.Item.Ammo where
module Dodge.Item.Ammo
where
import Dodge.Item.Attach
import Control.Lens
import Dodge.Data.World
import Dodge.Default.Item
@@ -98,6 +100,4 @@ chemFuelPouch =
}
bulletSynthesizer :: Item
bulletSynthesizer = defaultHeldItem
& itType .~ ATTACH BULLETSYNTHESIZER
& itUse .~ AttachUse Nothing
bulletSynthesizer = makeAttach BULLETSYNTHESIZER
+2 -2
View File
@@ -78,7 +78,7 @@ showAttachItem t itm = case t of
ZOOMSCOPE -> "ZOOMSCOPE"
-- TARGETATTACH x -> show x
BULLETSYNTHESIZER -> "BSYNTH"
REMOTESCREEN -> "REMOTE SCREEN " ++ show (itm ^? itUse . atLinkedProjectile . _Just)
REMOTESCREEN -> "REMOTE SCREEN " ++ show (itm ^? itUse . uaParams . apLinkedProjectile . _Just)
HOMINGMODULE -> "HOMING MOD"
AUGMENTEDHUD -> "AUGMENTED HUD"
@@ -115,7 +115,7 @@ itemNumberDisplay cr itm = case iu of
EquipUse{} -> showEquipmentNumber cr itm
CraftUse -> []
UseConsume {} -> []
AttachUse {} -> []
UseAttach {} -> []
UseAmmoMag {} -> [maybe "" shortShow $ itm ^? itUse . amagLoadStatus . iaLoaded]
ScopeUse OpticScope {_opticZoom = x} -> [shortShow x]
ScopeUse {} -> []
+32 -1
View File
@@ -4,6 +4,7 @@ module Dodge.Item.HeldOffset (
heldItemOffset,
) where
import qualified Linear.Quaternion as Q
import Data.Maybe
import Dodge.Creature.HandPos
import Dodge.Data.Creature
@@ -21,6 +22,37 @@ transToHandle itm = fromMaybe id $ do
V2 x y <- itm ^? itUse . heldAim . aimHandlePos
return (-.-.- V3 x y 0)
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
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 :: Item -> Creature -> Point3 -> Point3
heldItemOffset itm cr
| _posture (_crStance cr) == Aiming =
@@ -39,7 +71,6 @@ heldItemOffset itm cr
. (+.+.+ V3 (_crRad cr) 0 0)
. rotate3 (strideRot cr + 1.2)
. (+.+.+ V3 (-8) 0 0)
-- . (+.+.+ V3 (-5) 0 0)
. transToHandle itm
where
handD = 15
+3 -3
View File
@@ -1,5 +1,6 @@
module Dodge.Item.Orientation
where
module Dodge.Item.Orientation
( orientAttachment
) where
import Dodge.Data.ComposedItem
import Geometry.Data
@@ -13,7 +14,6 @@ orientChild itm = case _itType itm of
orientByLink :: Item -> ComposeLinkType -> (Point3, Q.Quaternion Float)
orientByLink itm lt = case (_itType itm,lt) of
--(HELD FLAMETHROWER, AmmoInLink{}) -> undefined --(V3 4 (-6) 0,0)
(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)
_ -> (0,Q.axisAngle (V3 1 0 0) 0)
+5 -10
View File
@@ -10,6 +10,7 @@ module Dodge.Item.Scope (
bulletPayloadModule,
) where
import Dodge.Item.Attach
import Control.Lens
import Dodge.Data.Item
import Dodge.Default.Item
@@ -25,9 +26,7 @@ targetingScope tt = defaultHeldItem
& itUse .~ TargetingUse Nothing Nothing False
homingModule :: Item
homingModule = defaultHeldItem
& itType .~ ATTACH HOMINGMODULE
& itUse .~ AttachUse Nothing
homingModule = makeAttach HOMINGMODULE
fletchingModule :: Item
fletchingModule = bulletTargetingModule FlechetteTrajectoryType
@@ -45,12 +44,8 @@ bulletPayloadModule :: BulletPayload -> Item
bulletPayloadModule = bulletModule . BulletModPayload
augmentedHUD :: Item
augmentedHUD = defaultHeldItem
& itType .~ ATTACH AUGMENTEDHUD
& itUse .~ AttachUse Nothing
augmentedHUD = makeAttach AUGMENTEDHUD
remoteScreen :: Item
remoteScreen =
defaultHeldItem
& itType .~ ATTACH REMOTESCREEN
& itUse .~ AttachUse Nothing
remoteScreen = makeAttach REMOTESCREEN