Cleanup, remove old item orientation code

This commit is contained in:
2025-07-06 13:08:13 +01:00
parent 76cb03b07b
commit b6cd988c82
3 changed files with 80 additions and 132 deletions
+10 -16
View File
@@ -309,8 +309,7 @@ updateItemWithOrientation ::
updateItemWithOrientation cr m loc@(LocLDT _ itmtree) w =
case (ci ^. _1 . itType, ci ^. _2) of
(HELD TORCH, _) -> shineTorch cr itmtree m w
--(HELD LASER, WeaponTargetingSF) -> shineTargetLaser cr itmtree m w
(HELD LASER, WeaponTargetingSF) -> shineTargetLaser cr loc w
(HELD LASER, WeaponTargetingSF) -> shineTargetLaser cr loc m w
(TARGETING tt, _) -> updateItemTargeting tt cr itm w
(ARHUD, _) -> drawARHUD loc w
_ -> w
@@ -326,8 +325,8 @@ drawARHUD (LocLDT con _) w = fromMaybe w $ do
<>~ fold
(drawTargetingAR itm w <|> drawMapperAR itm w)
shineTargetLaser :: Creature -> LocationLDT ItemLink CItem -> World -> World
shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do
shineTargetLaser :: Creature -> LocationLDT ItemLink CItem -> Point3Q -> World -> World
shineTargetLaser cr loc o w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do
guard (crIsAiming cr)
(_, mag) <- find (isammolink . fst) (itmtree ^. ldtLeft)
i <- mag ^. ldtValue . _1 . itConsumables
@@ -352,8 +351,10 @@ shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ d
}
where
itmtree = loc ^. locLDT
(p,q) = heldItemRelativeOrient (locToTop loc ^. locLDT . ldtValue . _1) cr
$ orientLocation (V3 0 0 0,Q.qID) (fmap fst loc) (V3 5 0 0,Q.qID)
--(p,q) = heldItemRelativeOrient (locToTop loc ^. locLDT . ldtValue . _1) cr
-- $ orientLocation (V3 0 0 0,Q.qID) (fmap fst loc) (V3 5 0 0,Q.qID)
(p,q) = o `Q.comp` (V3 5 0 0,Q.qID)
-- $ orientLocation (V3 0 0 0,Q.qID) (fmap fst loc) (V3 5 0 0,Q.qID)
x = 1
isammolink AmmoInLink{} = True
isammolink _ = False
@@ -406,12 +407,7 @@ shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ d
-- invid = _ilInvID $ _itLocation itm
-- col = blue -- mixColors reloadFrac (1-reloadFrac) blue red
shineTorch ::
Creature ->
LDTree ItemLink CItem ->
(Point3, Q.Quaternion Float) ->
World ->
World
shineTorch :: Creature -> LDTree ItemLink CItem -> Point3Q -> World -> World
shineTorch cr itmtree (p, q) = fromMaybe id $ do
(_, mag) <- find (isammolink . fst) (itmtree ^. ldtLeft)
i <- mag ^. ldtValue . _1 . itConsumables
@@ -419,16 +415,14 @@ shineTorch cr itmtree (p, q) = fromMaybe id $ do
guard $ i >= x
invid <- mag ^? ldtValue . _1 . itLocation . ilInvID
return $
(cWorld . lWorld . lights .:~ LSParam pos'' 250 0.7)
(cWorld . lWorld . lights .:~ LSParam pos 250 0.7)
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itConsumables . _Just -~ x)
where
x = 10
isammolink AmmoInLink{} = True
isammolink _ = False
pos = _crPos cr `v2z` 0 + rotate3 cdir p
pos'' = pos + rotate3 d (V3 8 0 1.5)
pos = _crPos cr `v2z` 0 + rotate3 cdir (p + Q.rotate q (V3 8 0 1.5))
cdir = _crDir cr
d = _crDir cr + argV (Q.qToV2 q)
-- this probably needs to be set to null when dropped as well?
-- does this need to be updated if it is not attached to the used root item?