This commit is contained in:
Matteo Sonaglioni
2026-03-13 18:35:50 +01:00
parent 6e11a95a3e
commit 44252ec5e6
27 changed files with 623 additions and 94 deletions

View File

@@ -54,13 +54,21 @@ extends Node3D
@export var raggio_spawn_lucciole: float = 20.0
@export var altezza_spawn_lucciole: float = 3.0
# --- NUOVO: GRUPPO VENTO ---
@export_group("Vento")
@export var particelle_vento: GPUParticles3D
@export var quantita_vento: int = 100
@export var raggio_spawn_vento: float = 25.0
@export var altezza_spawn_vento: float = 5.0
# --- GRUPPO NEVE AGGIORNATO ---
@export_group("Neve")
@export var bottone_neve: Button
@export var bottone_nevicata: Button
@export var overlay_nebbia_schermo: ColorRect
@export var particelle_neve: GPUParticles3D
@export var quantita_neve: int = 2000
@export var tempo_transizione_neve: float = 10.0
@onready var sole: DirectionalLight3D = $DirectionalLight3D
@onready var ambiente: WorldEnvironment = $WorldEnvironment
@onready var menu_giornata: OptionButton = $CanvasLayer/OptionButton
@@ -79,6 +87,13 @@ var is_cinematic_mode: bool = false
var timer_cinematic_env: float = 0.0
var sto_cambiando_in_cinematic: bool = false
# Variabili di stato per la neve
var is_snow_accumulated: bool = false
var is_actively_snowing: bool = false
var snow_tween: Tween
var cold_tween: Tween
var actual_snow_amount: float = 0.0
func _ready() -> void:
if menu_giornata:
menu_giornata.clear()
@@ -102,13 +117,27 @@ func _ready() -> void:
if proc_mat:
proc_mat.emission_box_extents = Vector3(raggio_spawn_lucciole, altezza_spawn_lucciole, raggio_spawn_lucciole)
# --- NUOVO: INIZIALIZZAZIONE VENTO ---
# Inizializzazione Vento
if particelle_vento:
particelle_vento.emitting = false
particelle_vento.amount = quantita_vento
var proc_mat_vento = particelle_vento.process_material as ParticleProcessMaterial
if proc_mat_vento:
proc_mat_vento.emission_box_extents = Vector3(raggio_spawn_vento, altezza_spawn_vento, raggio_spawn_vento)
# --- INIZIALIZZAZIONE NEVE ---
set_snow_amount(0.0)
if particelle_neve:
particelle_neve.emitting = false
particelle_neve.amount = quantita_neve
if bottone_neve:
bottone_neve.pressed.connect(_on_snow_button_pressed)
if bottone_nevicata:
bottone_nevicata.pressed.connect(_on_nevicata_button_pressed)
bottone_nevicata.disabled = true
_resetta_timer_fulmine()
@@ -341,3 +370,52 @@ func spawn_single_godray() -> void:
ray.global_position = nodo_camere.global_position + Vector3(random_x, godray_spawn_height, random_z)
ray.rotation_degrees = godray_rotation_degrees
ray.scale = godray_scale
# ==========================================
# --- LOGICA NEVE AGGIORNATA ---
# ==========================================
func _on_snow_button_pressed():
is_snow_accumulated = !is_snow_accumulated
# Sblocca il pulsante nevicata solo se c'è accumulo
if bottone_nevicata:
bottone_nevicata.disabled = !is_snow_accumulated
# Se sciogliamo la neve, fermiamo anche la nevicata attiva
if not is_snow_accumulated and is_actively_snowing:
_on_nevicata_button_pressed()
var target_snow: float = 1.0 if is_snow_accumulated else 0.0
if snow_tween and snow_tween.is_valid():
snow_tween.kill()
snow_tween = create_tween()
snow_tween.tween_method(set_snow_amount, actual_snow_amount, target_snow, tempo_transizione_neve)
func _on_nevicata_button_pressed():
if not is_snow_accumulated:
return
is_actively_snowing = !is_actively_snowing
if particelle_neve:
particelle_neve.emitting = is_actively_snowing
if overlay_nebbia_schermo and overlay_nebbia_schermo.material:
var target_opacity: float = 1.0 if is_actively_snowing else 0.135
var target_radius: float = 0.350 if is_actively_snowing else 0.465
if cold_tween and cold_tween.is_valid():
cold_tween.kill()
cold_tween = create_tween()
cold_tween.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
cold_tween.set_parallel(true)
cold_tween.tween_property(overlay_nebbia_schermo.material, "shader_parameter/max_opacity", target_opacity, 4.0)
cold_tween.tween_property(overlay_nebbia_schermo.material, "shader_parameter/clear_center_radius", target_radius, 4.0)
func set_snow_amount(value: float):
actual_snow_amount = value
RenderingServer.global_shader_parameter_set("global_snow_amount", value)