Continue work on chasm rooms
This commit is contained in:
+23
-18
@@ -1,36 +1,41 @@
|
||||
module Dodge.Room.Ngon where
|
||||
|
||||
import RandomHelp
|
||||
import Data.List
|
||||
import qualified Data.Set as S
|
||||
--import Data.Maybe
|
||||
import Data.Tile
|
||||
import Dodge.Data.GenWorld
|
||||
import Dodge.Default.Room
|
||||
import Dodge.Placement.Instance
|
||||
import Dodge.PlacementSpot
|
||||
import Dodge.RoomLink
|
||||
import Geometry
|
||||
import RandomHelp
|
||||
import Tile
|
||||
|
||||
roomNgon :: RandomGen g => Int -> Float -> State g Room
|
||||
roomNgon n x = do
|
||||
thelight <-mntLightLnkCond $ resetPLUse $ rprBool $ const . isInLnk
|
||||
return defaultRoom
|
||||
{ _rmPolys = [poly]
|
||||
, _rmLinks = map toBothLnk lnks -- muout (init lnks) ++ muin[last lnks]
|
||||
, _rmPath = mempty -- TODO
|
||||
, _rmPmnts = [thelight]
|
||||
, _rmBound = [poly]
|
||||
, _rmFloor = Tiled [makeTileFromPoly poly 2]
|
||||
, _rmName = show n ++ "gon"
|
||||
}
|
||||
thelight <- mntLightLnkCond $ resetPLUse $ rprBool $ const . isInLnk
|
||||
return
|
||||
defaultRoom
|
||||
{ _rmPolys = [poly]
|
||||
, _rmLinks = map f lnks -- muout (init lnks) ++ muin[last lnks]
|
||||
, _rmPath = mempty -- TODO
|
||||
, _rmPmnts = [thelight]
|
||||
, _rmBound = [poly]
|
||||
, _rmFloor = Tiled [makeTileFromPoly poly 2]
|
||||
, _rmName = show n ++ "gon"
|
||||
}
|
||||
where
|
||||
rot = 2 * pi / fromIntegral n
|
||||
rots = map ((rot *) . fromIntegral) [0 .. n -1]
|
||||
poly = polyOrthDist n x
|
||||
-- mapMaybe
|
||||
-- (\(ra, rb) -> intersectLineLine (rotateV ra bl) (rotateV ra br) (rotateV rb bl) (rotateV rb br))
|
||||
-- $ loopPairs rots
|
||||
-- bl = V2 x x
|
||||
-- br = V2 (- x) x
|
||||
lnks = sortOn ((\(V2 a b) -> (negate b, a)) . fst) $ map (\r -> (rotateV r (V2 0 x), r)) rots
|
||||
lnks =
|
||||
sortOn ((\(V2 a b) -> (negate b, a)) . fst . snd)
|
||||
. zip [0 ..]
|
||||
$ map (\r -> (rotateV r (V2 0 x), r)) rots
|
||||
f (i, (p, a)) =
|
||||
RoomLink
|
||||
{ _rlType = S.fromList [OutLink, InLink, PolyEdge i]
|
||||
, _rlPos = p
|
||||
, _rlDir = a
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user