Simplify grid/lattice creation

This commit is contained in:
2025-10-27 12:21:18 +00:00
parent 437f5d44d8
commit c88fc1c729
6 changed files with 138 additions and 222 deletions
+9 -13
View File
@@ -7,9 +7,10 @@ module Dodge.Room.Procedural (
centerVaultRoom,
combineRooms,
-- linksAndPath,
makeGrid,
-- makeGrid,
) where
import Grid
import Dodge.Door.PutSlideDoor
import Dodge.Default.Wall
import Control.Monad
@@ -37,16 +38,7 @@ import RandomHelp
-- This will need a cleanup, but it might change a bit first
{- A simple rectangular room with a light in the center.
Creates links and pathfinding graph. -}
roomRect ::
-- | Width
Float ->
-- | Height
Float ->
-- | Number of links on vertical walls
Int ->
-- | Number of links on horizontal walls
Int ->
Room
roomRect :: Float -> Float -> Int -> Int -> Room
roomRect x y xn yn =
defaultRoom
{ _rmPolys = [rectNSWE y 0 0 x]
@@ -82,8 +74,14 @@ roomRect x y xn yn =
}
}
where
xs = take (xn + 1) [0,xd..] & each +~ 20
ys = take (yn + 1) [0,yd..] & each +~ 20
yd = (y - 40) / fromIntegral yn
xd = (x - 40) / fromIntegral xn
pth = linksGridToPath lnks
$ latticeXsYs xs ys
--pth = linksGridToPath lnks
-- $ map (bimap (+.+ V2 20 20) (+.+ V2 20 20)) (makeGrid xd xn yd yn)
somelnks poffset ps a = zip (map (+.+ poffset) ps) (repeat a)
wlnks = somelnks (V2 0 20) (gridPoints 0 1 yd (yn + 1)) (pi / 2)
elnks = somelnks (V2 x 20) (gridPoints 0 1 yd (yn + 1)) (- pi / 2)
@@ -97,8 +95,6 @@ roomRect x y xn yn =
m edge edgefrom1 edgefrom2 =
zipWith (lnkBothAnd (OnEdge edge) edgefrom1 edgefrom2) [0 ..]
. zipCountDown
pth = linksGridToPath lnks
$ map (bimap (+.+ V2 20 20) (+.+ V2 20 20)) (makeGrid xd xn yd yn)
makeonpos (p, a) = RoomPos p 0 (S.singleton $ RoomPosOnGrid $ makerpedges a)
(NotLink True) mempty
makerpedges (a, b) =