Files
loop/src/Dodge/Creature/ChooseTarget.hs
T
2025-10-10 13:47:31 +01:00

24 lines
652 B
Haskell

module Dodge.Creature.ChooseTarget where
import Control.Lens
import Dodge.Base
import Dodge.Data.World
import Linear
targetYouLOS :: Creature -> World -> Maybe Creature
{-# INLINE targetYouLOS #-}
targetYouLOS cr w
| hasLOS (cr ^. crPos . _xy) ( you w ^. crPos . _xy) w = Just $ you w
| otherwise = Nothing
targetYouCognizant :: Creature -> World -> Maybe Creature
targetYouCognizant cr w
| hasLOS (cr ^. crPos . _xy) (you w ^. crPos . _xy) w
&& isCog (cr ^? crPerception . cpAwareness . ix 0) =
Just $ you w
| otherwise = Nothing
where
isCog x = case x of
Just (Cognizant _) -> True
_ -> False