Make _targetCr an Int id rather than a full creature

This commit is contained in:
2025-10-15 20:09:17 +01:00
parent 57ca53638a
commit 5e6ed1d793
13 changed files with 122 additions and 123 deletions
+9 -7
View File
@@ -66,14 +66,16 @@ crHasTarget :: Creature -> Bool
crHasTarget cr = isJust $ cr ^? crIntention . targetCr . _Just
crHasTargetLOS :: World -> Creature -> Bool
crHasTargetLOS w cr = case cr ^? crIntention . targetCr . _Just of
Just i -> crCanSeeCr i (w, cr)
Nothing -> False
crHasTargetLOS w cr = fromMaybe False $ do
i <- cr ^. crIntention . targetCr
tcr <- w ^? cWorld . lWorld . creatures . ix i
return $ crCanSeeCr tcr (w, cr)
crSafeDistFromTarg :: Float -> Creature -> Bool
crSafeDistFromTarg d cr = case cr ^? crIntention . targetCr . _Just of
Just tcr -> dist (cr ^. crPos . _xy) (tcr ^. crPos . _xy) > d
Nothing -> True
crSafeDistFromTarg :: World -> Float -> Creature -> Bool
crSafeDistFromTarg w d cr = fromMaybe True $ do
i <- cr ^? crIntention . targetCr . _Just
tcr <- w ^? cWorld . lWorld . creatures . ix i
return $ dist (cr ^. crPos . _xy) (tcr ^. crPos . _xy) > d
crStratConMatches :: Strategy -> Creature -> Bool
crStratConMatches strat cr = strat == _apStrategy (_crActionPlan cr)