Reduce fog and suppress weather indoors
This commit is contained in:
parent
6029eb29b8
commit
134ece4a10
6 changed files with 105 additions and 10 deletions
|
|
@ -13,6 +13,7 @@ var _weather_service: WorldWeatherService
|
|||
var _fade_tween: Tween
|
||||
var _is_active: bool = false
|
||||
var _audio_enabled: bool = false
|
||||
var _suppressed: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -77,6 +78,18 @@ func set_active(active: bool) -> void:
|
|||
)
|
||||
|
||||
|
||||
func set_suppressed(suppressed: bool) -> void:
|
||||
if _suppressed == suppressed:
|
||||
return
|
||||
_suppressed = suppressed
|
||||
if suppressed:
|
||||
_silence_immediately()
|
||||
return
|
||||
_transition_to_rain(
|
||||
_weather_service != null and _weather_service.is_raining()
|
||||
)
|
||||
|
||||
|
||||
func _on_weather_changed(
|
||||
weather: WorldWeatherService.Weather,
|
||||
_seconds_remaining: float,
|
||||
|
|
@ -85,7 +98,7 @@ func _on_weather_changed(
|
|||
|
||||
|
||||
func _transition_to_rain(is_raining: bool) -> void:
|
||||
if not _is_active or not _audio_enabled:
|
||||
if not _is_active or not _audio_enabled or _suppressed:
|
||||
return
|
||||
_stop_fade()
|
||||
if is_raining:
|
||||
|
|
@ -120,7 +133,11 @@ func _fade_volume_to(target_volume_db: float, stop_after_fade: bool) -> void:
|
|||
|
||||
|
||||
func _finish_fade_out() -> void:
|
||||
if _weather_service != null and _weather_service.is_raining():
|
||||
if (
|
||||
not _suppressed
|
||||
and _weather_service != null
|
||||
and _weather_service.is_raining()
|
||||
):
|
||||
return
|
||||
stop()
|
||||
volume_db = SILENT_VOLUME_DB
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ var _distance_update_remaining: float = 0.0
|
|||
var _target_volume_db: float = -80.0
|
||||
var _is_active := false
|
||||
var _audio_enabled: bool = false
|
||||
var _suppressed: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -58,8 +59,8 @@ func configure(listener: Node3D, shoreline_mesh: MeshInstance3D) -> void:
|
|||
|
||||
func set_active(active: bool) -> void:
|
||||
_is_active = active
|
||||
set_process(active and _audio_enabled)
|
||||
if active:
|
||||
set_process(active and _audio_enabled and not _suppressed)
|
||||
if active and not _suppressed:
|
||||
if not _audio_enabled:
|
||||
return
|
||||
_distance_update_remaining = 0.0
|
||||
|
|
@ -72,6 +73,22 @@ func set_active(active: bool) -> void:
|
|||
_waves_audio.volume_db = -80.0
|
||||
|
||||
|
||||
func set_suppressed(suppressed: bool) -> void:
|
||||
if _suppressed == suppressed:
|
||||
return
|
||||
_suppressed = suppressed
|
||||
set_process(_is_active and _audio_enabled and not suppressed)
|
||||
if suppressed:
|
||||
_waves_audio.stop()
|
||||
_waves_audio.volume_db = -80.0
|
||||
elif _is_active and _audio_enabled:
|
||||
_distance_update_remaining = 0.0
|
||||
_update_target_volume()
|
||||
_waves_audio.volume_db = _target_volume_db
|
||||
if _waves_audio.stream != null:
|
||||
_waves_audio.play()
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if not _is_active:
|
||||
return
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@ var _weather_to: WorldWeatherService.Weather = (
|
|||
)
|
||||
var _weather_transition: float = 1.0
|
||||
var _light_performance_profile: bool = false
|
||||
var _local_home_interior_active: bool = false
|
||||
|
||||
|
||||
func setup(
|
||||
|
|
@ -185,6 +186,28 @@ func apply_weather_immediately(
|
|||
_apply_time(_time_service.get_time_hours())
|
||||
|
||||
|
||||
func set_local_home_interior_active(active: bool) -> void:
|
||||
if _local_home_interior_active == active:
|
||||
return
|
||||
_local_home_interior_active = active
|
||||
if _rain != null:
|
||||
_rain.visible = not active
|
||||
_rain.process_mode = (
|
||||
Node.PROCESS_MODE_DISABLED if active else Node.PROCESS_MODE_INHERIT
|
||||
)
|
||||
if _rain_collision != null:
|
||||
_rain_collision.visible = not active
|
||||
_rain_collision.process_mode = (
|
||||
Node.PROCESS_MODE_DISABLED if active else Node.PROCESS_MODE_INHERIT
|
||||
)
|
||||
if _storm_clouds != null:
|
||||
_storm_clouds.process_mode = (
|
||||
Node.PROCESS_MODE_DISABLED if active else Node.PROCESS_MODE_INHERIT
|
||||
)
|
||||
if _time_service != null:
|
||||
_apply_time(_time_service.get_time_hours())
|
||||
|
||||
|
||||
func _prepare_runtime_environment() -> bool:
|
||||
if (
|
||||
_time_service == null
|
||||
|
|
@ -700,6 +723,8 @@ func _weather_value(
|
|||
rainy: float,
|
||||
foggy: float,
|
||||
) -> float:
|
||||
if _local_home_interior_active:
|
||||
return sunny
|
||||
return lerpf(
|
||||
_weather_state_value(_weather_from, sunny, cloudy, rainy, foggy),
|
||||
_weather_state_value(_weather_to, sunny, cloudy, rainy, foggy),
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ const FOGGY_DURATION_RANGE := Vector2(
|
|||
const MAX_PERSISTED_SECONDS: float = WEATHER_PERIOD_SECONDS
|
||||
const DAILY_PLAN_SEGMENT_HOURS: float = 1.0
|
||||
const DAILY_PLAN_SEGMENT_COUNT: int = 24
|
||||
const CLOUDY_TO_SUNNY_THRESHOLD: float = 0.50
|
||||
const CLOUDY_TO_RAINY_THRESHOLD: float = 0.95
|
||||
|
||||
var _weather: Weather = DEFAULT_WEATHER
|
||||
var _seconds_remaining: float = SUNNY_DURATION_RANGE.x
|
||||
|
|
@ -328,9 +330,9 @@ func _choose_next_weather() -> Weather:
|
|||
return Weather.CLOUDY
|
||||
Weather.CLOUDY:
|
||||
var roll: float = _rng.randf()
|
||||
if roll < 0.45:
|
||||
if roll < CLOUDY_TO_SUNNY_THRESHOLD:
|
||||
return Weather.SUNNY
|
||||
if roll < 0.80:
|
||||
if roll < CLOUDY_TO_RAINY_THRESHOLD:
|
||||
return Weather.RAINY
|
||||
return Weather.FOGGY
|
||||
return Weather.SUNNY
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue