Weather: the rain and thunder fade runs even with the weather cycle off
This commit is contained in:
@@ -4227,8 +4227,9 @@ impl Game<'_> {
|
||||
if running {
|
||||
self.world.game_time += 1;
|
||||
if self.ui.rules.bool("advance_weather") {
|
||||
self.world.weather.tick(&mut self.world.random);
|
||||
self.world.weather.tick_timers(&mut self.world.random);
|
||||
}
|
||||
self.world.weather.tick_levels();
|
||||
self.tick_weather_effects();
|
||||
}
|
||||
if self.ticks.is_multiple_of(6000) {
|
||||
|
||||
@@ -109,7 +109,9 @@ pub struct Weather {
|
||||
pub thunder_level: (f32, f32),
|
||||
}
|
||||
impl Weather {
|
||||
pub fn tick(&mut self, random: &mut horizon_core::random::LegacyRandom) {
|
||||
/// The timers of `advanceWeatherCycle`, which run only while
|
||||
/// `advance_weather` is on.
|
||||
pub fn tick_timers(&mut self, random: &mut horizon_core::random::LegacyRandom) {
|
||||
use horizon_core::random::RandomSource;
|
||||
let mut uniform =
|
||||
|min: i32, max: i32| min + random.next_int_bound(max - min + 1).unwrap_or(0);
|
||||
@@ -141,6 +143,10 @@ impl Weather {
|
||||
self.rain_time = uniform(12000, 180000);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// The rain and thunder level fade at the end of `advanceWeatherCycle`,
|
||||
/// which runs whatever `advance_weather` says, so `/weather` still shows.
|
||||
pub fn tick_levels(&mut self) {
|
||||
self.thunder_level.0 = self.thunder_level.1;
|
||||
self.thunder_level.1 =
|
||||
(self.thunder_level.1 + if self.thundering { 0.01 } else { -0.01 }).clamp(0.0, 1.0);
|
||||
|
||||
Reference in New Issue
Block a user