Make _targetCr an Int id rather than a full creature
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user