Hack solution to path graph space leak: evaluate all edge obstacles

This commit is contained in:
2025-10-26 11:38:22 +00:00
parent b8536e2929
commit c55c3e874d
9 changed files with 19608 additions and 399694 deletions
+15 -21
View File
@@ -1,47 +1,41 @@
module Dodge.Update.WallDamage (updateWallDamages, updateEdgesWall) where
import Dodge.Wall.Pathing
import Geometry.Data
import Control.Lens
import Data.Foldable
import Data.Maybe
import qualified Data.Set as S
import Dodge.Data.World
import Dodge.Path
import Dodge.Wall.Damage
import Dodge.Wall.Pathing
import Dodge.WorldEvent.ThingsHit
import Dodge.Zoning.Base
import Geometry.Data
import qualified IntMapHelp as IM
updateWallDamages :: World -> World
updateWallDamages w =
let (is, w') =
IM.foldlWithKey' f (mempty, w) (w ^. cWorld . lWorld . wallDamages)
in updateEdgesWall is
w'
& cWorld . lWorld . wallDamages .~ IM.empty
let (is, w') = IM.foldlWithKey' f (mempty, w) (w ^. cWorld . lWorld . wallDamages)
in updateEdgesWall is w' & cWorld . lWorld . wallDamages .~ IM.empty
where
f isw k dams = fromMaybe isw $ do
wl <- isw ^? _2 . cWorld . lWorld . walls . ix k
return $ foldl' (flip (`damageWall` wl)) isw dams
updateEdgesWall :: S.Set Int2 -> World -> World
updateEdgesWall is w = updateEdgesWall'
(zonesExtract (w ^. incEdgeZoning & each . each %~ S.fromList) is) w
updateEdgesWall is w =
updateEdgesWall'
(zonesExtract (w ^. incEdgeZoning & each . each %~ S.fromList) is)
w
updateEdgesWall' :: S.Set (Int, Int) -> World -> World
updateEdgesWall' = flip $ foldl' updateEdgeWallObs
--updateEdgeWallObs :: World -> (Int, Int) -> World
--updateEdgeWallObs w (i, j) = w
updateEdgeWallObs :: World -> (Int, Int) -> World
updateEdgeWallObs w (i, j) = fromMaybe w $ do
s <- getNodePos i w
e <- getNodePos j w
let wlflags = foldMap (^. _2 . to getWallPathing) $ wlsHitUnsorted s e w
return $ w & cWorld . incGraph %~ updateEdge (f wlflags) (i, j)
updateEdgeWallObs w (i, j) = w & cWorld . incGraph . ix i . ix j . seObstacles %~ f wlflags
where
-- f x _ = S.map WallObstacle x
f x y = S.map WallObstacle x `S.union`
(y S.\\ (S.fromList $ map WallObstacle [minBound..maxBound]))
s = w ^?! cWorld . incNode . ix i
e = w ^?! cWorld . incNode . ix j
wlflags = foldMap (^. _2 . to getWallPathing) $ wlsHitUnsorted s e w
f x =
(`S.union` S.map WallObstacle x)
. (S.\\ (S.fromList $ map WallObstacle [minBound .. maxBound]))