Refactor material sounds

This commit is contained in:
2022-06-19 21:21:33 +01:00
parent 08e5df07e2
commit 8d81104f5f
14 changed files with 236 additions and 231 deletions
+3 -12
View File
@@ -1,7 +1,7 @@
module Dodge.Block where
import Dodge.Data
import Dodge.Material
--import Dodge.Block.Debris
import Dodge.SoundLogic
import Dodge.Zone
import Dodge.WorldEvent.Sound
import Dodge.Wall.Delete
@@ -18,13 +18,13 @@ import Control.Lens
splinterBlock :: Block -> World -> World
splinterBlock bl w = foldr unshadowBlock w (_blShadows bl) -- foldr shiftTowardCen w (_blWallIDs bl)
& matSplintSound bm cen
& originsIDsAt [MaterialSound bm 0,MaterialSound bm 1,MaterialSound bm 2]
(weakenMatS bm) (_blPos bl)
where
bm = fromMaybe Stone $ do
wlids <- w ^? blocks . ix (_blID bl) . blWallIDs
(wlid,_) <- IS.minView wlids
w ^? walls . ix wlid . wlMaterial
cen = centroid $ fst . _wlLine <$> IM.restrictKeys (_walls w) (_blWallIDs bl)
unshadowBlock :: Int -> World -> World
unshadowBlock wlid w = case w ^? walls . ix wlid of
@@ -35,15 +35,6 @@ unshadowBlock wlid w = case w ^? walls . ix wlid of
(x,y) = zoneOfPoint $ uncurry pHalf (_wlLine wl)
Nothing -> w
matSplintSound :: Material -> Point2 -> World -> World
matSplintSound mat = case mat of
Glass -> mkSoundSplinterGlass
Stone -> mkSoundSplinterBlock
Crystal -> mkSoundSplinterBlock
Dirt -> originIDsAt (BlockDegradeSound 1) [impact1S,impact3S]
Wood -> originIDsAt (BlockDegradeSound 1) [impact1S,impact2S,impact3S]
Metal -> originIDsAt (BlockDegradeSound 1) [impact2S,impact3S]
checkBlockHP :: Block -> World -> World
checkBlockHP bl
| _blHP bl < 1 = destroyBlock bl