Partially implement separate blocks

This commit is contained in:
2021-10-26 22:53:49 +01:00
parent d136fd910c
commit 12d43f9cf0
15 changed files with 145 additions and 115 deletions
+18 -1
View File
@@ -11,7 +11,7 @@ import Dodge.Config.Data
import Dodge.Base
import Dodge.Zone
import Dodge.WallCreatureCollisions
import Dodge.LevelGen.Block
--import Dodge.LevelGen.Block
import Dodge.Update.Camera
import Dodge.SoundLogic
import Dodge.Inventory
@@ -80,6 +80,23 @@ functionalUpdate w = case _menuLayers w of
where
(x,y) = cloudZoneOfPoint $ stripZ $ _clPos cl
updateBlocks :: World -> World
updateBlocks w = foldr f w $ _blocks w
where
f bl w'
| head (_blHPs bl) < 1 = w'
& blocks %~ IM.delete (_blID bl)
& walls %~ removeIDs (_blWallIDs bl)
-- & flip (foldr removeFromZone) (_blWallIDs bl)
| otherwise = w'
removeIDs is wls = foldr IM.delete wls is
--removeFromZone wlid w' = over (wallsZone . znObjects . ix x . ix y) (IM.delete (_wlID wl)) w'
removeFromZone wlid w' = over (wallsZone . znObjects . ix x . ix y . ix (_wlID wl)) setCol w'
where
(x,y) = zoneOfPoint $ uncurry pHalf (_wlLine wl)
wl = _walls w' IM.! wlid
setCol = wlColor .~ V4 1 1 0 1
-- | Note the explict use of record syntax. Using lens creates a space leak.
resetWorldEvents :: World -> World
resetWorldEvents w = w {_worldEvents = id}