27 lines
731 B
Haskell
27 lines
731 B
Haskell
module Dodge.Creature.ChooseTarget
|
|
where
|
|
import Dodge.Data
|
|
import Dodge.Base
|
|
import Dodge.Base.Collide
|
|
import Dodge.Creature.Perception.Data
|
|
|
|
import Control.Lens
|
|
--import qualified Data.IntMap.Strict as IM
|
|
|
|
targetYouLOS :: Creature -> World -> Maybe Creature
|
|
{-# INLINE targetYouLOS #-}
|
|
targetYouLOS cr w
|
|
| hasLOS (_crPos cr) (_crPos $ you w) w = Just $ you w
|
|
| otherwise = Nothing
|
|
|
|
targetYouCognizant :: Creature -> World -> Maybe Creature
|
|
targetYouCognizant cr w
|
|
| hasLOS (_crPos cr) (_crPos $ you w) w
|
|
&& isCog (cr ^? crPerception . crAwarenessLevel . ix 0)
|
|
= Just $ you w
|
|
| otherwise = Nothing
|
|
where
|
|
isCog x = case x of
|
|
Just (Cognizant _) -> True
|
|
_ -> False
|