Door destruction happens during door update, updates pathing

This commit is contained in:
2025-10-22 22:47:10 +01:00
parent 151c037763
commit 0fd7ba46b5
9 changed files with 145 additions and 198 deletions
-36
View File
@@ -1,7 +1,6 @@
module Dodge.Block (
splinterBlock,
destroyBlock,
destroyDoor,
) where
import Dodge.Zoning.Wall
@@ -13,10 +12,7 @@ import Data.Foldable
import qualified Data.IntSet as IS
import Data.Maybe
import Dodge.Block.Debris
import Dodge.Data.MountedObject
import Dodge.Data.World
import Dodge.DrWdWd
import Dodge.LightSource
import Dodge.Material.Sound
import Dodge.Wall.Delete
import Dodge.Wall.Zone
@@ -83,35 +79,3 @@ maybeClearPath w (i,j) = fromMaybe w $ do
---- w
---- & cWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles .~ mempty) . FGL.delEdge (x, y)
destroyDoor :: Door -> World -> World
destroyDoor dr w =
w
& doDrWdWd (_drDeath dr) dr
& deleteWallIDs wlids
& cWorld . lWorld . doors %~ IM.delete (_drID dr)
-- & muchWlDustAt awl (0.5 * uncurry (+) (_drPos dr))
-- & flip (foldl' (flip $ muchWlDustAt awl)) (map (pos +.+) ps)
& stopPushing (_drPushes dr)
& destroyMounts (_drMounts dr)
where
wlids = _drWallIDs dr
--awl = _walls (_cWorld w) IM.! IS.findMin wlids
-- 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 mos w = foldl' (flip destroyMount) w mos
destroyMount :: MountedObject -> World -> World
destroyMount mo = case mo of
MountedLS lsid -> destroyLS lsid
MountedProp prid -> cWorld . lWorld . props . at prid .~ Nothing
stopPushing :: Maybe Int -> World -> World
stopPushing mdrid w = fromMaybe w $ do
drid <- mdrid
dr <- w ^? cWorld . lWorld . doors . ix drid
return $
w & cWorld . lWorld . doors . ix drid . drMech .~ DrWdId
& stopPushing (_drPushes dr)