Put config/targeting pictures in sensible places, tweak main loop

This commit is contained in:
2022-06-28 01:19:47 +01:00
parent 03b37c4e7b
commit f6d96ec92c
14 changed files with 148 additions and 154 deletions
+9 -74
View File
@@ -12,49 +12,25 @@ module Dodge.Creature.Picture
, basicCrCorpse
) where
import Dodge.Data
--import Dodge.Base
--import Dodge.Render.InfoBox
--import Dodge.Render.List
--import Dodge.Creature.AlertLevel.Data
--import Dodge.Picture.Layer
import Dodge.Clock
import Dodge.Creature.HandPos (translateToRightHand,translateToLeftHand)
import Dodge.Creature.Test
import Dodge.Damage
--import Dodge.Debug.Picture
import Picture
import Geometry
import Shape
import ShapePicture
import qualified Quaternion as Q
--import Geometry.Vector3D
import Control.Lens
import qualified Data.IntMap.Strict as IM
import qualified Data.Vector as V
basicCrPict :: Creature
-> Configuration
-> World
-> SPic
basicCrPict cr cfig w =
drawCrEquipment cr
<>
(basicCrShape cr
, pictures $
targetingPic ++
[ creatureDisplayText cfig w cr
--, tr . rotdir $ _spPicture $ drawEquipment cr
]
)
where
targetingPic = IM.elems $ IM.mapMaybe f $ _crInv cr
f it = fmap (\g -> g it cr cfig w) (it ^? itTargeting . tgDraw)
basicCrPict :: Creature -> SPic
basicCrPict cr = drawCrEquipment cr <> (basicCrShape cr , mempty)
drawCrEquipment :: Creature -> SPic
drawCrEquipment cr = uncurryV translateSPf (_crPos cr) (rotateSP (_crDir cr) $ drawEquipment cr)
shapeAtCrPos :: Shape -> Creature -> Configuration -> World -> SPic
shapeAtCrPos sh cr _ _ =
shapeAtCrPos :: Shape -> Creature -> SPic
shapeAtCrPos sh cr =
( uncurryV translateSHf (_crPos cr) $ rotateSH (_crDir cr) sh
, mempty
)
@@ -77,47 +53,6 @@ basicCrShape cr
rotdir = rotateSH (_crDir cr)
rotmdir = rotateSH (_crMvDir cr)
creatureDisplayText :: Configuration -> World -> Creature -> Picture
creatureDisplayText cfig w cr
| not (debugOn Cr_awareness cfig) = []
| otherwise
= 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']
]
) w cr
where
campos = _cameraViewFrom w
theScale = 0.15 / _cameraZoom w
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
--damageMod :: Creature -> Picture -> Picture
--damageMod cr pic = piercingMod $ bluntScale pic
-- where
@@ -285,13 +220,13 @@ drawEquipment cr = foldMap f (_crInv cr)
circLine :: Float -> Picture
circLine x = line [V2 0 0,V2 x 0]
picAtCrPos :: Picture -> Creature -> Configuration -> World -> SPic
picAtCrPos :: Picture -> Creature -> SPic
--{-# INLINE picAtCrPos #-}
picAtCrPos thePic cr _ _ = (,) emptySH $ tranRot (_crPos cr) (_crDir cr) thePic
picAtCrPos thePic cr = (,) emptySH $ tranRot (_crPos cr) (_crDir cr) thePic
picAtCrPosNoRot :: Picture -> Creature -> Configuration -> World -> SPic
picAtCrPosNoRot :: Picture -> Creature -> SPic
--{-# INLINE picAtCrPos #-}
picAtCrPosNoRot thePic cr _ _ = (,) emptySH $ uncurryV translate (_crPos cr) thePic
picAtCrPosNoRot thePic cr = (,) emptySH $ uncurryV translate (_crPos cr) thePic
basicCrCorpse :: Creature -> Corpse -> SPic
basicCrCorpse cr cp = noPic . tr . scaleSH (V3 crsize crsize crsize) $ mconcat
+45
View File
@@ -0,0 +1,45 @@
module Dodge.Creature.Picture.Awareness where
import Dodge.Data
import Dodge.Clock
import Picture
import Geometry
import qualified Data.Vector as V
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']
]
) w cr
where
campos = _cameraViewFrom w
theScale = 0.15 / _cameraZoom w
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