Start simplifying projectile update

This commit is contained in:
2025-08-03 13:46:20 +01:00
parent 5f158cc87a
commit c3b2bb30f5
10 changed files with 218 additions and 228 deletions
+9
View File
@@ -2,6 +2,7 @@ module Dodge.Prop.Gib (
addCrGibs,
) where
import Dodge.WorldEvent.Cloud
import Dodge.Creature.Shape
import Color
import Control.Monad
@@ -20,10 +21,18 @@ addCrGibs cr = case damageDirection $ _crDamage cr of
addGibAt 25 (_skinHead skin) cpos
. addGibsAtDir pi 0 3 7 (_skinLower skin) cpos
. addGibsAtDir pi 0 13 20 (_skinUpper skin) cpos
. makeDustAt Flesh 50 (addZ 20 cpos)
. makeDustAt Flesh 50 (addZ 20 cpos)
. makeDustAt Flesh 50 (addZ 20 cpos)
. makeDustAt Flesh 50 (addZ 20 cpos)
Just d -> (testFloat +~ 1)
. addGibsAtDir (pi/4) d 3 7 (_skinLower skin) cpos
. addGibsAtDir (pi/4) d 13 20 (_skinUpper skin) cpos
. addGibAtDir d 25 (_skinHead skin) cpos
. makeDustAt Flesh 50 (addZ 20 cpos)
. makeDustAt Flesh 50 (addZ 20 cpos)
. makeDustAt Flesh 50 (addZ 20 cpos)
. makeDustAt Flesh 50 (addZ 20 cpos)
where
skin = crShape $ _crType cr -- this should be cleaned up
cpos = _crPos cr
+43 -43
View File
@@ -1,12 +1,12 @@
module Dodge.Prop.Moving (
fallSmallBounceDamage,
fallSmallBounce,
-- fallSmallBounceDamage,
-- fallSmallBounce,
updateDebrisChunk,
) where
import Linear.Metric
import Linear.V3
import Dodge.Damage
--import Dodge.Damage
import Dodge.Base
import Dodge.Data.World
import Geometry
@@ -30,47 +30,47 @@ updateDebrisChunk w db = (w, mdb)
& dbVel .~ (0.7 * reflectInNormal n sv) - V3 0 0 1
dospin = (_dbSpin db *)
mdb = do
guard (np ^. _z > -100)
guard (np ^. _z > -1000)
return cdb'
fallSmallBounceDamage :: Prop -> World -> World
fallSmallBounceDamage pr w =
w
& dodamage
& cWorld . lWorld . props . ix (_prID pr) %~ fallMovement w
where
p = _prPos pr
v = _prVel pr
dodamage
| _prPosZ pr < 25 = damageInCircle (const thedam) p 5
| otherwise = id
thedam = Crushing (floor . (* 10) . max 0 . subtract 5 . abs $ _prVelZ pr) v
--fallSmallBounceDamage :: Prop -> World -> World
--fallSmallBounceDamage pr w =
-- w
-- & dodamage
-- & cWorld . lWorld . props . ix (_prID pr) %~ fallMovement w
-- where
-- p = _prPos pr
-- v = _prVel pr
-- dodamage
-- | _prPosZ pr < 25 = damageInCircle (const thedam) p 5
-- | otherwise = id
-- thedam = Crushing (floor . (* 10) . max 0 . subtract 5 . abs $ _prVelZ pr) v
fallSmallBounce :: Prop -> World -> World
fallSmallBounce pr w = w & cWorld . lWorld . props . ix (_prID pr) %~ fallMovement w
--fallSmallBounce :: Prop -> World -> World
--fallSmallBounce pr w = w & cWorld . lWorld . props . ix (_prID pr) %~ fallMovement w
fallMovement :: World -> Prop -> Prop
fallMovement w pr
| newposz < 0 && velz < (-2) =
pr
& prVelZ %~ ((* 0.5) . negate)
& updateWithVel (0.5 *.* vel)
& prVel %~ (0.5 *.*)
| newposz < 0 =
pr & prUpdate .~ PropUpdateId
& prPosZ .~ 0
-- & pjQuat *~ (_pjQuatSpin pr)
| otherwise =
pr
& prVelZ -~ 1
& prPosZ +~ velz
& updateWithVel vel
& prQuat *~ _prQuatSpin pr
where
newposz = _prPosZ pr + velz
velz = _prVelZ pr
vel = _prVel pr
pos = _prPos pr
updateWithVel v = case bouncePoint (const True) 0.5 pos (pos + v) w of
Nothing -> prPos +~ v
Just (p, v') -> (prPos .~ p) . (prVel .~ v')
--fallMovement :: World -> Prop -> Prop
--fallMovement w pr
-- | newposz < 0 && velz < (-2) =
-- pr
-- & prVelZ %~ ((* 0.5) . negate)
-- & updateWithVel (0.5 *.* vel)
-- & prVel %~ (0.5 *.*)
-- | newposz < 0 =
-- pr & prUpdate .~ PropUpdateId
-- & prPosZ .~ 0
-- -- & pjQuat *~ (_pjQuatSpin pr)
-- | otherwise =
-- pr
-- & prVelZ -~ 1
-- & prPosZ +~ velz
-- & updateWithVel vel
-- & prQuat *~ _prQuatSpin pr
-- where
-- newposz = _prPosZ pr + velz
-- velz = _prVelZ pr
-- vel = _prVel pr
-- pos = _prPos pr
-- updateWithVel v = case bouncePoint (const True) 0.5 pos (pos + v) w of
-- Nothing -> prPos +~ v
-- Just (p, v') -> (prPos .~ p) . (prVel .~ v')
+1 -3
View File
@@ -4,14 +4,12 @@ import Control.Lens
import Data.Foldable
import Dodge.Data.World
import Dodge.PrWdLsLs
import Dodge.Prop.Moving
--import Dodge.Prop.Moving
import Dodge.WdP2f
import Dodge.WorldBool
updateProp :: Prop -> World -> World
updateProp pr = case _prUpdate pr of
PropFallSmallBounceDamage -> fallSmallBounceDamage pr
PropFallSmallBounce -> fallSmallBounce pr
PropUpdateId -> id
PropRotate x -> rotateProp x pr
PropSetToggleAnd wb pu -> propSetToggleAnd wb pu pr