Add Read/Show instance for Creature
This commit is contained in:
@@ -5,6 +5,7 @@ module Dodge.Creature.Perception
|
||||
-- , newSounds
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.FloatFunction
|
||||
import Dodge.Creature.Vocalization
|
||||
import Dodge.Base.Collide
|
||||
import RandomHelp
|
||||
@@ -45,9 +46,10 @@ basicAwarenessUpdate cr = case _cpAttention $ _crPerception cr of
|
||||
oldAwareness = _cpAwareness $ _crPerception cr
|
||||
newAwareness = (IM.mapMaybe decreaseAwareness . IM.unionWith combineAwareness is) oldAwareness
|
||||
becomesCognizant = any isCognizant $ IM.unionWith cogRaised oldAwareness newAwareness
|
||||
thejitter = do
|
||||
p <- randInCirc 1
|
||||
return $ Move p
|
||||
thejitter = RandImpulseCircMove 1
|
||||
--do
|
||||
--p <- randInCirc 1
|
||||
--return $ Move p
|
||||
maybeBark
|
||||
| becomesCognizant = case vocalizationTest cr of
|
||||
Just sid -> crActionPlan . apAction .~
|
||||
@@ -77,9 +79,10 @@ chaseCritAwarenessUpdate w cr = case _cpAttention $ _crPerception cr of
|
||||
newAwareness = (IM.mapMaybe decreaseAwareness . IM.unionWith combineAwareness is) oldAwareness
|
||||
becomesCognizant = any isCognizant $ IM.unionWith cogRaised oldAwareness newAwareness
|
||||
--randBool = takeOne [False,True] & evalState $ _randGen w
|
||||
thejitter = do
|
||||
p <- randInCirc 2
|
||||
return $ Move p
|
||||
thejitter = RandImpulseCircMove 2
|
||||
-- do
|
||||
-- p <- randInCirc 2
|
||||
-- return $ Move p
|
||||
maybeBark
|
||||
| becomesCognizant -- && randBool
|
||||
&& cr ^? crVocalization . vcCoolDown == Just 0
|
||||
@@ -133,7 +136,7 @@ newExtraAwareness
|
||||
-> Maybe Awareness
|
||||
newExtraAwareness cr w cid
|
||||
| not $ canSeeIndirect (_crID cr) cid w = Nothing
|
||||
| otherwise = Just . Suspicious $ _viFOV vi ang * _viDist vi d * awakeLevelPerception cr
|
||||
| otherwise = Just . Suspicious $ doFloatFloat (_viFOV vi) ang * doFloatFloat (_viDist vi) d * awakeLevelPerception cr
|
||||
where
|
||||
vi = _cpVision $ _crPerception cr
|
||||
tpos = _crPos $ _creatures w IM.! cid
|
||||
@@ -168,7 +171,7 @@ rememberSounds w cr = cr
|
||||
-- TODO work out correct form for sounds passing through walls
|
||||
soundIsClose :: World -> Creature -> (Point2,Float) -> Bool
|
||||
soundIsClose w cr (pos,vol) = dist cpos pos < 2000
|
||||
&& vol > (_auDist . _cpAudition $ _crPerception cr) (dist pos cpos)
|
||||
&& vol > doFloatFloat (_auDist . _cpAudition $ _crPerception cr) (dist pos cpos)
|
||||
&& hasLOS cpos pos w
|
||||
where
|
||||
cpos = _crPos cr
|
||||
|
||||
Reference in New Issue
Block a user