Make lasGun have multiple functions when attached differently

This commit is contained in:
2024-10-06 11:19:19 +01:00
parent 3b54f00cc7
commit 9860a88c0c
11 changed files with 155 additions and 112 deletions
+9 -9
View File
@@ -175,7 +175,7 @@ updateAttachedItems itmtree cr =
chainLinkOrientation
chainLinkOrientation
(updateItemWithOrientation cr)
(heldItemRelativeOrient (fst $ _ldtValue itmtree) cr (0, Q.qID))
(heldItemRelativeOrient (_cItem $ _ldtValue itmtree) cr (0, Q.qID))
(LocLDT TopLDT itmtree)
-- need to check rotation
@@ -185,7 +185,7 @@ chainLinkOrientation ::
ItemLink ->
ComposedItem ->
(Point3, Q.Quaternion Float)
chainLinkOrientation mo (par,_) (ILink lt f) (child,_) = (p + Q.rotate q p1, q * q1)
chainLinkOrientation mo (CItem par _) (ILink lt f) (CItem child _) = (p + Q.rotate q p1, q * q1)
where
(p, q) = mo
(p1, q1) = f par lt child
@@ -203,11 +203,11 @@ updateItemWithOrientation cr m loc@(LocLDT _ itmtree) = case _itType itm of
ATTACH AUGMENTEDHUD -> drawAugmentedHUD loc
_ -> id
where
itm = itmtree ^. ldtValue . _1
itm = itmtree ^. ldtValue . cItem
drawAugmentedHUD :: LocationLDT ItemLink ComposedItem -> World -> World
drawAugmentedHUD (LocLDT con _) w = fromMaybe w $ do
itm <- con ^? cldtParent . _1
itm <- con ^? cldtParent . cItem
return $ w & cWorld . lWorld . flares <>~ drawTargeting itm w
shineTargetLaser :: Creature -> LabelDoubleTree ItemLink ComposedItem -> (Point3, Q.Quaternion Float)
@@ -215,9 +215,9 @@ shineTargetLaser :: Creature -> LabelDoubleTree ItemLink ComposedItem -> (Point3
shineTargetLaser cr itmtree (p,q) w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do
guard (crIsAiming cr)
(_, mag) <- find (isammolink . _iatType . fst) (itmtree ^. ldtLeft)
i <- mag ^? ldtValue . _1 . itUse . amagLoadStatus . iaLoaded
i <- mag ^? ldtValue . cItem . itUse . amagLoadStatus . iaLoaded
guard $ i >= x
maginvid <- mag ^? ldtValue . _1 . itLocation . ilInvID
maginvid <- mag ^? ldtValue . cItem . itLocation . ilInvID
return $ w
& cWorld . lWorld . creatures . ix (_crID cr)
. crInv . ix maginvid . itUse . amagLoadStatus . iaLoaded -~ x
@@ -234,7 +234,7 @@ shineTargetLaser cr itmtree (p,q) w = fromMaybe (w & pointittarg . itTgPos .~ No
isammolink _ = False
pos = _crPos cr + xyV3 (rotate3 cdir (p + V3 5 0 0))
cdir = _crDir cr
itm = itmtree ^. ldtValue . _1
itm = itmtree ^. ldtValue . cItem
--pointItUse = cWorld . lWorld . creatures . ix cid . crInv . ix invid . itUse
pointittarg = cWorld . lWorld . creatures . ix cid . crInv . ix invid . itTargeting
cid = _crID cr
@@ -244,9 +244,9 @@ shineTargetLaser cr itmtree (p,q) w = fromMaybe (w & pointittarg . itTgPos .~ No
shineTorch :: Creature -> LabelDoubleTree ItemLink ComposedItem -> (Point3, Q.Quaternion Float) -> World -> World
shineTorch cr itmtree (p, q) = fromMaybe id $ do
(_, mag) <- find (isammolink . _iatType . fst) (itmtree ^. ldtLeft)
i <- mag ^? ldtValue . _1 . itUse . amagLoadStatus . iaLoaded
i <- mag ^? ldtValue . cItem . itUse . amagLoadStatus . iaLoaded
guard $ i >= x
invid <- mag ^? ldtValue . _1 . itLocation . ilInvID
invid <- mag ^? ldtValue . cItem . itLocation . ilInvID
return $
(cWorld . lWorld . tempLightSources .:~ tlsTimeRadColPos 1 250 0.7 pos'')
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . amagLoadStatus . iaLoaded -~ x)