Cleanup
This commit is contained in:
@@ -13,13 +13,11 @@ import Data.Aeson.TH
|
|||||||
import Dodge.Data.Material
|
import Dodge.Data.Material
|
||||||
import Dodge.Data.Wall.Structure
|
import Dodge.Data.Wall.Structure
|
||||||
import Geometry
|
import Geometry
|
||||||
import qualified Data.Set as S
|
|
||||||
|
|
||||||
data Wall = Wall
|
data Wall = Wall
|
||||||
{ _wlLine :: (Point2, Point2)
|
{ _wlLine :: (Point2, Point2)
|
||||||
, _wlID :: Int
|
, _wlID :: Int
|
||||||
, _wlOpacity :: Opacity
|
, _wlOpacity :: Opacity
|
||||||
-- , _wlPathFlag :: S.Set WallFlag
|
|
||||||
, _wlTouchThrough :: Bool
|
, _wlTouchThrough :: Bool
|
||||||
, _wlUnshadowed :: Bool
|
, _wlUnshadowed :: Bool
|
||||||
, _wlRotateTo :: Bool
|
, _wlRotateTo :: Bool
|
||||||
|
|||||||
@@ -9,18 +9,14 @@ module Dodge.Default.Wall (
|
|||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import qualified Data.Set as S
|
|
||||||
import Dodge.Data.Wall
|
import Dodge.Data.Wall
|
||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
|
|
||||||
{- Indestructible wall. -}
|
|
||||||
defaultWall :: Wall
|
defaultWall :: Wall
|
||||||
defaultWall =
|
defaultWall =
|
||||||
Wall
|
Wall
|
||||||
{ _wlLine = (V2 0 0, V2 50 0)
|
{ _wlLine = (V2 0 0, V2 50 0)
|
||||||
, _wlID = 0
|
, _wlID = 0
|
||||||
-- , _wlPathFlag =
|
|
||||||
-- S.fromList [minBound .. maxBound]
|
|
||||||
, _wlOpacity = Opaque 11
|
, _wlOpacity = Opaque 11
|
||||||
, _wlUnshadowed = True
|
, _wlUnshadowed = True
|
||||||
, _wlRotateTo = True
|
, _wlRotateTo = True
|
||||||
@@ -31,23 +27,13 @@ defaultWall =
|
|||||||
}
|
}
|
||||||
|
|
||||||
defaultDoorWall :: Wall
|
defaultDoorWall :: Wall
|
||||||
defaultDoorWall =
|
defaultDoorWall = defaultWall & wlMaterial .~ Metal & wlOpacity .~ Opaque 0
|
||||||
defaultWall
|
|
||||||
-- & wlPathFlag . at WallNotDestrucable .~ Nothing
|
|
||||||
& wlMaterial .~ Metal
|
|
||||||
& wlOpacity .~ Opaque 0
|
|
||||||
|
|
||||||
defaultAutoWall :: Wall
|
defaultAutoWall :: Wall
|
||||||
defaultAutoWall =
|
defaultAutoWall = defaultDoorWall & wlOpacity .~ Opaque 9
|
||||||
defaultDoorWall
|
|
||||||
& wlOpacity .~ Opaque 9
|
|
||||||
-- & wlPathFlag . at WallNotAutoOpen .~ Nothing
|
|
||||||
|
|
||||||
{- Indestructible see-through wall. -}
|
|
||||||
defaultCrystalWall :: Wall
|
defaultCrystalWall :: Wall
|
||||||
defaultCrystalWall =
|
defaultCrystalWall = defaultWall & wlOpacity .~ SeeThrough & wlMaterial .~ Crystal
|
||||||
defaultWall & wlOpacity .~ SeeThrough & wlMaterial .~ Crystal
|
|
||||||
-- & wlPathFlag . at WallBlockVisibility .~ Nothing
|
|
||||||
|
|
||||||
defaultMachineWall :: Wall
|
defaultMachineWall :: Wall
|
||||||
defaultMachineWall =
|
defaultMachineWall =
|
||||||
@@ -58,27 +44,14 @@ defaultMachineWall =
|
|||||||
, _wlMaterial = Metal
|
, _wlMaterial = Metal
|
||||||
, _wlTouchThrough = True
|
, _wlTouchThrough = True
|
||||||
}
|
}
|
||||||
-- & wlPathFlag . at WallBlockVisibility .~ Nothing
|
|
||||||
-- & wlPathFlag . at WallNotDestrucable .~ Nothing
|
|
||||||
|
|
||||||
defaultDirtWall :: Wall
|
defaultDirtWall :: Wall
|
||||||
defaultDirtWall =
|
defaultDirtWall =
|
||||||
defaultWall
|
defaultWall
|
||||||
{ _wlLine = (V2 0 0, V2 50 0)
|
{ _wlOpacity = Opaque 6
|
||||||
, _wlID = 0
|
|
||||||
, _wlOpacity = Opaque 6
|
|
||||||
, _wlRotateTo = False
|
, _wlRotateTo = False
|
||||||
, _wlMaterial = Dirt
|
, _wlMaterial = Dirt
|
||||||
}
|
}
|
||||||
-- & wlPathFlag . at WallNotDestrucable .~ Nothing
|
|
||||||
|
|
||||||
defaultWindow :: Wall
|
defaultWindow :: Wall
|
||||||
defaultWindow =
|
defaultWindow = defaultWall & wlOpacity .~ SeeThrough & wlMaterial .~ Glass
|
||||||
defaultWall
|
|
||||||
{ _wlLine = (V2 0 0, V2 50 0)
|
|
||||||
, _wlID = 0
|
|
||||||
, _wlOpacity = SeeThrough
|
|
||||||
, _wlMaterial = Glass
|
|
||||||
}
|
|
||||||
-- & wlPathFlag . at WallNotDestrucable .~ Nothing
|
|
||||||
-- & wlPathFlag . at WallBlockVisibility .~ Nothing
|
|
||||||
|
|||||||
+1
-12
@@ -126,12 +126,7 @@ pairsToIncGraph pairs =
|
|||||||
inodes = UV.generate (length ps) (ps !!)
|
inodes = UV.generate (length ps) (ps !!)
|
||||||
ps = Set.toList $ Set.map fst pairs <> Set.map snd pairs
|
ps = Set.toList $ Set.map fst pairs <> Set.map snd pairs
|
||||||
|
|
||||||
obstructPathsCrossing ::
|
obstructPathsCrossing :: S.Set EdgeObstacle -> Point2 -> Point2 -> World -> World
|
||||||
S.Set EdgeObstacle ->
|
|
||||||
Point2 ->
|
|
||||||
Point2 ->
|
|
||||||
World ->
|
|
||||||
World
|
|
||||||
obstructPathsCrossing obs s e w = w & cWorld . incGraph %~ updateincedges
|
obstructPathsCrossing obs s e w = w & cWorld . incGraph %~ updateincedges
|
||||||
where
|
where
|
||||||
updateincedge = flip $ updateEdge (S.union obs)
|
updateincedge = flip $ updateEdge (S.union obs)
|
||||||
@@ -139,12 +134,6 @@ obstructPathsCrossing obs s e w = w & cWorld . incGraph %~ updateincedges
|
|||||||
inces = filter inedgecrosses $ nearSeg peZoneSize _incEdgeZoning s e w
|
inces = filter inedgecrosses $ nearSeg peZoneSize _incEdgeZoning s e w
|
||||||
inedgecrosses (i, j) = isJust $ intersectSegSeg s e (f i) (f j)
|
inedgecrosses (i, j) = isJust $ intersectSegSeg s e (f i) (f j)
|
||||||
f i = w ^?! cWorld . incNode . ix i
|
f i = w ^?! cWorld . incNode . ix i
|
||||||
--es = Set.filter edgecrosses $ pesNearSeg sp ep w
|
|
||||||
-- edgecrosses (PathEdgeNodes _ _ pe) =
|
|
||||||
-- isJust $ intersectSegSeg s e (_peStart pe) (_peEnd pe)
|
|
||||||
-- updateedges gr = foldl' updateedge gr es
|
|
||||||
-- updateedge gr (PathEdgeNodes x y pe) =
|
|
||||||
-- insEdge (x, y, pe & peObstacles . at obstacletype ?~ ()) $ delEdge (x, y) gr
|
|
||||||
|
|
||||||
snapToGrid :: Set (Point2, Point2) -> Set (Point2, Point2)
|
snapToGrid :: Set (Point2, Point2) -> Set (Point2, Point2)
|
||||||
snapToGrid = Set.map (over each (fmap (fromIntegral . f)))
|
snapToGrid = Set.map (over each (fmap (fromIntegral . f)))
|
||||||
|
|||||||
@@ -1,21 +1,23 @@
|
|||||||
module Dodge.Placement.Instance.Wall
|
module Dodge.Placement.Instance.Wall (
|
||||||
(invisibleWall, crystalLine, blockLine, putBlockRect
|
invisibleWall,
|
||||||
,baseBlockPane
|
crystalLine,
|
||||||
,midWall
|
blockLine,
|
||||||
,windowLine
|
putBlockRect,
|
||||||
,putBlockN
|
baseBlockPane,
|
||||||
,putBlockV
|
midWall,
|
||||||
,heightWallPS
|
windowLine,
|
||||||
,replacePutID
|
putBlockN,
|
||||||
) where
|
putBlockV,
|
||||||
|
heightWallPS,
|
||||||
|
replacePutID,
|
||||||
|
) where
|
||||||
|
|
||||||
import qualified Data.Set as S
|
|
||||||
import Dodge.Material.Color
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Data.List
|
import Data.List
|
||||||
import Dodge.Data.GenWorld
|
import Dodge.Data.GenWorld
|
||||||
import Dodge.Default.Wall
|
import Dodge.Default.Wall
|
||||||
import Dodge.LevelGen.PlacementHelper
|
import Dodge.LevelGen.PlacementHelper
|
||||||
|
import Dodge.Material.Color
|
||||||
import Dodge.Placement.Instance.Block
|
import Dodge.Placement.Instance.Block
|
||||||
import Geometry
|
import Geometry
|
||||||
|
|
||||||
@@ -95,6 +97,7 @@ crystalLine a b = sps0 $ PutLineBlock defaultCrystalWall 7 a b
|
|||||||
|
|
||||||
baseBlockPane :: Wall
|
baseBlockPane :: Wall
|
||||||
baseBlockPane = defaultWall & wlOpacity .~ Opaque 17
|
baseBlockPane = defaultWall & wlOpacity .~ Opaque 17
|
||||||
|
|
||||||
-- & wlPathFlag .~ S.fromList [WallBlockVisibility, WallNotAutoOpen]
|
-- & wlPathFlag .~ S.fromList [WallBlockVisibility, WallNotAutoOpen]
|
||||||
|
|
||||||
-- TODO find home for this
|
-- TODO find home for this
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
--{-# LANGUAGE LambdaCase #-}
|
--{-# LANGUAGE LambdaCase #-}
|
||||||
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
|
--{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
|
||||||
|
|
||||||
{- | deals with placement of objects within the world
|
{- | deals with placement of objects within the world
|
||||||
after they have had their coordinates set by the layout
|
after they have had their coordinates set by the layout
|
||||||
@@ -174,13 +174,10 @@ placeChasm gw rid ps shiftps =
|
|||||||
-- where
|
-- where
|
||||||
-- (evaluatedType, g) = runState rgen (_randGen $ _gwWorld w)
|
-- (evaluatedType, g) = runState rgen (_randGen $ _gwWorld w)
|
||||||
|
|
||||||
-- this function is the reason for the warning suppression
|
|
||||||
-- remove the warning suppression if it changes
|
|
||||||
placeWallPoly :: [Point2] -> Wall -> World -> World
|
placeWallPoly :: [Point2] -> Wall -> World -> World
|
||||||
placeWallPoly qs wl w = foldl' (addPane wl) w pairs
|
placeWallPoly qs wl w
|
||||||
where
|
| (p : ps) <- orderPolygon qs = foldl' (addPane wl) w $ zip (ps ++ [p]) (p : ps)
|
||||||
(p : ps) = orderPolygon qs
|
| otherwise = error "tried to place wall poly with too few points"
|
||||||
pairs = zip (ps ++ [p]) (p : ps)
|
|
||||||
|
|
||||||
addPane :: Wall -> World -> (Point2, Point2) -> World
|
addPane :: Wall -> World -> (Point2, Point2) -> World
|
||||||
addPane wl w l =
|
addPane wl w l =
|
||||||
|
|||||||
@@ -179,8 +179,7 @@ airlockZ = do
|
|||||||
l2
|
l2
|
||||||
x2
|
x2
|
||||||
y2
|
y2
|
||||||
, -- outDoorps inDoorps
|
, sps0 $ PutWall (reverse $ rectNSWE 70 50 60 120) defaultWall
|
||||||
sps0 $ PutWall (reverse $ rectNSWE 70 50 60 120) defaultWall
|
|
||||||
, lighting
|
, lighting
|
||||||
]
|
]
|
||||||
, _rmBound =
|
, _rmBound =
|
||||||
|
|||||||
@@ -43,13 +43,12 @@ tutAnoTree = do
|
|||||||
foldMTRS
|
foldMTRS
|
||||||
[ tToBTree "TutStartRez" . return . cleatOnward <$> tutRezBox
|
[ tToBTree "TutStartRez" . return . cleatOnward <$> tutRezBox
|
||||||
, corDoor
|
, corDoor
|
||||||
, return $ tToBTree "cor" $ return $ cleatOnward corridor
|
-- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
||||||
, return $ tToBTree "cor" $ return $ cleatOnward corridor
|
-- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
||||||
, tToBTree "lastun" . return . cleatOnward <$> cenLasTur
|
-- , tToBTree "lastun" . return . cleatOnward <$> cenLasTur
|
||||||
, return $ tToBTree "cor" $ return $ cleatOnward corridor
|
-- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
||||||
, return $ tToBTree "cor" $ return $ cleatOnward corridor
|
-- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
||||||
, return $ tToBTree "cor" $ return $ cleatOnward corridor
|
-- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
||||||
|
|
||||||
, return $ tToBTree "cor" $ return $ cleatOnward corridor
|
, return $ tToBTree "cor" $ return $ cleatOnward corridor
|
||||||
-- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
-- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
||||||
-- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
-- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ updateEdgeWallObs :: World -> (Int, Int) -> World
|
|||||||
updateEdgeWallObs w (i, j) = fromMaybe w $ do
|
updateEdgeWallObs w (i, j) = fromMaybe w $ do
|
||||||
s <- getNodePos i w
|
s <- getNodePos i w
|
||||||
e <- getNodePos j w
|
e <- getNodePos j w
|
||||||
--let wlflags = foldMap (^. _2 . wlPathFlag) $ wlsHitUnsorted s e w
|
let wlflags = foldMap (^. _2 . to getWallPathing) $ wlsHitUnsorted s e w
|
||||||
let wlflags = foldMap (getWallPathing . (^. _2)) $ wlsHitUnsorted s e w
|
|
||||||
return $ w & cWorld . incGraph %~ updateEdge (f wlflags) (i, j)
|
return $ w & cWorld . incGraph %~ updateEdge (f wlflags) (i, j)
|
||||||
where
|
where
|
||||||
f x _ = S.map WallObstacle x
|
f x y = (S.map WallObstacle x) `S.union`
|
||||||
|
(y S.\\ (S.fromList $ map WallObstacle [minBound..maxBound]))
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ isFlyable :: Point2 -> Point2 -> World -> Bool
|
|||||||
{-# INLINE isFlyable #-}
|
{-# INLINE isFlyable #-}
|
||||||
isFlyable p1 p2 =
|
isFlyable p1 p2 =
|
||||||
not . (WallNotAutoOpen `S.member`)
|
not . (WallNotAutoOpen `S.member`)
|
||||||
. foldMap (getWallPathing . (^. _2))
|
. foldMap (^. _2 . to getWallPathing)
|
||||||
. wlsHitUnsorted p1 p2
|
. wlsHitUnsorted p1 p2
|
||||||
|
|
||||||
isWalkable :: Point2 -> Point2 -> World -> Bool
|
isWalkable :: Point2 -> Point2 -> World -> Bool
|
||||||
|
|||||||
Reference in New Issue
Block a user