Add creature info display

This commit is contained in:
2022-04-10 23:07:11 +01:00
parent 0cc12f31ad
commit 12852a7670
5 changed files with 47 additions and 29 deletions
+28 -3
View File
@@ -2,7 +2,8 @@ module Dodge.Render.ShapePicture
( worldSPic
) where
import Dodge.Config.Data
--import Dodge.Debug.Picture
import Dodge.Render.InfoBox
import Dodge.Debug.Picture
import Dodge.Picture.SizeInvariant
import Dodge.Data
import Dodge.Base
@@ -22,8 +23,8 @@ import Geometry.ConvexPoly
import qualified Data.IntMap.Strict as IM -- Lazy?
import qualified Data.Map.Strict as M
--import Control.Lens
--import Data.Maybe
import Control.Lens
import Data.Maybe
-- TODO only filter out shapes outside the range of the furthest shown light source
worldSPic :: Configuration -> World -> SPic
@@ -56,6 +57,7 @@ extraPics cfig w = pictures (_decorations w)
<> viewBoundaries cfig w
<> viewClipBounds cfig w
<> drawPathing cfig w
<> drawCrInfo cfig w
testPic :: World -> Picture
testPic _ = []
@@ -103,6 +105,29 @@ drawPathing cfig w
where
dispInc (p,n) = setDepth 2 . uncurryV translate p . scale 0.1 0.1 $ text $ show n
gr = _pathGraph w
crDisplayInfo :: Configuration -> World -> Creature -> Maybe (Point2,[String])
crDisplayInfo cfig w cr
| crOnScreen = Just (_crPos cr, catMaybes
[fmap show $ ap ^? crGoal
,fmap show $ ap ^? crStrategy
,fmap show $ ap ^? crAction
,fmap show $ ap ^? crImpulse
]
)
| otherwise = Nothing
where
ap = _crActionPlan cr
crOnScreen = pointOnScreen cfig w $ _crPos cr
drawCrInfo :: Configuration -> World -> Picture
drawCrInfo cfig w
= setLayer FixedCoordLayer
$ renderInfoListsAt (2*hw - 200) 0 cfig w
$ mapMaybe (crDisplayInfo cfig w) $ IM.elems $ _creatures w
where
hw = halfWidth cfig
viewBoundaries :: Configuration -> World -> Picture
viewBoundaries cfig w
| _debug_view_boundaries cfig