Refactor crPos to be a V3
This commit is contained in:
@@ -24,6 +24,7 @@ module Dodge.Creature.Test (
|
||||
crSafeDistFromTarg,
|
||||
) where
|
||||
|
||||
import Linear
|
||||
import NewInt
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Dodge.Creature.Radius
|
||||
@@ -49,7 +50,7 @@ import Geometry
|
||||
-- return (x > 0)
|
||||
|
||||
crCanSeeCr :: Creature -> (World, Creature) -> Bool
|
||||
crCanSeeCr tcr (w, cr) = hasLOS (_crPos cr) (_crPos tcr) w
|
||||
crCanSeeCr tcr (w, cr) = hasLOS (cr ^. crPos . _xy) (tcr ^. crPos . _xy) w
|
||||
|
||||
--crCanSeeCrid :: Int -> (World, Creature) -> Bool
|
||||
--crCanSeeCrid tcid (w, cr) = fromMaybe False $ do
|
||||
@@ -71,7 +72,7 @@ crHasTargetLOS w cr = case cr ^? crIntention . targetCr . _Just of
|
||||
|
||||
crSafeDistFromTarg :: Float -> Creature -> Bool
|
||||
crSafeDistFromTarg d cr = case cr ^? crIntention . targetCr . _Just of
|
||||
Just tcr -> dist (_crPos cr) (_crPos tcr) > d
|
||||
Just tcr -> dist (cr ^. crPos . _xy) (tcr ^. crPos . _xy) > d
|
||||
Nothing -> True
|
||||
|
||||
crStratConMatches :: Strategy -> Creature -> Bool
|
||||
@@ -81,7 +82,7 @@ crStratConMatches strat cr = strat == _apStrategy (_crActionPlan cr)
|
||||
|
||||
crAwayFromPost :: Creature -> Bool
|
||||
crAwayFromPost cr = case find sentinelGoal . _apGoal $ _crActionPlan cr of
|
||||
Just (SentinelAt p _) -> dist p (_crPos cr) > 15
|
||||
Just (SentinelAt p _) -> dist p (cr ^. crPos . _xy) > 15
|
||||
_ -> False
|
||||
where
|
||||
sentinelGoal (SentinelAt _ _) = True
|
||||
@@ -108,8 +109,9 @@ crIsArmouredFrom m p cr = fromMaybe False $ do
|
||||
ittype <- m ^? ix itid . itType
|
||||
return $
|
||||
EQUIP FRONTARMOUR == ittype
|
||||
&& p /= _crOldPos cr
|
||||
&& angleVV (unitVectorAtAngle (_crDir cr + frontarmdirection)) (p -.- _crOldPos cr) < pi / 2
|
||||
&& p /= ( cr ^. crOldPos . _xy)
|
||||
&& angleVV (unitVectorAtAngle (_crDir cr + frontarmdirection))
|
||||
(p -.- (cr ^. crOldPos . _xy)) < pi / 2
|
||||
where
|
||||
-- even though angleVV can generate NaN, the comparison seems to deal with it
|
||||
frontarmdirection
|
||||
@@ -125,7 +127,7 @@ crIsArmouredFrom m p cr = fromMaybe False $ do
|
||||
--crNearSeg d p1 p2 cr = circOnSeg p1 p2 (_crPos cr) (_crRad cr + d)
|
||||
|
||||
crNearPoint :: Float -> Point2 -> Creature -> Bool
|
||||
crNearPoint d p cr = dist (_crPos cr) p < d + crRad (cr ^. crType)
|
||||
crNearPoint d p cr = dist (cr ^. crPos . _xy) p < d + crRad (cr ^. crType)
|
||||
|
||||
isAnimate :: Creature -> Bool
|
||||
{-# INLINE isAnimate #-}
|
||||
|
||||
Reference in New Issue
Block a user