Add shatterGun

This commit is contained in:
2022-06-16 11:13:44 +01:00
parent 6d5d651566
commit fa762c7687
13 changed files with 98 additions and 15 deletions
+17 -3
View File
@@ -1,5 +1,7 @@
module Dodge.Block.Debris where
import Dodge.Prop.Moving
import Dodge.WorldEvent.Sound
import Dodge.SoundLogic
--import Dodge.Zone
import Dodge.Base
import Dodge.Data
@@ -13,17 +15,21 @@ import RandomHelp
import qualified Quaternion as Q
--import Data.List (zip4)
makeBlockDebris :: BlockMaterial -> Block -> World -> World
makeBlockDebris _ bl w = w
makeBlockDebris :: Block -> World -> World
makeBlockDebris bl = makeDebris (_blMaterial bl) (_blPos bl)
makeDebris :: BlockMaterial -> Point2 -> World -> World
makeDebris bm p w = w
& flip (foldr (plNew props pjID)) thedebris
& randGen .~ newg
& matDesSound bm p
where
(thedebris,newg) = runState (mapM f [35,55..95]) $ _randGen w
f h = do
v <- randInCirc 2
q <- Q.vToQuat (V3 0 0 1) <$> randOnUnitSphere
return $ someDebris
& prPos .~ _blPos bl
& prPos .~ p
& pjColor .~ greyN 0.5
& pjVel .~ v
& pjQuatSpin .~ Q.axisAngle (vNormal v `v2z` 0) (-0.1)
@@ -48,3 +54,11 @@ someDebris = PropZ
}
debrisShape :: Float -> Prop -> Shape
debrisShape size pr = colorSH (_pjColor pr) . translateSHz (-size) $ upperPrismPoly 8 $ square size
matDesSound :: BlockMaterial -> Point2 -> World -> World
matDesSound mat = case mat of
GlassBlock -> mkSoundBreakGlass
StoneBlock -> mkSoundSplinterBlock
DirtBlock -> originIDsAt (BlockDegradeSound 1) [impact1S,impact3S]
WoodBlock -> originIDsAt (BlockDegradeSound 1) [impact1S,impact2S,impact3S]
MetalBlock -> originIDsAt (BlockDegradeSound 1) [impact2S,impact3S]