Refactor crPos to be a V3

This commit is contained in:
2025-10-10 13:47:31 +01:00
parent 98ece551c7
commit 49fb982877
58 changed files with 375 additions and 307 deletions
+11 -10
View File
@@ -4,6 +4,7 @@ module Dodge.Creature.State (
invItemEffs,
) where
import Linear
import NewInt
import Control.Applicative
import Control.Monad
@@ -121,7 +122,7 @@ coolMachinePistol cr itm w
dosound s =
soundContinue
(CrWeaponSound (_crID cr) (fromIntegral $ _itID itm))
(_crPos cr)
(cr ^. crPos . _xy)
s
(Just 1)
d = pointerToItem itm . itParams
@@ -227,7 +228,7 @@ shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ d
x = 1
isammolink AmmoMagSF{} = True
isammolink _ = False
pos = _crPos cr + xyV3 (rotate3 cdir p)
pos = cr ^. crPos . _xy + xyV3 (rotate3 cdir p)
cdir = _crDir cr
itm = itmtree ^. dtValue . _1
pointittarg = cWorld . lWorld . items . ix itid . itTargeting
@@ -251,7 +252,7 @@ shineTorch cr loc = fromMaybe id $ do
x = 10
isammolink AmmoMagSF{} = True
isammolink _ = False
pos = _crPos cr `v2z` 0 + rotate3 cdir (p + Q.rotate q (V3 5 0 1.5))
pos = _crPos cr + rotate3 cdir (p + Q.rotate q (V3 5 0 1.5))
cdir = _crDir cr
-- this probably needs to be set to null when dropped as well?
@@ -295,18 +296,18 @@ setRBCreatureTargeting cr w ituse
| otherwise = ituse & itTgID .~ fmap _crID newtarg & updatePos & itTgActive .~ False
where
newtarg =
safeMinimumOn (dist mwp . _crPos)
. filter (canseepos . _crPos)
safeMinimumOn (dist mwp . (^. crPos . _xy))
. filter (canseepos . (^. crPos . _xy))
$ crsNearCirc mwp 40 w
canseepos p = hasLOS (_crPos cr) p w
canseepos p = hasLOS ((^. crPos . _xy) cr) p w
mwp = w ^. cWorld . lWorld . lAimPos
updatePos t' = t' & itTgPos .~ posFromMaybeID (_itTgID t')
posFromMaybeID Nothing = Nothing
posFromMaybeID (Just i) = w ^? cWorld . lWorld . creatures . ix i . crPos
posFromMaybeID Nothing = Nothing
posFromMaybeID (Just i) = w ^? cWorld . lWorld . creatures . ix i . crPos . _xy
canSeeTarget = fromMaybe False $ do
cid <- ituse ^? itTgID . _Just
cpos <- w ^? cWorld . lWorld . creatures . ix cid . crPos
Just $ hasLOS cpos (_crPos cr) w
cpos <- w ^? cWorld . lWorld . creatures . ix cid . crPos . _xy
Just $ hasLOS cpos ( cr ^. crPos . _xy) w
--isFrictionless :: Creature -> Bool
--isFrictionless cr = case cr ^? crStance . carriage of