This commit is contained in:
2025-11-09 16:12:17 +00:00
parent cd7a5dcbb5
commit 658da193b7
2 changed files with 36 additions and 60 deletions
+1 -13
View File
@@ -2,7 +2,6 @@ module Dodge.Update.WallDamage (updateWallDamages, updateEdgesWall) where
import Control.Lens
import Data.Foldable
import Data.Maybe
import Data.Monoid
import qualified Data.Set as S
import Dodge.Data.World
@@ -13,23 +12,12 @@ 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
-- where
-- f isw k dams = fromMaybe isw $ do
-- wl <- isw ^? _2 . cWorld . lWorld . walls . ix k
-- return $ foldl' (flip (`damageWall` wl)) isw dams
updateWallDamages :: World -> World
updateWallDamages w = set (cWorld . lWorld . wallDamages) mempty
. uncurry updateEdgesWall $ foldrM f w
(IM.toList $ w ^. cWorld . lWorld . wallDamages)
where
f (k,dams) w' = fromMaybe (mempty,w') $ do
wl <- w' ^? cWorld . lWorld . walls . ix k
return $ foldrM (damageWall wl) w' dams
f (k,dams) w' = foldrM (damageWall k) w' dams
updateEdgesWall :: S.Set Int2 -> World -> World
updateEdgesWall is w =