Cleanup: broken pathfinding

This commit is contained in:
2021-11-16 18:05:47 +00:00
parent cb8cbe03a4
commit ebe9ad6b90
42 changed files with 491 additions and 301 deletions
+42 -6
View File
@@ -1,14 +1,18 @@
module Dodge.Room.Start where
import Dodge.LevelGen.Data
import Dodge.Data
import Dodge.Room.Door
import Dodge.Room.Link
import Dodge.Room.Procedural
import Dodge.Room.Foreground
import Dodge.Room.Furniture
import Dodge.Placements
import Dodge.Room.RoadBlock
import Dodge.Placement.Instance
import Dodge.Layout.Tree.Polymorphic
import Dodge.Item.Random
--import Dodge.LevelGen.Data
import Geometry.Data
import Padding
import Color
import Shape
@@ -20,17 +24,49 @@ import System.Random
rezBox :: Room
--rezBox = shiftRoomBy (V2 (-20) (-10),0) $ roomRect 40 20 1 1
rezBox = roomRect 40 40 1 1
& rmPmnts .~ [ spanColLightI (V3 0 0.5 0) 95 (V2 0 1) (V2 40 1) ]
rezBox = roomRect 40 60 1 1
& rmPmnts .~ [ spanColLightI (V3 0 0 0.5) 95 (V2 0 1) (V2 40 1) ]
rezInvBox :: Room
rezInvBox = roomRect 40 40 1 1
& rmPmnts .~ [ spanColLightI (V3 0 0.5 0) 95 (V2 0 39) (V2 40 39) ]
rezInvBox = roomRect 40 60 1 1
& rmPmnts .~ [ spanColLightI (V3 0 0 0.5) 95 (V2 0 59) (V2 40 59) ]
crRezBox :: Room
crRezBox = rezInvBox -- & rmPmnts %~ (sPS (V2 20 0) pi randC1 :)
wpRezBox :: Item -> Room
wpRezBox wp = rezInvBox & rmPmnts %~ (sPS (V2 15 30) 1 (PutFlIt wp) :)
startRoom :: RandomGen g => State g (Tree (Either Room Room))
startRoom = do
w <- state $ randomR (100,400)
h <- state $ randomR (100,200)
h <- state $ randomR (40,40)
theweapon <- randBlockBreakWeapon
let bottomEdgeTest (V2 _ y,_) = y < 1
bottomLeftTest (V2 x y,_) = y < 1 && x < 21
centralRoom <- filterSortOutLinksOn bottomEdgeTest ((\(V2 a b) -> (b,a)) . fst) <$>
(randomiseOutLinks =<< changeLinkTo bottomLeftTest
((roomRectAutoLinks w h) {_rmPmnts = []}))
let n = length $ filter bottomEdgeTest $ _rmLinks centralRoom
i <- state $ randomR (0,n-3)
j <- state $ randomR (i,n-2)
blcor <- blockedCorridor'
let rezrooms = map adddoor
$ insertAt i (wpRezBox theweapon)
$ insertAt j crRezBox
$ replicate (n-3) rezInvBox
return $ treeFromTrunk [Left rezBox
, Left door
]
(Node (Left centralRoom) (rezrooms ++ [onwardtree blcor]))
where
adddoor rm = treeFromPost [Left door] (Left rm)
onwardtree blcor = treeFromPost [Left door] (Right blcor)
randomRezBoxes :: RandomGen g => State g (Tree (Either Room Room))
randomRezBoxes = do
w <- state $ randomR (100,400)
h <- state $ randomR (40,40)
let bottomEdgeTest (V2 _ y,_) = y < 1
centralRoom <- randomiseOutLinks =<< changeLinkTo bottomEdgeTest
((roomRectAutoLinks w h) {_rmPmnts = []})