161 lines
5.6 KiB
GDScript
161 lines
5.6 KiB
GDScript
@tool
|
|
class_name WeatherProfile
|
|
extends Resource
|
|
|
|
enum WeatherState {
|
|
CLEAR,
|
|
CLOUDY,
|
|
OVERCAST,
|
|
RAIN,
|
|
STORM,
|
|
SNOW
|
|
}
|
|
|
|
@export var weather_state: WeatherState = WeatherState.CLEAR
|
|
@export var display_name: String = "Clear"
|
|
|
|
@export_group("Clouds")
|
|
@export var cloud_density: float = 0.2
|
|
@export var cloud_opacity: float = 0.7
|
|
@export var cloud_coverage: float = 0.3
|
|
@export var cloud_color: Color = Color.WHITE
|
|
@export var cloud_shadow_color: Color = Color(0.6, 0.6, 0.7)
|
|
|
|
@export_group("Wind")
|
|
@export var wind_speed: float = 1.0
|
|
@export var wind_direction: Vector2 = Vector2(1.0, 0.0)
|
|
@export var wind_turbulence: float = 0.1
|
|
|
|
@export_group("Ambient Adjustments")
|
|
@export var ambient_color_multiplier: Color = Color.WHITE
|
|
@export var ambient_intensity_multiplier: float = 1.0
|
|
|
|
@export_group("Fog Adjustments")
|
|
@export var fog_color_multiplier: Color = Color.WHITE
|
|
@export var fog_density_multiplier: float = 1.0
|
|
|
|
@export_group("VFX")
|
|
@export var rain_intensity: float = 0.0
|
|
@export var snow_intensity: float = 0.0
|
|
@export var lightning_enabled: bool = false
|
|
@export var lightning_frequency: float = 0.1
|
|
|
|
@export_group("Transition")
|
|
@export var default_transition_duration: float = 5.0
|
|
|
|
|
|
static func create_clear() -> WeatherProfile:
|
|
var profile := WeatherProfile.new()
|
|
profile.weather_state = WeatherState.CLEAR
|
|
profile.display_name = "Clear"
|
|
profile.cloud_density = 0.1
|
|
profile.cloud_opacity = 0.6
|
|
profile.cloud_coverage = 0.2
|
|
profile.wind_speed = 0.5
|
|
return profile
|
|
|
|
|
|
static func create_cloudy() -> WeatherProfile:
|
|
var profile := WeatherProfile.new()
|
|
profile.weather_state = WeatherState.CLOUDY
|
|
profile.display_name = "Cloudy"
|
|
profile.cloud_density = 0.5
|
|
profile.cloud_opacity = 0.8
|
|
profile.cloud_coverage = 0.5
|
|
profile.wind_speed = 1.0
|
|
profile.ambient_intensity_multiplier = 0.9
|
|
return profile
|
|
|
|
|
|
static func create_overcast() -> WeatherProfile:
|
|
var profile := WeatherProfile.new()
|
|
profile.weather_state = WeatherState.OVERCAST
|
|
profile.display_name = "Overcast"
|
|
profile.cloud_density = 0.9
|
|
profile.cloud_opacity = 1.0
|
|
profile.cloud_coverage = 0.9
|
|
profile.cloud_color = Color(0.7, 0.72, 0.75)
|
|
profile.wind_speed = 1.5
|
|
profile.ambient_intensity_multiplier = 0.7
|
|
profile.fog_density_multiplier = 1.5
|
|
return profile
|
|
|
|
|
|
static func create_rain() -> WeatherProfile:
|
|
var profile := WeatherProfile.new()
|
|
profile.weather_state = WeatherState.RAIN
|
|
profile.display_name = "Rain"
|
|
profile.cloud_density = 0.85
|
|
profile.cloud_opacity = 0.95
|
|
profile.cloud_coverage = 0.85
|
|
profile.cloud_color = Color(0.55, 0.58, 0.65)
|
|
profile.wind_speed = 2.0
|
|
profile.ambient_intensity_multiplier = 0.6
|
|
profile.fog_density_multiplier = 2.0
|
|
profile.rain_intensity = 0.7
|
|
profile.lightning_enabled = true
|
|
profile.lightning_frequency = 0.008
|
|
profile.default_transition_duration = 8.0
|
|
return profile
|
|
|
|
|
|
static func create_storm() -> WeatherProfile:
|
|
var profile := WeatherProfile.new()
|
|
profile.weather_state = WeatherState.STORM
|
|
profile.display_name = "Storm"
|
|
profile.cloud_density = 1.0
|
|
profile.cloud_opacity = 1.0
|
|
profile.cloud_coverage = 1.0
|
|
profile.cloud_color = Color(0.4, 0.42, 0.5)
|
|
profile.cloud_shadow_color = Color(0.2, 0.22, 0.28)
|
|
profile.wind_speed = 4.0
|
|
profile.wind_turbulence = 0.4
|
|
profile.ambient_intensity_multiplier = 0.4
|
|
profile.fog_density_multiplier = 3.0
|
|
profile.rain_intensity = 1.0
|
|
profile.lightning_enabled = true
|
|
profile.lightning_frequency = 0.15
|
|
profile.default_transition_duration = 10.0
|
|
return profile
|
|
|
|
|
|
static func create_snow() -> WeatherProfile:
|
|
var profile := WeatherProfile.new()
|
|
profile.weather_state = WeatherState.SNOW
|
|
profile.display_name = "Snow"
|
|
profile.cloud_density = 0.8
|
|
profile.cloud_opacity = 0.9
|
|
profile.cloud_coverage = 0.8
|
|
profile.cloud_color = Color(0.85, 0.87, 0.92)
|
|
profile.wind_speed = 1.0
|
|
profile.ambient_color_multiplier = Color(0.9, 0.92, 1.0)
|
|
profile.ambient_intensity_multiplier = 0.75
|
|
profile.fog_color_multiplier = Color(0.95, 0.97, 1.0)
|
|
profile.fog_density_multiplier = 1.8
|
|
profile.snow_intensity = 0.8
|
|
profile.default_transition_duration = 12.0
|
|
return profile
|
|
|
|
|
|
func lerp_to(other: WeatherProfile, weight: float) -> WeatherProfile:
|
|
var result := WeatherProfile.new()
|
|
result.weather_state = weather_state if weight < 0.5 else other.weather_state
|
|
result.display_name = display_name if weight < 0.5 else other.display_name
|
|
result.cloud_density = lerpf(cloud_density, other.cloud_density, weight)
|
|
result.cloud_opacity = lerpf(cloud_opacity, other.cloud_opacity, weight)
|
|
result.cloud_coverage = lerpf(cloud_coverage, other.cloud_coverage, weight)
|
|
result.cloud_color = cloud_color.lerp(other.cloud_color, weight)
|
|
result.cloud_shadow_color = cloud_shadow_color.lerp(other.cloud_shadow_color, weight)
|
|
result.wind_speed = lerpf(wind_speed, other.wind_speed, weight)
|
|
result.wind_direction = wind_direction.lerp(other.wind_direction, weight).normalized()
|
|
result.wind_turbulence = lerpf(wind_turbulence, other.wind_turbulence, weight)
|
|
result.ambient_color_multiplier = ambient_color_multiplier.lerp(other.ambient_color_multiplier, weight)
|
|
result.ambient_intensity_multiplier = lerpf(ambient_intensity_multiplier, other.ambient_intensity_multiplier, weight)
|
|
result.fog_color_multiplier = fog_color_multiplier.lerp(other.fog_color_multiplier, weight)
|
|
result.fog_density_multiplier = lerpf(fog_density_multiplier, other.fog_density_multiplier, weight)
|
|
result.rain_intensity = lerpf(rain_intensity, other.rain_intensity, weight)
|
|
result.snow_intensity = lerpf(snow_intensity, other.snow_intensity, weight)
|
|
result.lightning_enabled = lightning_enabled or other.lightning_enabled
|
|
result.lightning_frequency = lerpf(lightning_frequency, other.lightning_frequency, weight)
|
|
return result
|