Move wall damages to external position

This commit is contained in:
2022-06-19 15:05:12 +01:00
parent f2d6504634
commit a7e6d6f3cc
14 changed files with 47 additions and 18 deletions
+16
View File
@@ -0,0 +1,16 @@
module Dodge.Update.WallDamage where
import Dodge.Wall.Damage
import Dodge.Data
import qualified Data.IntMap.Strict as IM
import Control.Lens
import Data.Maybe
updateWallDamages :: World -> World
updateWallDamages w = w
& wallDamages .~ IM.empty
& flip (IM.foldrWithKey f) (_wallDamages w)
where
f k dams w' = fromMaybe w' $ do
wl <- w' ^? walls . ix k
return $ foldr (flip damageWall wl) w' dams