add 'thunder_rate' weather property

This commit is contained in:
MihailRis
2025-02-28 18:48:21 +03:00
parent aed7c1c5b8
commit 0ea842580c
5 changed files with 29 additions and 2 deletions
+20
View File
@@ -178,6 +178,26 @@ void Decorator::update(
const WeatherPreset& weatherA,
const WeatherPreset& weatherB
) {
float thunderRate = weatherA.thunderRate * weatherA.intensity +
weatherB.thunderRate * weatherB.intensity;
thunderTimer += delta;
util::PseudoRandom random(rand());
if (thunderTimer >= 1.0f) {
thunderTimer = 0.0f;
if (random.randFloat() < thunderRate) {
audio::play(
assets.get<audio::Sound>("ambient/thunder"),
glm::vec3(),
false,
1.0f,
1.0f + random.randFloat() - 0.5f,
false,
audio::PRIORITY_NORMAL,
audio::get_channel_index("ambient")
);
}
}
glm::ivec3 pos = camera.position;
for (int i = 0; i < ITERATIONS; i++) {
update(delta, pos - glm::ivec3(UPDATE_AREA_DIAMETER / 2), pos);