add 'thunder_rate' weather property
This commit is contained in:
parent
aed7c1c5b8
commit
0ea842580c
@ -18,5 +18,6 @@
|
||||
"fog_opacity": 0.8,
|
||||
"fog_dencity": 2.0,
|
||||
"fog_curve": 0.5,
|
||||
"clouds": 0.5
|
||||
"clouds": 0.5,
|
||||
"thunder_rate": 0.1
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -30,6 +30,7 @@ class Decorator {
|
||||
std::unordered_map<int64_t, u64id_t> playerTexts;
|
||||
int currentIndex = 0;
|
||||
NotePreset playerNamePreset {};
|
||||
float thunderTimer = 0.0f;
|
||||
|
||||
void update(
|
||||
float delta,
|
||||
|
||||
@ -23,6 +23,7 @@ dv::value WeatherPreset::serialize() const {
|
||||
root["fog_dencity"] = fogDencity;
|
||||
root["fog_curve"] = fogCurve;
|
||||
root["clouds"] = clouds;
|
||||
root["thunder_rate"] = thunderRate;
|
||||
|
||||
return root;
|
||||
}
|
||||
@ -49,4 +50,5 @@ void WeatherPreset::deserialize(const dv::value& src) {
|
||||
src.at("fog_dencity").get(fogDencity);
|
||||
src.at("fog_curve").get(fogCurve);
|
||||
src.at("clouds").get(clouds);
|
||||
src.at("thunder_rate").get(thunderRate);
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ struct WeatherPreset : Serializable {
|
||||
/// @example if 0.8 then opacity range is 0.8-1.0 for 0.0-1.0 intensity
|
||||
float minOpacity = 0.0f;
|
||||
float maxOpacity = 1.0f;
|
||||
/// @brief Clip texture by alpha channel
|
||||
bool opaque = false;
|
||||
/// @brief Fall splash
|
||||
std::optional<ParticlesPreset> splash;
|
||||
@ -37,7 +38,9 @@ struct WeatherPreset : Serializable {
|
||||
float fogCurve = 1.0f;
|
||||
|
||||
float clouds = 0.0f;
|
||||
|
||||
|
||||
float thunderRate = 0.0f;
|
||||
|
||||
/// @brief Weather effects intensity
|
||||
float intensity = 1.0f;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user