Files
loop/src/Dodge/Creature/Picture/Awareness.hs
T

53 lines
1.4 KiB
Haskell

module Dodge.Creature.Picture.Awareness where
import qualified Data.Vector as V
import Dodge.Clock
import Dodge.Data.World
import Geometry
import Picture
import Control.Lens
creatureDisplayText :: World -> Creature -> Picture
creatureDisplayText w cr =
setLayer DebugLayer
. setDepth 20
. translate x y
. color white
. rotate (0.5 * pi)
-- . rotate (argV v - 0.5 * pi)
. scale theScale theScale
. stackText
$ clockCycle
25
( V.fromList
[ \cr' -> [crDisplayVigilance cr']
, \cr' -> [crDisplayAwareness cr']
]
)
lw
cr
where
lw = w ^. cWorld . lWorld
campos = w ^. cWorld . lWorld . camPos . camViewFrom
theScale = 0.15 / (w ^. cWorld . lWorld . camPos . camZoom)
cpos = _crPos cr
v = cpos -.- campos
(V2 x y) = campos +.+ v +.+ _crRad cr *.* normalizeV v
crDisplayAwareness :: Creature -> String
crDisplayAwareness cr
| isSuspicious = "?"
| isCognizant = "!"
| otherwise = "."
where
imAwarenesses = _cpAwareness (_crPerception cr)
isSuspicious = any f imAwarenesses && not (null imAwarenesses)
isCognizant = any g imAwarenesses && not (null imAwarenesses)
f (Suspicious _) = True
f _ = False
g (Cognizant _) = True
g _ = False
crDisplayVigilance :: Creature -> String
crDisplayVigilance = show . _cpVigilance . _crPerception