Split gasses and clouds
This commit is contained in:
+42
-5
@@ -276,6 +276,7 @@ functionalUpdate =
|
||||
(updateIMl' (_linearShockwaves . _lWorld . _cWorld) updateLinearShockwave)
|
||||
. over uvWorld (updateIMl' (_projectiles . _lWorld . _cWorld) updateProjectile)
|
||||
. over uvWorld updateClouds
|
||||
. over uvWorld updateGasses
|
||||
. over uvWorld updateDusts
|
||||
. over uvWorld updateGusts
|
||||
. over uvWorld (updateIMl' (_terminals . _lWorld . _cWorld) tmUpdate)
|
||||
@@ -471,6 +472,7 @@ pbFlicker pt =
|
||||
zoneClouds :: World -> World
|
||||
zoneClouds w =
|
||||
w & clZoning .~ foldl' (flip zoneCloud) mempty (w ^. cWorld . lWorld . clouds)
|
||||
& gasZoning .~ foldl' (flip zoneGas) mempty (w ^. cWorld . lWorld . gasses)
|
||||
|
||||
zoneDusts :: World -> World
|
||||
zoneDusts w = w & dsZoning .~ foldl' (flip zoneDust) mempty (w ^. cWorld . lWorld . dusts)
|
||||
@@ -664,6 +666,9 @@ updateSparks = updateObjCatMaybes sparks updateSpark
|
||||
updateClouds :: World -> World
|
||||
updateClouds = updateObjCatMaybes clouds updateCloud
|
||||
|
||||
updateGasses :: World -> World
|
||||
updateGasses = updateObjCatMaybes gasses updateGas
|
||||
|
||||
updateDusts :: World -> World
|
||||
updateDusts w = updateObjMapMaybe dusts (updateDust w) w
|
||||
|
||||
@@ -785,16 +790,15 @@ mvGust _ gu
|
||||
& guPos .+.+~ _guVel gu
|
||||
& guTime -~ 1
|
||||
|
||||
cloudEffect :: Cloud -> World -> World
|
||||
cloudEffect cl = case _clType cl of
|
||||
GasCloud -> cloudPoisonDamage cl
|
||||
_ -> id
|
||||
gasEffect :: Gas -> World -> World
|
||||
gasEffect cl = case _gsType cl of
|
||||
PoisonGas -> cloudPoisonDamage cl
|
||||
|
||||
updateCloud :: World -> Cloud -> (World, Maybe Cloud)
|
||||
updateCloud w c
|
||||
| _clTimer c < 1 = (w, Nothing)
|
||||
| otherwise =
|
||||
( cloudEffect c w
|
||||
( w
|
||||
, Just $
|
||||
c
|
||||
& clPos .~ finalPos
|
||||
@@ -814,6 +818,30 @@ updateCloud w c
|
||||
finalPos = addZ (min 90 npz) $ maybe newPos2 fst hitWl
|
||||
finalVel = addZ nvz $ maybe newVel2 snd hitWl
|
||||
|
||||
updateGas :: World -> Gas -> (World, Maybe Gas)
|
||||
updateGas w c
|
||||
| _gsTimer c < 1 = (w, Nothing)
|
||||
| otherwise =
|
||||
( gasEffect c w
|
||||
, Just $
|
||||
c
|
||||
& gsPos .~ finalPos
|
||||
& gsVel .~ finalVel
|
||||
& gsTimer -~ 1
|
||||
)
|
||||
where
|
||||
newVel@(V3 _ _ nvz) = (0.95 *^ springVels) + V3 0 0 (0.01 * vertVel)
|
||||
newVel2 = stripZ newVel
|
||||
vertVel = min 5 $ 20 - opz
|
||||
springVels = foldl' (gasGasSpringVel c) (_gsVel c) (gassesNearPoint oldPos2 w)
|
||||
oldPos@(V3 _ _ opz) = _gsPos c
|
||||
oldPos2 = stripZ oldPos
|
||||
newPos@(V3 _ _ npz) = oldPos + newVel
|
||||
newPos2 = stripZ newPos
|
||||
hitWl = bouncePoint (const True) 1 oldPos2 newPos2 w
|
||||
finalPos = addZ (min 90 npz) $ maybe newPos2 fst hitWl
|
||||
finalVel = addZ nvz $ maybe newVel2 snd hitWl
|
||||
|
||||
updateDust :: World -> Dust -> Maybe Dust
|
||||
updateDust w c
|
||||
| _dsTimer c < 1 = Nothing
|
||||
@@ -842,6 +870,15 @@ clClSpringVel a v b
|
||||
pb = _clPos b
|
||||
radDist = 10
|
||||
|
||||
gasGasSpringVel :: Gas -> Point3 -> Gas -> Point3
|
||||
gasGasSpringVel a v b
|
||||
| dist3 pa pb < radDist = v + 0.1 *^ normalizeV3 (pa - pb)
|
||||
| otherwise = v
|
||||
where
|
||||
pa = _gsPos a
|
||||
pb = _gsPos b
|
||||
radDist = 10
|
||||
|
||||
--radDist = (_clRad a + _clRad b) / 2
|
||||
|
||||
dustSpringVel :: Dust -> Point3 -> Dust -> Point3
|
||||
|
||||
Reference in New Issue
Block a user