Cleanup, move towards unifying zones
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
{- | Creation, update and destruction of destructible walls. -}
|
||||
module Dodge.LevelGen.Block where
|
||||
import Dodge.Data
|
||||
import Dodge.Data.SoundOrigin
|
||||
import Dodge.Base
|
||||
import Dodge.Base.Zone
|
||||
import Dodge.Zone
|
||||
import Dodge.Zone.Data
|
||||
import Dodge.SoundLogic
|
||||
import Dodge.WorldEvent.Sound
|
||||
import Dodge.LevelGen.Pathing
|
||||
@@ -24,7 +26,7 @@ updateBlocks w = (\w' -> seq (_wallsZone w') w') $ flip (foldr removeFromZone) d
|
||||
where
|
||||
degradeBlocks = deadBlocks `seq` foldr killBlock w deadBlocks
|
||||
removeFromZone :: Wall -> World -> World
|
||||
removeFromZone bl = over (wallsZone . ix x . ix y) (IM.delete (_wlID bl))
|
||||
removeFromZone bl = over (wallsZone . znObjects . ix x . ix y) (IM.delete (_wlID bl))
|
||||
where
|
||||
(x,y) = zoneOfPoint $ uncurry pHalf (_wlLine bl)
|
||||
deadPanes = filter blockIsDead (IM.elems $ _walls w)
|
||||
@@ -54,7 +56,7 @@ killBlock bl w = f bl . flip (foldr unshadow) (_blShadows bl) $ w
|
||||
unshadow bid w' = case w' ^? walls . ix bid of
|
||||
Just b ->
|
||||
let (x,y) = zoneOfPoint $ uncurry pHalf (_wlLine b)
|
||||
in w & wallsZone . ix x . ix y . ix bid . blVisible %~ const True
|
||||
in w & wallsZone . znObjects . ix x . ix y . ix bid . blVisible %~ const True
|
||||
& walls . ix bid . blVisible %~ const True
|
||||
Nothing -> w
|
||||
|
||||
@@ -100,7 +102,7 @@ addBlock (p:ps) hp col isSeeThrough degradability w
|
||||
| hp <= 0 && null degradability = w
|
||||
| hp <= 0 = addBlock (p:ps) (head degradability + hp) col isSeeThrough (tail degradability) w
|
||||
| otherwise = w
|
||||
& wallsZone %~ flip (IM.foldr wallInZone) panes
|
||||
& wallsZone . znObjects %~ flip (IM.foldr wallInZone) panes
|
||||
& walls %~ IM.union panes
|
||||
where
|
||||
lns = zip (p:ps) (ps ++ [p])
|
||||
|
||||
Reference in New Issue
Block a user