MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / UpdateWeather

Method UpdateWeather

TombEngine/Game/effects/weather.cpp:325–526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323 }
324
325 void EnvironmentController::UpdateWeather(const ScriptInterfaceLevel& level)
326 {
327 for (auto& part : Particles)
328 {
329 part.StoreInterpolationData();
330
331 part.Life -= 2;
332
333 // Disable particle if dead. Will be cleaned on next call of SpawnWeatherParticles().
334 if (part.Life <= 0)
335 {
336 part.Enabled = false;
337 continue;
338 }
339
340 // Check if particle got out of collision check radius and fade out if it did.
341 if (abs(Camera.pos.x - part.Position.x) > COLLISION_CHECK_DISTANCE ||
342 abs(Camera.pos.z - part.Position.z) > COLLISION_CHECK_DISTANCE)
343 {
344 part.Life = std::clamp(part.Life, 0.0f, WEATHER_PARTICLE_NEAR_DEATH_LIFE);
345 }
346
347 // If particle was locked (after landing or stucking in substance such as water or swamp),
348 // fade out and bypass collision checks and movement updates.
349 if (part.Stopped)
350 {
351 if (part.Type == WeatherType::Snow)
352 part.Size *= WEATHER_PARTICLE_NEAR_DEATH_MELT_FACTOR;
353
354 continue;
355 }
356
357 // Backup previous position and progress new position according to velocity.
358 auto prevPos = part.Position;
359 part.Position.x += part.Velocity.x;
360 part.Position.z += part.Velocity.z;
361
362 switch (part.Type)
363 {
364 case WeatherType::None:
365 part.Position.y += part.Velocity.y;
366 break;
367
368 case WeatherType::Rain:
369 case WeatherType::Snow:
370 part.Position.y += (part.Velocity.y / 2.0f);
371 break;
372 }
373
374 // Particle is inert; don't check collisions.
375 if (part.Type == WeatherType::None)
376 continue;
377
378 PointCollisionData pointColl;
379 bool collisionCalculated = false;
380 bool landed = false;
381
382 if (part.CollisionCheckDelay <= 0)

Callers

nothing calls this directly

Calls 13

GetPointCollisionFunction · 0.85
floorFunction · 0.85
IsPointInRoomFunction · 0.85
SpawnRippleFunction · 0.85
GenerateFloatFunction · 0.85
AddWaterSparksFunction · 0.85
GenerateIntFunction · 0.85
GetWeatherStrengthMethod · 0.80
GetFloorHeightMethod · 0.45
GetCeilingHeightMethod · 0.45
GetRoomNumberMethod · 0.45

Tested by

no test coverage detected