Allow chunk debris to fall down chasms

This commit is contained in:
2025-08-02 22:49:10 +01:00
parent 5722ca8204
commit ae24720762
4 changed files with 59 additions and 59 deletions
+19 -14
View File
@@ -11,7 +11,6 @@ import Color
import Data.Foldable
import qualified Data.IntSet as IS
import Data.Maybe
import Dodge.Base
import Dodge.Data.World
import Dodge.Material.Sound
import Dodge.WorldEvent.Sound
@@ -49,25 +48,31 @@ makeDebris = makeDebrisDirected (2 * pi) 0
makeDebrisDirected :: Float -> Float -> Material -> Color -> Point2 -> World -> World
makeDebrisDirected arcrad dir bm col p w =
w
& flip (foldl' (flip $ plNew (cWorld . lWorld . props) prID)) thedebris
-- & flip (foldl' (flip $ plNew (cWorld . lWorld . props) prID)) thedebris
& cWorld . lWorld . debris <>~ thedebris
& randGen .~ newg
& soundOriginsIDsAt [MaterialSound bm i | i <- [0, 1, 2]] (destroyMatS bm) p
where
(thedebris, newg) = mapM f [35, 55 .. 95] & runState $ _randGen w
(thedebris, newg) = mapM f [35, 55, 75, 95] & runState $ _randGen w
f h = do
v <- rotateV (dir - arcrad / 2) <$> randInArcStrip 1 2 arcrad
q <- Q.vToQuat (V3 0 0 1) <$> randOnUnitSphere
spinspeed <- randomR (-0.2, -0.1) & state
basedebris <- baseDebris bm
return $
basedebris
& prColor .~ col
& prPos .~ p
& prVel .~ v
& prQuatSpin .~ Q.axisAngle (vNormal v `v2z` 0) spinspeed
& prQuat .~ q
& prVelZ .~ 0
& prPosZ .~ h
-- basedebris <- baseDebris bm
return $ DebrisChunk
{ _dbPos = p `v2z` h
, _dbType = BlockDebris col
, _dbVel = v `v2z` 0
, _dbRot = Q.qID
, _dbSpin = Q.axisAngle (vNormal v `v2z` 0) spinspeed
}
-- basedebris
-- & prColor .~ col
-- & prPos .~ p
-- & prVel .~ v
-- & prQuatSpin .~ Q.axisAngle (vNormal v `v2z` 0) spinspeed
-- & prQuat .~ Q.qID
-- & prVelZ .~ 0
-- & prPosZ .~ h
debrisSize :: Material -> Float
debrisSize mt = case mt of