Delete cruft, add Reader monad to some internal ai
This commit is contained in:
@@ -3,11 +3,12 @@ module Dodge.Creature.AlertLevel
|
||||
where
|
||||
import Dodge.Data
|
||||
import Dodge.Creature.AlertLevel.Data
|
||||
import Dodge.Base.Collide
|
||||
import Dodge.Base
|
||||
--import Dodge.Base.Collide
|
||||
|
||||
import Control.Lens
|
||||
import Control.Monad.Reader
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
|
||||
{- | Ties together (currently) an awareness and attention update -}
|
||||
basicPerceptionUpdate
|
||||
:: [Int] -- ^ List of creature ids that may direct attention and awareness
|
||||
@@ -15,13 +16,20 @@ basicPerceptionUpdate
|
||||
-> Creature
|
||||
-> Creature
|
||||
basicPerceptionUpdate is w cr
|
||||
= basicAwarenessUpdate w $
|
||||
basicAttentionUpdate is w cr
|
||||
= basicAwarenessUpdate w $ basicAttentionUpdate is w cr
|
||||
|
||||
basicPerceptionUpdateR
|
||||
:: [Int] -- ^ List of creature ids that may direct attention and awareness
|
||||
-> Creature
|
||||
-> Reader World Creature
|
||||
basicPerceptionUpdateR is cr = reader $ \w ->
|
||||
basicAwarenessUpdate w $ basicAttentionUpdate is w cr
|
||||
|
||||
{- | Update a creatures awareness based upon the creatures current direction
|
||||
of attention -}
|
||||
basicAwarenessUpdate
|
||||
:: World -> Creature -> Creature
|
||||
basicAwarenessUpdate w cr = case _crAttentionDir cr of
|
||||
basicAwarenessUpdate _ cr = case _crAttentionDir cr of
|
||||
AttentiveTo is -> cr & crAwarenessLevel %~ updateAwareness is
|
||||
Fixated i -> cr & crAwarenessLevel
|
||||
%~ ( IM.insert i (Cognizant 100) . IM.mapMaybe decreaseAwareness)
|
||||
@@ -54,4 +62,4 @@ basicAttentionUpdate
|
||||
-> Creature
|
||||
-> Creature
|
||||
basicAttentionUpdate cids w cr = cr & crAttentionDir .~
|
||||
AttentiveTo (filter (\cid -> canSee (_crID cr) cid w) cids)
|
||||
AttentiveTo (forceList $ filter (\cid -> canSee (_crID cr) cid w) cids)
|
||||
|
||||
Reference in New Issue
Block a user