Move configuration from world to universe

This commit is contained in:
2021-11-28 22:30:47 +00:00
parent 45ba120796
commit 8c5777a1af
29 changed files with 343 additions and 300 deletions
+21 -21
View File
@@ -24,33 +24,33 @@ import qualified Data.Map.Strict as M
--import Control.Lens
--import Data.Maybe
worldSPic :: World -> SPic
worldSPic w =
(extraShapes w, extraPics w)
worldSPic :: Configuration -> World -> SPic
worldSPic cfig w =
(extraShapes w, extraPics cfig w)
<> foldMap (dbArg _prDraw) (filtOn _pjPos _props)
<> foldMap (($ w) . dbArg _crPict) (filtOn _crPos _creatures)
<> foldMap ((($ w) . ($ cfig)) . dbArg _crPict) (filtOn _crPos _creatures)
<> foldMap floorItemSPic (filtOn _flItPos _floorItems)
<> foldMap btSPic (filtOn _btPos _buttons)
<> foldMap mcSPic (filtOn _mcPos _machines)
where
filtOn f g = IM.filter (pointIsClose . f) (g w)
pointIsClose p = dist camCen p < winSize
winSize = 30 + max (getWindowX w) (getWindowY w)
winSize = 30 + max (getWindowX cfig) (getWindowY cfig)
camCen = _cameraCenter w
extraShapes :: World -> Shape
extraShapes = _foregroundShape
extraPics :: World -> Picture
extraPics w = pictures (_decorations w)
extraPics :: Configuration -> World -> Picture
extraPics cfig w = pictures (_decorations w)
<> concatMapPic (dbArg _ptDraw) (_particles w)
<> concatMapPic (dbArg _lsPict) (_lightSources w)
<> testPic w
<> concatMapPic clDraw (_clouds w )
<> concatMapPic ppDraw (_pressPlates w )
<> soundPics w
<> viewBoundaries w
<> drawPathing w
<> soundPics cfig w
<> viewBoundaries cfig w
<> drawPathing cfig w
-- TODO remove duplicate!
testPic :: World -> Picture
@@ -71,13 +71,13 @@ mcSPic :: Machine -> SPic
mcSPic bt = uncurryV translateSPf (_mcPos bt)
$ rotateSP (_mcDir bt) (_mcDraw bt bt)
soundPics :: World -> Picture
soundPics w
| _show_sound (_config w) = pictures $ M.map (soundPic w) $ _playingSounds w
soundPics :: Configuration -> World -> Picture
soundPics cfig w
| _show_sound cfig = pictures $ M.map (soundPic cfig w) $ _playingSounds w
| otherwise = []
soundPic :: World -> Sound -> Picture
soundPic w s = fixedSizePicClampArrow 50 50 thePic p w
soundPic :: Configuration -> World -> Sound -> Picture
soundPic cfig w s = fixedSizePicClampArrow 50 50 thePic p cfig w
where
p = _soundPos s
thePic
@@ -89,9 +89,9 @@ soundPic w s = fixedSizePicClampArrow 50 50 thePic p w
theScale = 0.15 * f (_soundVolume s * 0.0001)
f x = 1 - 0.5 * (1 - x)
drawPathing :: World -> Picture
drawPathing w
| _debug_pathing (_config w)
drawPathing :: Configuration -> World -> Picture
drawPathing cfig w
| _debug_pathing cfig
= -- setLayer 5 $
(color green . pictures . map (flip thickLine 5 . tflat2) $ graphToEdges gr)
<> concatMap dispInc (graphToIncidence gr)
@@ -99,9 +99,9 @@ drawPathing w
where
dispInc (p,n) = setDepth 2 . uncurryV translate p . scale 0.1 0.1 $ text $ show n
gr = _pathGraph w
viewBoundaries :: World -> Picture
viewBoundaries w
| _debug_view_boundaries (_config w)
viewBoundaries :: Configuration -> World -> Picture
viewBoundaries cfig w
| _debug_view_boundaries cfig
= setLayer 5 $ color green (concatMap (polygonWire . _grBound) grs)
<> color yellow (concatMap (\q -> line [p,q]) $ farWallPoints p w)
| otherwise = []