Single source of truth for wall pathing
This commit is contained in:
@@ -16,8 +16,8 @@ decoratedBlock decf mat col h ps = PutBlock bl wl $ reverse ps
|
||||
& blHeight .~ h
|
||||
wl =
|
||||
defaultWall
|
||||
& wlPathFlag . at WallNotDestrucable .~ Nothing
|
||||
& wlPathFlag . at WallBlockVisibility .~ Nothing
|
||||
-- & wlPathFlag . at WallNotDestrucable .~ Nothing
|
||||
-- & wlPathFlag . at WallBlockVisibility .~ Nothing
|
||||
& wlRotateTo .~ False
|
||||
& wlOpacity .~ SeeAbove
|
||||
& wlMaterial .~ mat
|
||||
|
||||
@@ -5,23 +5,31 @@ module Dodge.Placement.Instance.Door (
|
||||
switchDoor, -- not used 9/3/22
|
||||
) where
|
||||
|
||||
import Dodge.Default.Wall
|
||||
import Dodge.Default.Door
|
||||
import qualified Data.Set as S
|
||||
import Color
|
||||
import Control.Lens
|
||||
import qualified Data.Set as S
|
||||
import Dodge.Data.CreatureEffect
|
||||
import Dodge.Data.GenWorld
|
||||
import Dodge.Default.Door
|
||||
import Dodge.Default.Wall
|
||||
import Dodge.LevelGen.PlacementHelper
|
||||
import Dodge.LevelGen.Switch
|
||||
import Geometry
|
||||
|
||||
putDoubleDoor :: S.Set EdgeObstacle
|
||||
-> Wall -> WdBl -> Point2 -> Point2 -> Float -> Placement
|
||||
putDoubleDoor eo wl cond a b speed =
|
||||
putDoubleDoorThen eo wl cond 1 a b speed (const $ const Nothing)
|
||||
putDoubleDoor ::
|
||||
Bool ->
|
||||
S.Set EdgeObstacle ->
|
||||
Wall ->
|
||||
WdBl ->
|
||||
Point2 ->
|
||||
Point2 ->
|
||||
Float ->
|
||||
Placement
|
||||
putDoubleDoor isauto eo wl cond a b speed =
|
||||
putDoubleDoorThen isauto eo wl cond 1 a b speed (const $ const Nothing)
|
||||
|
||||
putDoubleDoorThen ::
|
||||
Bool ->
|
||||
S.Set EdgeObstacle ->
|
||||
Wall ->
|
||||
WdBl ->
|
||||
@@ -31,15 +39,16 @@ putDoubleDoorThen ::
|
||||
Float ->
|
||||
(Placement -> Placement -> Maybe Placement) ->
|
||||
Placement
|
||||
putDoubleDoorThen eo wl cond soff a b speed cont =
|
||||
doorBetween eo wl cond soff a half speed $
|
||||
putDoubleDoorThen isauto eo wl cond soff a b speed cont =
|
||||
doorBetween isauto eo wl cond soff a half speed $
|
||||
\pl1 -> Just $
|
||||
doorBetween eo wl cond soff b half speed $
|
||||
doorBetween isauto eo wl cond soff b half speed $
|
||||
\pl2 -> cont pl1 pl2
|
||||
where
|
||||
half = 0.5 *.* (a +.+ b)
|
||||
|
||||
doorBetween ::
|
||||
Bool ->
|
||||
S.Set EdgeObstacle ->
|
||||
Wall ->
|
||||
WdBl ->
|
||||
@@ -49,9 +58,9 @@ doorBetween ::
|
||||
Float ->
|
||||
(Placement -> Maybe Placement) ->
|
||||
Placement
|
||||
doorBetween eo wl cond soff pa pb speed g = case divideLine 40 pa pb of
|
||||
[x, y] -> ptCont (PutSlideDr adoor wl eo soff x y) g
|
||||
(x : y : zs) -> divideDoorPane Nothing wl cond (soff - dist y pb) speed (zip (x : y : zs) (y : zs)) g
|
||||
doorBetween isauto eo wl cond soff pa pb speed g = case divideLine 40 pa pb of
|
||||
[x, y] -> ptCont (PutSlideDr isauto adoor wl eo soff x y) g
|
||||
(x : y : zs) -> divideDoorPane isauto Nothing wl cond (soff - dist y pb) speed (zip (x : y : zs) (y : zs)) g
|
||||
_ -> undefined
|
||||
where
|
||||
adoor =
|
||||
@@ -60,6 +69,7 @@ doorBetween eo wl cond soff pa pb speed g = case divideLine 40 pa pb of
|
||||
& drUpdate . drLerpSpeed .~ speed
|
||||
|
||||
divideDoorPane ::
|
||||
Bool ->
|
||||
Maybe Int ->
|
||||
Wall ->
|
||||
WdBl ->
|
||||
@@ -68,28 +78,31 @@ divideDoorPane ::
|
||||
[(Point2, Point2)] ->
|
||||
(Placement -> Maybe Placement) ->
|
||||
Placement
|
||||
divideDoorPane mid wl cond soff speed ppairs g = case ppairs of
|
||||
divideDoorPane isauto mid wl cond soff speed ppairs g = case ppairs of
|
||||
[p] -> ptCont (adoor p) g
|
||||
(p : ps) -> ptCont (adoor p) $ \pl -> Just $ divideDoorPane (_plMID pl) wl cond soff speed ps g
|
||||
(p : ps) -> ptCont (adoor p) $ \pl -> Just $ divideDoorPane isauto (_plMID pl) wl cond soff speed ps g
|
||||
_ -> undefined
|
||||
where
|
||||
adoor (x, y) = PutSlideDr thedoor wl mempty soff x y
|
||||
adoor (x, y) = PutSlideDr isauto thedoor wl mempty soff x y
|
||||
thedoor =
|
||||
defaultDoor & drUpdate . drLerpSpeed .~ speed & drTrigger .~ cond
|
||||
& drPushedBy .~ maybe PushesItself PushedBy mid
|
||||
|
||||
putAutoDoor :: Point2 -> Point2 -> Placement
|
||||
putAutoDoor a b = Placement (PS 0 0) (PutCoord a) Nothing Nothing $ \_ apl ->
|
||||
Just $ Placement (PS 0 0) (PutCoord b) Nothing Nothing $ \w bpl ->
|
||||
let x = w ^?! gwWorld . coordinates . ix (apl ^?! plMID . _Just)
|
||||
y = w ^?! gwWorld . coordinates . ix (bpl ^?! plMID . _Just)
|
||||
in Just $ putDoubleDoor
|
||||
(S.fromList [WallObstacle WallBlockVisibility])
|
||||
defaultAutoWall
|
||||
(WdBlCrFilterNearPoint 40 (0.5 *.* (x + y)) CrIsAnimate)
|
||||
a
|
||||
b
|
||||
3
|
||||
Just $
|
||||
Placement (PS 0 0) (PutCoord b) Nothing Nothing $ \w bpl ->
|
||||
let x = w ^?! gwWorld . coordinates . ix (apl ^?! plMID . _Just)
|
||||
y = w ^?! gwWorld . coordinates . ix (bpl ^?! plMID . _Just)
|
||||
in Just $
|
||||
putDoubleDoor True
|
||||
(S.fromList [WallObstacle WallBlockVisibility])
|
||||
defaultAutoWall
|
||||
(WdBlCrFilterNearPoint 40 (0.5 *.* (x + y)) CrIsAnimate)
|
||||
a
|
||||
b
|
||||
3
|
||||
|
||||
--putAutoDoor :: Point2 -> Point2 -> Placement
|
||||
--putAutoDoor a b = PlacementUsingPos (addZ 0 a) $
|
||||
-- \az -> PlacementUsingPos (addZ 0 b) $
|
||||
@@ -112,9 +125,15 @@ switchDoor btpos btrot dra drb col = pContID
|
||||
jsps0J (doorbetween btid dra drc) $
|
||||
sps0 (doorbetween btid drb drc)
|
||||
where
|
||||
--doorbetween btid a b = PutSlideDr thedoor (switchWallCol col)
|
||||
doorbetween btid a b = PutSlideDr thedoor defaultDoorWall
|
||||
(S.fromList (WallObstacle <$> [WallNotAutoOpen,WallBlockVisibility])) 1 a b
|
||||
--doorbetween btid a b = PutSlideDr thedoor (switchWallCol col)
|
||||
doorbetween btid a b =
|
||||
PutSlideDr False
|
||||
thedoor
|
||||
defaultDoorWall
|
||||
(S.fromList (WallObstacle <$> [WallNotAutoOpen, WallBlockVisibility]))
|
||||
1
|
||||
a
|
||||
b
|
||||
where
|
||||
thedoor =
|
||||
defaultDoor
|
||||
|
||||
@@ -95,7 +95,7 @@ crystalLine a b = sps0 $ PutLineBlock defaultCrystalWall 7 a b
|
||||
|
||||
baseBlockPane :: Wall
|
||||
baseBlockPane = defaultWall & wlOpacity .~ Opaque 17
|
||||
& wlPathFlag .~ S.fromList [WallBlockVisibility, WallNotAutoOpen]
|
||||
-- & wlPathFlag .~ S.fromList [WallBlockVisibility, WallNotAutoOpen]
|
||||
|
||||
-- TODO find home for this
|
||||
{- Replaces instances of a given 'PutID' with 'PSType's drawn from a list. -}
|
||||
|
||||
@@ -134,10 +134,10 @@ placeSpotID rid ps pt w = case pt of
|
||||
PutMachine pps mc mitm -> plMachine (map doShift pps) mc mitm p rot w
|
||||
PutLS ls -> plNewUpID (gwWorld . cWorld . lWorld . lightSources) lsID (mvLS p' rot ls) w
|
||||
RandPS _ -> error "RandPS should not be reachable here" --evaluateRandPS rid rgn ps w
|
||||
PutDoor eo f l p1 p2 -> plDoor eo f l (pashift p1) (pashift p2) w
|
||||
PutDoor isauto eo f l p1 p2 -> plDoor isauto eo f l (pashift p1) (pashift p2) w
|
||||
PutCoord cp -> plNewID (gwWorld . coordinates) (doShift cp) w
|
||||
PutSlideDr wl dr eo off a b ->
|
||||
plSlideDoor wl dr eo off (doShift a) (doShift b) w
|
||||
PutSlideDr isauto wl dr eo off a b ->
|
||||
plSlideDoor isauto wl dr eo off (doShift a) (doShift b) w
|
||||
PutBlock bl wl ps' ->
|
||||
plBlock
|
||||
(map doShift ps')
|
||||
|
||||
@@ -4,6 +4,7 @@ module Dodge.Placement.PlaceSpot.Block (
|
||||
plLineBlock,
|
||||
) where
|
||||
|
||||
import Dodge.Wall.Pathing
|
||||
import qualified Data.Set as S
|
||||
import Control.Lens
|
||||
import qualified Data.IntSet as IS
|
||||
@@ -115,6 +116,6 @@ insertWalls wls w = foldl' (flip insertWall) w wls
|
||||
|
||||
insertWall :: Wall -> World -> World
|
||||
insertWall wl =
|
||||
uncurry (obstructPathsCrossing (S.map WallObstacle $ wl ^. wlPathFlag))
|
||||
uncurry (obstructPathsCrossing (S.map WallObstacle $ getWallPathing wl))
|
||||
(_wlLine wl)
|
||||
. (cWorld . lWorld . walls . at (_wlID wl) ?~ wl)
|
||||
|
||||
@@ -4,20 +4,21 @@ module Dodge.Placement.PlaceSpot.TriggerDoor (
|
||||
updateDoorEdges,
|
||||
) where
|
||||
|
||||
import Dodge.Default.Wall
|
||||
import qualified Data.Set as S
|
||||
import Dodge.ShiftPoint
|
||||
import Linear
|
||||
import Dodge.Data.GenWorld
|
||||
import Data.List
|
||||
import qualified Data.Set as S
|
||||
import Dodge.Data.GenWorld
|
||||
import Dodge.Default.Door
|
||||
import Dodge.Default.Wall
|
||||
import Dodge.LevelGen.DoorPane
|
||||
import Dodge.Path
|
||||
import Dodge.ShiftPoint
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
import Linear
|
||||
|
||||
plDoor ::
|
||||
Bool ->
|
||||
S.Set EdgeObstacle ->
|
||||
-- | Opening condition
|
||||
WdBl ->
|
||||
@@ -28,7 +29,7 @@ plDoor ::
|
||||
Point2A ->
|
||||
GenWorld ->
|
||||
(Int, GenWorld)
|
||||
plDoor eo cond l p1 p2 gw = (drid, over gwWorld addWalls $ gw & gwWorld . cWorld . lWorld . doors %~ addDoor) -- carefull with the ordering of addWalls
|
||||
plDoor isauto eo cond l p1 p2 gw = (drid, over gwWorld addWalls $ gw & gwWorld . cWorld . lWorld . doors %~ addDoor) -- carefull with the ordering of addWalls
|
||||
where
|
||||
drid = IM.newKey $ _doors (_lWorld (_cWorld $ _gwWorld gw))
|
||||
addDoor =
|
||||
@@ -45,12 +46,20 @@ plDoor eo cond l p1 p2 gw = (drid, over gwWorld addWalls $ gw & gwWorld . cWorld
|
||||
wlids = take 4 [IM.newKey $ _walls (_lWorld (_cWorld $ _gwWorld gw)) ..]
|
||||
wlps' = rectanglePairs 9 0 (V2 l 0)
|
||||
--addWalls w' = foldl' (addDoorWall eo drid $ switchWallCol col) w' $ zip wlids
|
||||
addWalls w' = foldl' (addDoorWall eo drid defaultDoorWall) w' $ zip wlids
|
||||
$ wlps' & each . each %~ shiftPointBy p1
|
||||
addWalls w' =
|
||||
foldl' (addDoorWall isauto eo drid defaultDoorWall) w' $
|
||||
zip wlids $
|
||||
wlps' & each . each %~ shiftPointBy p1
|
||||
|
||||
addDoorWall :: S.Set EdgeObstacle
|
||||
-> Int -> Wall -> World -> (Int, (Point2, Point2)) -> World
|
||||
addDoorWall eo drid wl w (wlid, wlps) =
|
||||
addDoorWall ::
|
||||
Bool ->
|
||||
S.Set EdgeObstacle ->
|
||||
Int ->
|
||||
Wall ->
|
||||
World ->
|
||||
(Int, (Point2, Point2)) ->
|
||||
World
|
||||
addDoorWall isauto eo drid wl w (wlid, wlps) =
|
||||
w'
|
||||
& cWorld . lWorld . walls
|
||||
%~ IM.insert
|
||||
@@ -58,23 +67,25 @@ addDoorWall eo drid wl w (wlid, wlps) =
|
||||
wl
|
||||
{ _wlLine = wlps
|
||||
, _wlID = wlid
|
||||
, _wlStructure = DoorPart drid
|
||||
, _wlStructure = DoorPart drid isauto
|
||||
}
|
||||
where
|
||||
w' = uncurry (obstructPathsCrossing eo) wlps w
|
||||
|
||||
updateDoorEdges :: EdgeObstacle -> [(Int,Int)] -> World -> World
|
||||
updateDoorEdges :: EdgeObstacle -> [(Int, Int)] -> World -> World
|
||||
updateDoorEdges eo es w = foldl' (updateDoorEdge eo) w es
|
||||
|
||||
updateDoorEdge :: EdgeObstacle -> World -> (Int,Int) -> World
|
||||
updateDoorEdge :: EdgeObstacle -> World -> (Int, Int) -> World
|
||||
--updateDoorEdge eo w (i,j) = w
|
||||
updateDoorEdge _ w _ = w
|
||||
|
||||
-- | not . null $ overlapSegWalls (_peStart pe) (_peEnd pe) $ wlsNearSeg (_peStart pe) (_peEnd pe) w =
|
||||
-- w & cWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles . at eo ?~ ()) . FGL.delEdge (x, y)
|
||||
-- | otherwise =
|
||||
-- w & cWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles . at eo .~ Nothing) . FGL.delEdge (x, y)
|
||||
|
||||
plSlideDoor ::
|
||||
Bool ->
|
||||
Door ->
|
||||
Wall ->
|
||||
S.Set EdgeObstacle ->
|
||||
@@ -83,7 +94,7 @@ plSlideDoor ::
|
||||
Point2 ->
|
||||
GenWorld ->
|
||||
(Int, GenWorld)
|
||||
plSlideDoor dr wl eo shiftOffset a b gw =
|
||||
plSlideDoor isauto dr wl eo shiftOffset a b gw =
|
||||
(drid, over gwWorld addDoorWalls $ gw & gwWorld . cWorld . lWorld . doors %~ addDoor)
|
||||
where
|
||||
drid = IM.newKey $ _doors (_lWorld (_cWorld $ _gwWorld gw))
|
||||
@@ -95,9 +106,9 @@ plSlideDoor dr wl eo shiftOffset a b gw =
|
||||
, _drZeroPos = (a, 0)
|
||||
, _drOnePos = (shiftLeft a, 0)
|
||||
, _drLerp = 0
|
||||
, _drFootPrint = IM.fromList $ zip wlids $ rectanglePairs 9 0 (b-a)
|
||||
, _drFootPrint = IM.fromList $ zip wlids $ rectanglePairs 9 0 (b - a)
|
||||
}
|
||||
addDoorWalls w' = foldl' (addDoorWall eo drid wl) w' $ zip wlids pairs
|
||||
addDoorWalls w' = foldl' (addDoorWall isauto eo drid wl) w' $ zip wlids pairs
|
||||
pairs = rectanglePairs 9 a b
|
||||
shiftLeft = (+.+ (a -.- b +.+ shiftOffset *.* normalizeV (b -.- a)))
|
||||
wlids = take 4 [IM.newKey $ _walls (_lWorld (_cWorld $ _gwWorld gw)) ..]
|
||||
|
||||
Reference in New Issue
Block a user