Start to make wall flags/pathing interaction more sensible

This commit is contained in:
2025-10-23 11:35:24 +01:00
parent 9e6534b8f4
commit fc7c4d6468
18 changed files with 167 additions and 145 deletions
+9 -6
View File
@@ -5,6 +5,7 @@ module Dodge.Placement.Instance.Door (
switchDoor, -- not used 9/3/22
) where
import qualified Data.Set as S
import Color
import Control.Lens
import Dodge.Data.CreatureEffect
@@ -14,12 +15,13 @@ import Dodge.LevelGen.PlacementHelper
import Dodge.LevelGen.Switch
import Geometry
putDoubleDoor :: EdgeObstacle -> Wall -> WdBl -> Point2 -> Point2 -> Float -> Placement
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)
putDoubleDoorThen ::
EdgeObstacle ->
S.Set EdgeObstacle ->
Wall ->
WdBl ->
Float ->
@@ -37,7 +39,7 @@ putDoubleDoorThen eo wl cond soff a b speed cont =
half = 0.5 *.* (a +.+ b)
doorBetween ::
EdgeObstacle ->
S.Set EdgeObstacle ->
Wall ->
WdBl ->
Float ->
@@ -70,7 +72,7 @@ divideDoorPane mid wl cond soff speed ppairs g = case ppairs of
(p : ps) -> ptCont (adoor p) $ \pl -> Just $ divideDoorPane (_plMID pl) wl cond soff speed ps g
_ -> undefined
where
adoor (x, y) = PutSlideDr thedoor wl DoorObstacle soff x y
adoor (x, y) = PutSlideDr thedoor wl mempty soff x y
thedoor =
defaultDoor & drSpeed .~ speed & drTrigger .~ cond
& drPushedBy .~ maybe PushesItself PushedBy mid
@@ -81,7 +83,7 @@ putAutoDoor a b = Placement (PS 0 0) (PutCoord a) Nothing Nothing $ \_ apl ->
let x = w ^?! gwWorld . coordinates . ix (apl ^?! plMID . _Just)
y = w ^?! gwWorld . coordinates . ix (bpl ^?! plMID . _Just)
in Just $ putDoubleDoor
AutoDoorObstacle
(S.fromList [WallObstacle WallBlockVisibility])
defaultAutoWall
(WdBlCrFilterNearPoint 40 (0.5 *.* (x + y)) CrIsAnimate)
a
@@ -109,7 +111,8 @@ 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) DoorObstacle 1 a b
doorbetween btid a b = PutSlideDr thedoor (switchWallCol col)
(S.fromList (WallObstacle <$> [WallNotAutoOpen,WallBlockVisibility])) 1 a b
where
thedoor =
defaultDoor
+3 -2
View File
@@ -6,6 +6,7 @@
-}
module Dodge.Placement.PlaceSpot (placeSpot) where
import qualified Data.Set as S
import Color
import Control.Monad.State
import Data.Bifunctor
@@ -165,7 +166,7 @@ placeChasm gw rid ps shiftps =
& gwWorld %~ f
where
f w = foldl' g w (loopPairs shiftps)
g w (x,y) = fst $ obstructPathsCrossing ChasmObstacle x y w
g w (x,y) = fst $ obstructPathsCrossing (S.singleton ChasmObstacle) x y w
--evaluateRandPS
-- :: Int -> State StdGen PSType -> PlacementSpot -> GenWorld -> (Int, GenWorld)
@@ -185,7 +186,7 @@ placeWallPoly qs wl w = foldl' (addPane wl) w pairs
addPane :: Wall -> World -> (Point2, Point2) -> World
addPane wl w l =
w & plNew (cWorld . lWorld . walls) wlID (wl & wlLine .~ l)
& fst . uncurry (obstructPathsCrossing WallObstacle) l
& fst . uncurry (obstructPathsCrossing (S.fromList [WallObstacle WallNotAutoOpen])) l
mvProp :: Point2 -> Float -> Prop -> Prop
mvProp p a = (prRot +~ a) . (prPos %~ ((p +.+) . rotateV a))
+3 -1
View File
@@ -4,6 +4,7 @@ module Dodge.Placement.PlaceSpot.Block (
plLineBlock,
) where
import qualified Data.Set as S
import Control.Lens
import qualified Data.IntSet as IS
import Data.List
@@ -119,5 +120,6 @@ insertWalls blid wls w = w' & cWorld . lWorld . blocks . ix blid . blObstructs .
insertWall :: Wall -> World -> (World, [(Int,Int)])
insertWall wl =
uncurry (obstructPathsCrossing BlockObstacle) (_wlLine wl)
uncurry (obstructPathsCrossing (S.fromList [WallObstacle WallNotAutoOpen, WallObstacle WallBlockVisibility]))
(_wlLine wl)
. (cWorld . lWorld . walls . at (_wlID wl) ?~ wl)
+5 -3
View File
@@ -4,6 +4,7 @@ module Dodge.Placement.PlaceSpot.TriggerDoor (
updateDoorEdges,
) where
import qualified Data.Set as S
import Dodge.ShiftPoint
import Linear
import Dodge.Data.GenWorld
@@ -18,7 +19,7 @@ import Picture
plDoor ::
Color ->
EdgeObstacle ->
S.Set EdgeObstacle ->
-- | Opening condition
WdBl ->
-- | Door positions, closed to open.
@@ -51,7 +52,8 @@ plDoor col eo cond l p1 p2 gw = (drid, over gwWorld addWalls $ gw & gwWorld . cW
addWalls w' = foldl' (addDoorWall eo drid $ switchWallCol col) w' $ zip wlids
$ wlps' & each . each %~ shiftPointBy p1
addDoorWall :: EdgeObstacle -> Int -> Wall -> World -> (Int, (Point2, Point2)) -> World
addDoorWall :: S.Set EdgeObstacle
-> Int -> Wall -> World -> (Int, (Point2, Point2)) -> World
addDoorWall eo drid wl w (wlid, wlps) =
w'
& cWorld . lWorld . walls
@@ -80,7 +82,7 @@ updateDoorEdge _ w _ = w
plSlideDoor ::
Door ->
Wall ->
EdgeObstacle ->
S.Set EdgeObstacle ->
Float ->
Point2 ->
Point2 ->