From 3efd89fa34409004e0b38ebc199e7c074345747f Mon Sep 17 00:00:00 2001 From: justin Date: Sat, 2 Jul 2022 22:59:11 +0100 Subject: [PATCH] Correctly add all obstructed paths to doors --- src/Dodge/Placement/PlaceSpot/TriggerDoor.hs | 4 ++-- src/Dodge/Render/ShapePicture.hs | 25 +++++++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/Dodge/Placement/PlaceSpot/TriggerDoor.hs b/src/Dodge/Placement/PlaceSpot/TriggerDoor.hs index 0771c6518..7fedbc39a 100644 --- a/src/Dodge/Placement/PlaceSpot/TriggerDoor.hs +++ b/src/Dodge/Placement/PlaceSpot/TriggerDoor.hs @@ -14,11 +14,11 @@ import Picture import Geometry import qualified IntMapHelp as IM import Dodge.SoundLogic +import LensHelp --import Dodge.LevelGen.LevelStructure --import Data.Maybe import Data.List -import Control.Lens import qualified Data.IntSet as IS import qualified Data.Graph.Inductive as FGL import qualified Streaming.Prelude as S @@ -53,7 +53,7 @@ addDoorWall drid wl w (wlid,wlps) = w' , _wlID = wlid , _wlStructure = DoorPart drid } - & doors . ix drid . drObstructs .~ es + & doors . ix drid . drObstructs .++~ es where (w',es) = uncurry (obstructPathsCrossing DoorObstacle) wlps w -- TODO use vector instead of list, perhaps also memoisation of rectanglePairs diff --git a/src/Dodge/Render/ShapePicture.hs b/src/Dodge/Render/ShapePicture.hs index 5afac0aac..e61875fa2 100644 --- a/src/Dodge/Render/ShapePicture.hs +++ b/src/Dodge/Render/ShapePicture.hs @@ -149,15 +149,28 @@ drawInspectWalls w = foldMap (drawInspectWall w) (a,b) = _lLine w drawInspectWall :: World -> Wall -> Picture -drawInspectWall _ wl = setLayer DebugLayer $ +drawInspectWall w wl = setLayer DebugLayer $ color rose (thickLine 3 [a,b]) - <> foldMap (drawZone wlZoneSize) - (runIdentity $ S.toList_ $ zoneOfWall wlZoneSize wl) -- this won't work if wlZoneSize is not consistent +-- <> foldMap (drawZone wlZoneSize) +-- (runIdentity $ S.toList_ $ zoneOfWall wlZoneSize wl) -- this won't work if wlZoneSize is not consistent + <> foldMap (drawDoorPaths w) (wl ^? wlStructure . wsDoor) where (a,b) = _wlLine wl --- $ line [a,b] --- where --- (a,b) = _wSelect w + +drawDoorPaths :: World -> Int -> Picture +drawDoorPaths w drid = fromMaybe mempty $ do + paths <- w ^? doors . ix drid . drObstructs +-- path <- listToMaybe paths +-- undefined + return $ foldMap (drawPathEdge . (^. _3)) paths +-- return $ (drawPathEdge . (^. _3)) path + +drawPathEdge :: PathEdge -> Picture +drawPathEdge pe = setLayer DebugLayer $ color col $ arrow (_peStart pe) (_peEnd pe) + where + col = case _peObstacles pe of + pos | WallObstacle `Set.member` pos -> blue + | True -> red drawWorldSelect :: World -> Picture drawWorldSelect w = setLayer DebugLayer