Simplify doors somewhat, unsure what to do about edge obstacles

This commit is contained in:
2025-10-22 23:09:09 +01:00
parent 0fd7ba46b5
commit 9e6534b8f4
7 changed files with 26 additions and 38 deletions
+3 -2
View File
@@ -7,6 +7,7 @@ module Dodge.Block.Debris (
makeDebrisDirected, makeDebrisDirected,
) where ) where
import qualified Data.IntMap.Strict as IM
import Dodge.ShiftPoint import Dodge.ShiftPoint
import Color import Color
import Data.Foldable import Data.Foldable
@@ -28,8 +29,8 @@ makeDoorDebris dr w = w & makeDebris mt col p
p2a = lerpP2A (dr ^. drZeroPos) (dr ^. drOnePos) (dr ^. drLerp) p2a = lerpP2A (dr ^. drZeroPos) (dr ^. drOnePos) (dr ^. drLerp)
p = centroid . fmap fst $ (dr ^. drFootPrint) & each . each %~ shiftPointBy p2a p = centroid . fmap fst $ (dr ^. drFootPrint) & each . each %~ shiftPointBy p2a
(mt, col) = fromMaybe (Stone, greyN 0.5) $ do (mt, col) = fromMaybe (Stone, greyN 0.5) $ do
wlids <- w ^? cWorld . lWorld . doors . ix (_drID dr) . drWallIDs wlids <- w ^? cWorld . lWorld . doors . ix (_drID dr) . drFootPrint
(wlid, _) <- IS.minView wlids ((wlid,_),_) <- IM.minViewWithKey wlids
wl <- w ^? cWorld . lWorld . walls . ix wlid wl <- w ^? cWorld . lWorld . walls . ix wlid
return (_wlMaterial wl, _wlColor wl) return (_wlMaterial wl, _wlColor wl)
-4
View File
@@ -11,7 +11,6 @@ module Dodge.Data.Door (
import Control.Lens import Control.Lens
import Data.Aeson import Data.Aeson
import Data.Aeson.TH import Data.Aeson.TH
import qualified Data.IntSet as IS
import Dodge.Data.MountedObject import Dodge.Data.MountedObject
import Dodge.Data.PathGraph import Dodge.Data.PathGraph
import Dodge.Data.WorldEffect import Dodge.Data.WorldEffect
@@ -29,7 +28,6 @@ data PushSource
data Door = Door data Door = Door
{ _drID :: Int { _drID :: Int
, _drWallIDs :: IS.IntSet
, _drTrigger :: WdBl , _drTrigger :: WdBl
, _drMech :: DrWdWd , _drMech :: DrWdWd
, _drZeroPos :: (Point2,Float) , _drZeroPos :: (Point2,Float)
@@ -41,8 +39,6 @@ data Door = Door
, _drPushedBy :: PushSource , _drPushedBy :: PushSource
, _drPushes :: Maybe Int , _drPushes :: Maybe Int
, _drMounts :: [MountedObject] , _drMounts :: [MountedObject]
-- , _drObstructs :: [(Int,Int)]
, _drObstacleType :: EdgeObstacle
} }
makeLenses ''Door makeLenses ''Door
+1 -3
View File
@@ -30,7 +30,7 @@ defaultDoor :: Door
defaultDoor = defaultDoor =
Door Door
{ _drID = 0 { _drID = 0
, _drWallIDs = mempty -- , _drWallIDs = mempty
-- , _drStatus = DoorClosed -- , _drStatus = DoorClosed
, _drTrigger = WdBlConst False , _drTrigger = WdBlConst False
, _drMech = DrWdId , _drMech = DrWdId
@@ -46,6 +46,4 @@ defaultDoor =
, _drPushedBy = PushesItself , _drPushedBy = PushesItself
, _drPushes = Nothing , _drPushes = Nothing
, _drMounts = mempty , _drMounts = mempty
-- , _drObstructs = mempty
, _drObstacleType = DoorObstacle
} }
+8 -11
View File
@@ -26,7 +26,7 @@ updateDoor dr w
doorLerp :: Door -> World -> (S.Set Int2,World) doorLerp :: Door -> World -> (S.Set Int2,World)
doorLerp dr w = fromMaybe (mempty,w) $ do doorLerp dr w = fromMaybe (mempty,w) $ do
x <- newlerp x <- newlerp
let ps = (dr ^. drFootPrint) & each . each %~ shiftPointBy (p2a x) let ps = wlposs x
is = foldMap (S.fromList . uncurry (zoneOfSeg peZoneSize)) ps is = foldMap (S.fromList . uncurry (zoneOfSeg peZoneSize)) ps
-- it seems possible that this will miss some paths: we add zones for the -- it seems possible that this will miss some paths: we add zones for the
-- old footprint. Seems unlikely, but a possible cause of pathfinding bugs -- old footprint. Seems unlikely, but a possible cause of pathfinding bugs
@@ -36,8 +36,7 @@ doorLerp dr w = fromMaybe (mempty,w) $ do
& cWorld . lWorld . doors . ix drid . drLerp .~ x) & cWorld . lWorld . doors . ix drid . drLerp .~ x)
where where
f = ifoldl' (flip . moveWallID) w . wlposs f = ifoldl' (flip . moveWallID) w . wlposs
p2a = lerpP2A (dr ^. drZeroPos) (dr ^. drOnePos) wlposs x = (dr ^. drFootPrint) & each . each %~ shiftPointBy (doDoorLerp dr x)
wlposs x = (dr ^. drFootPrint) & each . each %~ shiftPointBy (p2a x)
clerp = dr ^. drLerp clerp = dr ^. drLerp
newlerp newlerp
| toOpen && clerp < 1 = Just . min 1 $ clerp + speed | toOpen && clerp < 1 = Just . min 1 $ clerp + speed
@@ -48,9 +47,12 @@ doorLerp dr w = fromMaybe (mempty,w) $ do
drid = _drID dr drid = _drID dr
playSound x playSound x
| _drPushedBy dr == PushesItself = | _drPushedBy dr == PushesItself =
soundContinue (WallSound drid) (fst $ p2a x) slideDoorS (Just 1) soundContinue (WallSound drid) (fst $ doDoorLerp dr x) slideDoorS (Just 1)
| otherwise = id | otherwise = id
doDoorLerp :: Door -> Float -> Point2A
doDoorLerp dr = lerpP2A (dr ^. drZeroPos) (dr ^. drOnePos)
destroyDoor :: Door -> World -> (S.Set Int2, World) destroyDoor :: Door -> World -> (S.Set Int2, World)
destroyDoor dr w = destroyDoor dr w =
(is,w (is,w
@@ -62,14 +64,9 @@ destroyDoor dr w =
& stopPushing (_drPushes dr) & stopPushing (_drPushes dr)
& destroyMounts (_drMounts dr)) & destroyMounts (_drMounts dr))
where where
p2a = lerpP2A (dr ^. drZeroPos) (dr ^. drOnePos) (dr ^. drLerp)
ps = (dr ^. drFootPrint) & each . each %~ shiftPointBy p2a
is = foldMap (S.fromList . uncurry (zoneOfSeg peZoneSize)) ps is = foldMap (S.fromList . uncurry (zoneOfSeg peZoneSize)) ps
wlids = _drWallIDs dr ps = (dr ^. drFootPrint) & each . each %~ shiftPointBy (doDoorLerp dr (dr ^. drLerp))
--awl = _walls (_cWorld w) IM.! IS.findMin wlids wlids = IM.keysSet $ _drFootPrint dr
-- awl = w ^?! cWorld . lWorld . walls . ix (IS.findMin wlids)
-- pos = fst . _wlLine $ awl
-- ps = replicateM 25 (randInCirc 20) & evalState $ _randGen w
destroyMounts :: [MountedObject] -> World -> World destroyMounts :: [MountedObject] -> World -> World
destroyMounts mos w = foldl' (flip destroyMount) w mos destroyMounts mos w = foldl' (flip destroyMount) w mos
+2 -5
View File
@@ -7,7 +7,6 @@ module Dodge.Placement.PlaceSpot.TriggerDoor (
import Dodge.ShiftPoint import Dodge.ShiftPoint
import Linear import Linear
import Dodge.Data.GenWorld import Dodge.Data.GenWorld
import qualified Data.IntSet as IS
import Data.List import Data.List
import Dodge.Default.Door import Dodge.Default.Door
import Dodge.LevelGen.DoorPane import Dodge.LevelGen.DoorPane
@@ -36,14 +35,13 @@ plDoor col eo cond l p1 p2 gw = (drid, over gwWorld addWalls $ gw & gwWorld . cW
IM.insert drid $ IM.insert drid $
defaultDoor defaultDoor
{ _drID = drid { _drID = drid
, _drWallIDs = IS.fromList wlids -- , _drWallIDs = IS.fromList wlids
, _drTrigger = cond , _drTrigger = cond
, _drMech = DoorLerp , _drMech = DoorLerp
, _drZeroPos = p1 , _drZeroPos = p1
, _drOnePos = p2 , _drOnePos = p2
, _drLerp = 0 , _drLerp = 0
, _drFootPrint = IM.fromList . zip wlids $ wlps' , _drFootPrint = IM.fromList . zip wlids $ wlps'
, _drObstacleType = eo
, _drSpeed = 0.01 , _drSpeed = 0.01
} }
-- nsteps = length pss - 1 -- nsteps = length pss - 1
@@ -96,13 +94,12 @@ plSlideDoor dr wl eo shiftOffset a b gw =
IM.insert drid $ IM.insert drid $
dr dr
{ _drID = drid { _drID = drid
, _drWallIDs = IS.fromList wlids -- , _drWallIDs = IS.fromList wlids
, _drMech = DoorLerp , _drMech = DoorLerp
, _drZeroPos = (a, 0) , _drZeroPos = (a, 0)
, _drOnePos = (shiftLeft a, 0) , _drOnePos = (shiftLeft a, 0)
, _drLerp = 0 , _drLerp = 0
, _drFootPrint = IM.fromList $ zip wlids $ rectanglePairs 9 0 (b-a) , _drFootPrint = IM.fromList $ zip wlids $ rectanglePairs 9 0 (b-a)
, _drObstacleType = eo
, _drSpeed = 1 / distance a (shiftLeft a) , _drSpeed = 1 / distance a (shiftLeft a)
} }
addDoorWalls w' = foldl' (addDoorWall eo drid wl) w' $ zip wlids pairs addDoorWalls w' = foldl' (addDoorWall eo drid wl) w' $ zip wlids pairs
-1
View File
@@ -22,4 +22,3 @@ insertWallInZones = over wlZoning . zoneWall
deleteWallFromZones :: Wall -> World -> World deleteWallFromZones :: Wall -> World -> World
deleteWallFromZones = over wlZoning . deZoneWall deleteWallFromZones = over wlZoning . deZoneWall
+12 -12
View File
@@ -3125,8 +3125,8 @@ deleteWallID src/Dodge/Wall/Delete.hs 13;" f
deleteWallIDs src/Dodge/Wall/Delete.hs 28;" f deleteWallIDs src/Dodge/Wall/Delete.hs 28;" f
denormalEdges src/Polyhedra.hs 136;" f denormalEdges src/Polyhedra.hs 136;" f
destroyAllInvItems src/Dodge/Inventory.hs 53;" f destroyAllInvItems src/Dodge/Inventory.hs 53;" f
destroyBlock src/Dodge/Block.hs 51;" f destroyBlock src/Dodge/Block.hs 48;" f
destroyDoor src/Dodge/Block.hs 85;" f destroyDoor src/Dodge/DrWdWd.hs 56;" f
destroyInvItem src/Dodge/Inventory.hs 40;" f destroyInvItem src/Dodge/Inventory.hs 40;" f
destroyItem src/Dodge/Inventory.hs 62;" f destroyItem src/Dodge/Inventory.hs 62;" f
destroyLS src/Dodge/LightSource.hs 32;" f destroyLS src/Dodge/LightSource.hs 32;" f
@@ -3134,8 +3134,8 @@ destroyLSFlashAt src/Dodge/LightSource.hs 42;" f
destroyMachine src/Dodge/Machine/Destroy.hs 13;" f destroyMachine src/Dodge/Machine/Destroy.hs 13;" f
destroyMatS src/Dodge/Material/Sound.hs 7;" f destroyMatS src/Dodge/Material/Sound.hs 7;" f
destroyMcType src/Dodge/Machine/Destroy.hs 22;" f destroyMcType src/Dodge/Machine/Destroy.hs 22;" f
destroyMount src/Dodge/Block.hs 105;" f destroyMount src/Dodge/DrWdWd.hs 74;" f
destroyMounts src/Dodge/Block.hs 102;" f destroyMounts src/Dodge/DrWdWd.hs 71;" f
destroyProjectile src/Dodge/Projectile/Update.hs 108;" f destroyProjectile src/Dodge/Projectile/Update.hs 108;" f
detV src/Geometry/Vector.hs 94;" f detV src/Geometry/Vector.hs 94;" f
detector src/Dodge/Item/Held/Utility.hs 27;" f detector src/Dodge/Item/Held/Utility.hs 27;" f
@@ -3236,7 +3236,7 @@ doWorldEvents src/Dodge/Update.hs 447;" f
doWorldPos src/Dodge/WorldPos.hs 10;" f doWorldPos src/Dodge/WorldPos.hs 10;" f
door src/Dodge/Room/Door.hs 14;" f door src/Dodge/Room/Door.hs 14;" f
doorBetween src/Dodge/Placement/Instance/Door.hs 39;" f doorBetween src/Dodge/Placement/Instance/Door.hs 39;" f
doorLerp src/Dodge/DrWdWd.hs 20;" f doorLerp src/Dodge/DrWdWd.hs 26;" f
dotV src/Geometry/Vector.hs 76;" f dotV src/Geometry/Vector.hs 76;" f
dotV3 src/Geometry/Vector3D.hs 119;" f dotV3 src/Geometry/Vector3D.hs 119;" f
doubleCorridorBarrels src/Dodge/Room/Room.hs 276;" f doubleCorridorBarrels src/Dodge/Room/Room.hs 276;" f
@@ -3956,6 +3956,7 @@ leftRightCombine src/Dodge/Item/Grammar.hs 197;" f
leftWristPQ src/Dodge/Creature/HandPos.hs 81;" f leftWristPQ src/Dodge/Creature/HandPos.hs 81;" f
legsSPic src/Dodge/Item/Draw/SPic.hs 468;" f legsSPic src/Dodge/Item/Draw/SPic.hs 468;" f
lerpP2A src/Dodge/ShiftPoint.hs 14;" f lerpP2A src/Dodge/ShiftPoint.hs 14;" f
lerpdr src/Dodge/DrWdWd.hs 53;" f
liShape src/Dodge/Placement/Instance/LightSource.hs 111;" f liShape src/Dodge/Placement/Instance/LightSource.hs 111;" f
light src/Color.hs 104;" f light src/Color.hs 104;" f
lightSensByDoor src/Dodge/Room/LasTurret.hs 51;" f lightSensByDoor src/Dodge/Room/LasTurret.hs 51;" f
@@ -4110,10 +4111,9 @@ maxInvSlots src/Dodge/Inventory/CheckSlots.hs 30;" f
maxShowX src/Dodge/Combine/Graph.hs 48;" f maxShowX src/Dodge/Combine/Graph.hs 48;" f
maxViewDistance src/Dodge/Viewpoints.hs 26;" f maxViewDistance src/Dodge/Viewpoints.hs 26;" f
maybeBlockedPassage src/Dodge/Room/RezBox.hs 80;" f maybeBlockedPassage src/Dodge/Room/RezBox.hs 80;" f
maybeClearPath src/Dodge/Block.hs 71;" f maybeClearPath src/Dodge/Block.hs 68;" f
maybeClearPaths src/Dodge/Block.hs 68;" f maybeClearPaths src/Dodge/Block.hs 65;" f
maybeDestroyBlock src/Dodge/Wall/Damage.hs 32;" f maybeDestroyBlock src/Dodge/Wall/Damage.hs 32;" f
maybeDestroyDoor src/Dodge/Wall/Damage.hs 37;" f
maybeExitCombine src/Dodge/Update/Input/InGame.hs 562;" f maybeExitCombine src/Dodge/Update/Input/InGame.hs 562;" f
maybeOpenConsole src/Dodge/Update.hs 129;" f maybeOpenConsole src/Dodge/Update.hs 129;" f
maybeReadFile src/Dodge/LoadSeed.hs 10;" f maybeReadFile src/Dodge/LoadSeed.hs 10;" f
@@ -5029,7 +5029,7 @@ speedLegs src/Dodge/Item/Equipment.hs 90;" f
splashMenu src/Dodge/Menu.hs 33;" f splashMenu src/Dodge/Menu.hs 33;" f
splashMenuOptions src/Dodge/Menu.hs 38;" f splashMenuOptions src/Dodge/Menu.hs 38;" f
splashScreen src/Dodge/Initialisation.hs 10;" f splashScreen src/Dodge/Initialisation.hs 10;" f
splinterBlock src/Dodge/Block.hs 25;" f splinterBlock src/Dodge/Block.hs 22;" f
splitBezierquad src/Geometry/Bezier.hs 15;" f splitBezierquad src/Geometry/Bezier.hs 15;" f
splitExtra src/Justify.hs 21;" f splitExtra src/Justify.hs 21;" f
splitLookupTrie src/SimpleTrie.hs 39;" f splitLookupTrie src/SimpleTrie.hs 39;" f
@@ -5085,7 +5085,7 @@ stone4S src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 484;" f
stone5S src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 626;" f stone5S src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 626;" f
stopAllSounds src/Sound.hs 125;" f stopAllSounds src/Sound.hs 125;" f
stopBulletAt src/Dodge/Bullet.hs 199;" f stopBulletAt src/Dodge/Bullet.hs 199;" f
stopPushing src/Dodge/Block.hs 110;" f stopPushing src/Dodge/DrWdWd.hs 79;" f
stopSoundFrom src/Dodge/SoundLogic.hs 220;" f stopSoundFrom src/Dodge/SoundLogic.hs 220;" f
strFromEquipment src/Dodge/Creature/Statistics.hs 53;" f strFromEquipment src/Dodge/Creature/Statistics.hs 53;" f
strFromHeldItem src/Dodge/Creature/Statistics.hs 67;" f strFromHeldItem src/Dodge/Creature/Statistics.hs 67;" f
@@ -5330,7 +5330,7 @@ unpause src/Dodge/Menu.hs 212;" f
unsafeBlinkAction src/Dodge/Creature/Action/Blink.hs 57;" f unsafeBlinkAction src/Dodge/Creature/Action/Blink.hs 57;" f
unsafeBlinker src/Dodge/Item/Held/Utility.hs 33;" f unsafeBlinker src/Dodge/Item/Held/Utility.hs 33;" f
unsafeSwapKeys src/IntMapHelp.hs 75;" f unsafeSwapKeys src/IntMapHelp.hs 75;" f
unshadowBlock src/Dodge/Block.hs 38;" f unshadowBlock src/Dodge/Block.hs 35;" f
untilJust src/MonadHelp.hs 7;" f untilJust src/MonadHelp.hs 7;" f
untilJustCount src/MonadHelp.hs 14;" f untilJustCount src/MonadHelp.hs 14;" f
unusedOffPathAwayFromLink src/Dodge/PlacementSpot.hs 131;" f unusedOffPathAwayFromLink src/Dodge/PlacementSpot.hs 131;" f
@@ -5365,7 +5365,7 @@ updateDelayedEvents src/Dodge/Update.hs 909;" f
updateDisplaySections src/Dodge/DisplayInventory.hs 116;" f updateDisplaySections src/Dodge/DisplayInventory.hs 116;" f
updateDistortion src/Dodge/Distortion.hs 5;" f updateDistortion src/Dodge/Distortion.hs 5;" f
updateDistortions src/Dodge/Update.hs 577;" f updateDistortions src/Dodge/Update.hs 577;" f
updateDoor src/Dodge/DrWdWd.hs 15;" f updateDoor src/Dodge/DrWdWd.hs 20;" f
updateDoorEdge src/Dodge/Placement/PlaceSpot/TriggerDoor.hs 74;" f updateDoorEdge src/Dodge/Placement/PlaceSpot/TriggerDoor.hs 74;" f
updateDoorEdges src/Dodge/Placement/PlaceSpot/TriggerDoor.hs 71;" f updateDoorEdges src/Dodge/Placement/PlaceSpot/TriggerDoor.hs 71;" f
updateDoors src/Dodge/Update.hs 328;" f updateDoors src/Dodge/Update.hs 328;" f