Cleanup, remove chainLinkOrientation/updateItemWithOrientation etc

This commit is contained in:
2025-07-08 23:22:33 +01:00
parent 15187db999
commit 57be90fea2
+3 -98
View File
@@ -31,7 +31,6 @@ import Dodge.Item.Grammar
import Dodge.Item.HeldOffset
import Dodge.Item.Location
import Dodge.Item.MaxAmmo
import Dodge.Item.Orientation
import Dodge.Prop.Gib
import Dodge.SoundLogic
import Dodge.Targeting.Draw
@@ -70,7 +69,6 @@ crUpdate f =
, updateWalkCycle
, f
, invRootItemEffs
, updateHeldRootItem
]
-- I have changed the ordering of item/equipment effects, which may have
@@ -163,7 +161,7 @@ invItemLocUpdate cr loc w = doAnyEquipmentEffect loc cr $ case itm ^. itType of
HELD LASER | loc ^. locLDT . ldtValue . _2 == WeaponTargetingSF
, itm ^? itLocation . ilIsAttached == Just True -> shineTargetLaser cr loc w
HELD TORCH
| itm ^? itLocation . ilIsAttached == Just True -> shineTorch' cr loc w
| itm ^? itLocation . ilIsAttached == Just True -> shineTorch cr loc w
TARGETING tt
| itm ^? itLocation . ilIsAttached == Just True -> updateItemTargeting tt cr itm w
ARHUD
@@ -287,44 +285,6 @@ trySynthBullet loc w = fromMaybe w $ do
where
itm = loc ^. locLDT . ldtValue . _1
updateHeldRootItem :: Creature -> World -> World
updateHeldRootItem cr = fromMaybe id $ do
invid <- cr ^? crManipulation . manObject . imRootSelectedItem
itmtree <- invRootTrees' (_crInv cr) ^? ix invid
return $ updateAttachedItems itmtree cr
updateAttachedItems :: LDTree ItemLink CItem -> Creature -> World -> World
updateAttachedItems itmtree cr =
cldtPropagateFold
chainLinkOrientation
chainLinkOrientation
(updateItemWithOrientation cr)
(handHandleOrient (LocLDT TopLDT itmtree) cr)
(LocLDT TopLDT itmtree)
-- need to check rotation
chainLinkOrientation :: Point3Q -> CItem -> ItemLink -> CItem -> Point3Q
chainLinkOrientation o par lt child =
o
`Q.comp` orientAttachment (par ^. _1) lt (child ^. _1)
updateItemWithOrientation ::
Creature ->
Point3Q ->
LocationLDT ItemLink CItem ->
World ->
World
updateItemWithOrientation cr m loc@(LocLDT _ itmtree) w =
case (ci ^. _1 . itType, ci ^. _2) of
(HELD TORCH, _) -> w -- shineTorch cr itmtree m w
(HELD LASER, WeaponTargetingSF) -> w -- shineTargetLaser cr loc m w
(TARGETING tt, _) -> w -- updateItemTargeting tt cr itm w
(ARHUD, _) -> w --drawARHUD loc w
_ -> w
where
ci = itmtree ^. ldtValue
itm = ci ^. _1
drawARHUD :: LocationLDT ItemLink OItem -> World -> World
drawARHUD (LocLDT con _) w = fromMaybe w $ do
itm <- con ^? cldtParent . _1
@@ -372,63 +332,8 @@ shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ d
invid = _ilInvID $ _itLocation itm
col = blue -- mixColors reloadFrac (1-reloadFrac) blue red
--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
-- guard $ i >= x
-- maginvid <- mag ^? ldtValue . _1 . itLocation . ilInvID
-- return $
-- w
-- & worldEventFlags . at InventoryChange ?~ ()
-- & cWorld . lWorld . creatures . ix (_crID cr)
-- . crInv
-- . ix maginvid
-- . itConsumables
-- . _Just
-- -~ x
-- & cWorld . lWorld . lasers
-- .:~ Laser
-- { _lpPhaseV = 1
-- , _lpDir = _crDir cr + argV (Q.qToV2 q)
-- , _lpPos = pos
-- , _lpColor = col
-- , _lpType = TargetingLaser (_itID itm)
-- }
-- where
-- itmtree = loc ^. locLDT
-- (p, q) = o `Q.comp` (V3 5 0 0, Q.qID)
-- x = 1
-- isammolink AmmoInLink{} = True
-- isammolink _ = False
-- pos = _crPos cr + xyV3 (rotate3 cdir p)
-- cdir = _crDir cr
-- itm = itmtree ^. ldtValue . _1
-- pointittarg = cWorld . lWorld . creatures . ix cid . crInv . ix invid . itTargeting
-- cid = _crID cr
-- invid = _ilInvID $ _itLocation itm
-- col = blue -- mixColors reloadFrac (1-reloadFrac) blue red
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
guard $ crIsAiming cr
guard $ i >= x
invid <- mag ^? ldtValue . _1 . itLocation . ilInvID
return $
(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 + Q.rotate q (V3 8 0 1.5))
cdir = _crDir cr
shineTorch' :: Creature -> LocationLDT ItemLink OItem -> World -> World
shineTorch' cr loc = fromMaybe id $ do
shineTorch :: Creature -> LocationLDT ItemLink OItem -> World -> World
shineTorch cr loc = fromMaybe id $ do
(_, mag) <- find (isammolink . fst) (itmtree ^. ldtLeft)
i <- mag ^. ldtValue . _1 . itConsumables
guard $ crIsAiming cr