Unify some item updates
This commit is contained in:
@@ -160,6 +160,14 @@ invItemLocUpdate cr loc w = doAnyEquipmentEffect loc cr $ case itm ^. itType of
|
||||
HELD FLATSHIELD -> rootNotrootEff createShieldWall removeShieldWall itm cr w
|
||||
HELD MINIGUNX{} -> coolMinigun itm w
|
||||
HELD MACHINEPISTOL{} -> coolMachinePistol cr itm w
|
||||
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
|
||||
TARGETING tt
|
||||
| itm ^? itLocation . ilIsAttached == Just True -> updateItemTargeting tt cr itm w
|
||||
ARHUD
|
||||
| itm ^? itLocation . ilIsAttached == Just True -> drawARHUD loc w
|
||||
_ -> w
|
||||
where
|
||||
haspulse =
|
||||
@@ -194,8 +202,12 @@ coolMachinePistol cr itm w
|
||||
w & d . wTime .~ _coolStart (baseItemTriggerType itm)
|
||||
| otherwise = w & d . wTime .~ 0
|
||||
where
|
||||
dosound s = soundContinue
|
||||
(CrWeaponSound (_crID cr) (fromIntegral $ _itID itm)) (_crPos cr) s (Just 1)
|
||||
dosound s =
|
||||
soundContinue
|
||||
(CrWeaponSound (_crID cr) (fromIntegral $ _itID itm))
|
||||
(_crPos cr)
|
||||
s
|
||||
(Just 1)
|
||||
d = pointerToItem itm . itParams
|
||||
(sid, g) = runState (takeOne [whirdownSmall1S, whirdownSmall2S]) (w ^. randGen)
|
||||
|
||||
@@ -304,16 +316,16 @@ updateItemWithOrientation ::
|
||||
World
|
||||
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 loc m w
|
||||
(TARGETING tt, _) -> updateItemTargeting tt cr itm w
|
||||
(ARHUD, _) -> drawARHUD loc w
|
||||
(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 CItem -> World -> World
|
||||
drawARHUD :: LocationLDT ItemLink OItem -> World -> World
|
||||
drawARHUD (LocLDT con _) w = fromMaybe w $ do
|
||||
itm <- con ^? cldtParent . _1
|
||||
return $
|
||||
@@ -321,8 +333,8 @@ drawARHUD (LocLDT con _) w = fromMaybe w $ do
|
||||
<>~ fold
|
||||
(drawTargetingAR itm w <|> drawMapperAR itm w)
|
||||
|
||||
shineTargetLaser :: Creature -> LocationLDT ItemLink CItem -> Point3Q -> World -> World
|
||||
shineTargetLaser cr loc o w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do
|
||||
shineTargetLaser :: Creature -> LocationLDT ItemLink OItem -> World -> World
|
||||
shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do
|
||||
guard (crIsAiming cr)
|
||||
(_, mag) <- find (isammolink . fst) (itmtree ^. ldtLeft)
|
||||
i <- mag ^. ldtValue . _1 . itConsumables
|
||||
@@ -346,6 +358,7 @@ shineTargetLaser cr loc o w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $
|
||||
, _lpType = TargetingLaser (_itID itm)
|
||||
}
|
||||
where
|
||||
o = locOrient loc cr
|
||||
itmtree = loc ^. locLDT
|
||||
(p, q) = o `Q.comp` (V3 5 0 0, Q.qID)
|
||||
x = 1
|
||||
@@ -359,6 +372,44 @@ shineTargetLaser cr loc o w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $
|
||||
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)
|
||||
@@ -376,6 +427,25 @@ shineTorch cr itmtree (p, q) = fromMaybe id $ do
|
||||
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
|
||||
(_, 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
|
||||
itmtree = loc ^. locLDT
|
||||
(p, q) = locOrient loc cr
|
||||
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
|
||||
|
||||
-- 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?
|
||||
updateItemTargeting :: TargetingType -> Creature -> Item -> World -> World
|
||||
|
||||
@@ -8,6 +8,7 @@ module Dodge.Item.HeldOffset (
|
||||
handHandleOrient,
|
||||
) where
|
||||
|
||||
import Dodge.DoubleTree
|
||||
import Dodge.Data.AimStance
|
||||
import Dodge.Data.ComposedItem
|
||||
import Dodge.Data.Creature
|
||||
@@ -55,7 +56,7 @@ handOrient cr = case cr ^. crStance . posture of
|
||||
|
||||
locOrient :: LocationLDT ItemLink OItem -> Creature -> Point3Q
|
||||
locOrient loc cr =
|
||||
handHandleOrient (fmap (\(x, y, _) -> (x, y)) loc) cr
|
||||
handHandleOrient (fmap (\(x, y, _) -> (x, y)) $ locToTop loc) cr
|
||||
`Q.comp` (loc ^. locLDT . ldtValue . _3)
|
||||
|
||||
heldItemOffset :: LocationLDT ItemLink CItem -> Creature -> Point3 -> Point3
|
||||
|
||||
Reference in New Issue
Block a user