extends Node3D

@onready var rain: GPUParticles3D = $Rain
@onready var wind: GPUParticles3D = $Wind

@onready var world_environment: EnvironmentSetup = $WorldEnvironment
@onready var light: LightSetup = $DirectionalLight3D

func update(active: Array):
	if active.has("night"):
		set_sky("night")
	else:
		set_sky("day")
	
	wind.emitting = active.has("wind")
	var a: ParticleProcessMaterial = wind.process_material
	# TODO ramp
	a.initial_velocity_max = 15. if active.has("wind") else 0.
	a.initial_velocity_min = 15. if active.has("wind") else 0.

	# TODO ramp
	rain.emitting = active.has("rain")
	# TODO: Allow server to specify rain.amount

func set_sky(sky_name: String):
	world_environment.set_sky(sky_name)
	light.set_sky(sky_name)
	
