Update pathing on block destruction without relying on _blObstructs
This commit is contained in:
@@ -1,18 +1,35 @@
|
||||
module Dodge.Update.WallDamage (updateWallDamages) where
|
||||
module Dodge.Update.WallDamage (updateWallDamages,updateEdgesWall) where
|
||||
|
||||
import Dodge.WorldEvent.ThingsHit
|
||||
import Dodge.Path
|
||||
import Dodge.Zoning.Base
|
||||
import Control.Lens
|
||||
import Data.Maybe
|
||||
import Dodge.Data.World
|
||||
import Dodge.Wall.Damage
|
||||
import qualified IntMapHelp as IM
|
||||
import Data.Foldable
|
||||
import qualified Data.Set as S
|
||||
|
||||
updateWallDamages :: World -> World
|
||||
updateWallDamages w =
|
||||
w
|
||||
& cWorld . lWorld . wallDamages .~ IM.empty
|
||||
& flip (IM.foldlWithKey' f) (w ^. cWorld . lWorld . wallDamages)
|
||||
updateWallDamages w =
|
||||
let (is,w')
|
||||
= IM.foldlWithKey' f (mempty,w) (w ^. cWorld . lWorld . wallDamages)
|
||||
in updateEdgesWall (zonesExtract (w ^. incEdgeZoning & each . each %~ S.fromList) is) w'
|
||||
& cWorld . lWorld . wallDamages .~ IM.empty
|
||||
where
|
||||
f w' k dams = fromMaybe w' $ do
|
||||
wl <- w' ^? cWorld . lWorld . walls . ix k
|
||||
return $ foldl' (flip (`damageWall` wl)) w' dams
|
||||
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 (Int,Int) -> World -> World
|
||||
updateEdgesWall = flip $ foldl' updateEdgeWallObs
|
||||
|
||||
updateEdgeWallObs :: World -> (Int,Int) -> World
|
||||
updateEdgeWallObs w (i,j) = fromMaybe w $ do
|
||||
s <- getNodePos i w
|
||||
e <- getNodePos j w
|
||||
let wlflags = foldMap (^. _2 . wlPathFlag) $ wlsHitUnsorted s e w
|
||||
return $ w & cWorld . incGraph %~ updateEdge (f wlflags) (i,j)
|
||||
where
|
||||
f x _ = S.map WallObstacle x
|
||||
|
||||
Reference in New Issue
Block a user