Control wall damage effects using the wall

This commit is contained in:
2021-11-01 16:50:09 +00:00
parent 7ddbbdda14
commit e4c73b9b8b
7 changed files with 93 additions and 57 deletions
+3 -5
View File
@@ -89,11 +89,10 @@ splinterBlock bl w = foldr unshadowBlock w (_blShadows bl) -- foldr shiftTowardC
& blocks . ix (_blID bl) . blHPs %~ tail
& theSoundEffect cen
where
wls = map (_walls w IM.!) (IS.toList $ _blWallIDs bl)
ps = map (fst . _wlLine) wls
cen = centroid ps
wls = IM.restrictKeys (_walls w) (_blWallIDs bl)
cen = centroid $ fmap (fst . _wlLine) wls
theSoundEffect
| _wlOpacity (head wls) == SeeThrough = mkSoundSplinterGlass
| _wlOpacity (snd $ IM.findMin wls) == SeeThrough = mkSoundSplinterGlass
| otherwise = mkSoundSplinterBlock
unshadowBlock :: Int -> World -> World
@@ -121,7 +120,6 @@ destroyBlock bl w = w
where
wlids = _blWallIDs bl
pos = fst . _wlLine $ _walls w IM.! IS.findMin wlids
-- | Note the explict use of record syntax. Using lens created a space leak.
resetWorldEvents :: World -> World
resetWorldEvents w = w {_worldEvents = id}