fix snow stuff
This commit is contained in:
@@ -60,7 +60,6 @@ extends Node3D
|
||||
@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
|
||||
@@ -87,7 +86,6 @@ 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
|
||||
@@ -109,7 +107,6 @@ func _ready() -> void:
|
||||
if particelle_pioggia:
|
||||
particelle_pioggia.emitting = false
|
||||
|
||||
# Inizializzazione Lucciole
|
||||
if particelle_lucciole:
|
||||
particelle_lucciole.emitting = false
|
||||
particelle_lucciole.amount = quantita_lucciole
|
||||
@@ -117,7 +114,6 @@ func _ready() -> void:
|
||||
if proc_mat:
|
||||
proc_mat.emission_box_extents = Vector3(raggio_spawn_lucciole, altezza_spawn_lucciole, raggio_spawn_lucciole)
|
||||
|
||||
# Inizializzazione Vento
|
||||
if particelle_vento:
|
||||
particelle_vento.emitting = false
|
||||
particelle_vento.amount = quantita_vento
|
||||
@@ -125,7 +121,6 @@ func _ready() -> void:
|
||||
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:
|
||||
@@ -173,6 +168,12 @@ func _on_giornata_selezionata(index: int) -> void:
|
||||
trigger_morning()
|
||||
|
||||
func _on_pioggia_toggled(toggled_on: bool) -> void:
|
||||
# Blocchiamo la pioggia se sta già nevicando
|
||||
if is_actively_snowing and toggled_on:
|
||||
if bottone_pioggia:
|
||||
bottone_pioggia.set_pressed_no_signal(false)
|
||||
return
|
||||
|
||||
if not sto_cambiando_in_cinematic and is_cinematic_mode:
|
||||
is_cinematic_mode = false
|
||||
print("Ambiente Cinematic: DISATTIVATA (Pioggia cambiata manualmente)")
|
||||
@@ -196,13 +197,18 @@ func _process(delta: float) -> void:
|
||||
var base_sky_top: Color
|
||||
var base_sky_horizon: Color
|
||||
|
||||
if is_raining:
|
||||
# Usiamo questa variabile per animare le nuvole sia se piove sia se nevica
|
||||
var tempesta_attiva = is_raining or is_actively_snowing
|
||||
|
||||
if tempesta_attiva:
|
||||
intensita_pioggia = move_toward(intensita_pioggia, 1.0, delta * 0.5)
|
||||
|
||||
timer_prossimo_fulmine -= delta
|
||||
if timer_prossimo_fulmine <= 0.0:
|
||||
_scatena_fulmine()
|
||||
_resetta_timer_fulmine()
|
||||
# I fulmini partono SOLO se sta piovendo
|
||||
if is_raining:
|
||||
timer_prossimo_fulmine -= delta
|
||||
if timer_prossimo_fulmine <= 0.0:
|
||||
_scatena_fulmine()
|
||||
_resetta_timer_fulmine()
|
||||
else:
|
||||
intensita_pioggia = move_toward(intensita_pioggia, 0.0, delta * 0.5)
|
||||
|
||||
@@ -255,28 +261,22 @@ func _process(delta: float) -> void:
|
||||
materiale_nebbia.set_shader_parameter("night_intensity", night_val)
|
||||
materiale_nebbia.set_shader_parameter("sun_color", final_tint)
|
||||
|
||||
# ==========================================
|
||||
# --- GESTIONE POLVERE, LUCCIOLE E VENTO ---
|
||||
# ==========================================
|
||||
var e_notte = tempo_giorno >= 2.5
|
||||
|
||||
# Polvere (2D): Solo di giorno e senza pioggia
|
||||
if nodo_polvere:
|
||||
if not is_raining and not e_notte:
|
||||
if not tempesta_attiva and not e_notte:
|
||||
nodo_polvere.visible = true
|
||||
else:
|
||||
nodo_polvere.visible = false
|
||||
|
||||
# Lucciole (3D): Solo di notte e senza pioggia
|
||||
if particelle_lucciole:
|
||||
if not is_raining and e_notte:
|
||||
if not tempesta_attiva and e_notte:
|
||||
particelle_lucciole.emitting = true
|
||||
else:
|
||||
particelle_lucciole.emitting = false
|
||||
|
||||
# Vento (3D): Solo di giorno e senza pioggia
|
||||
if particelle_vento:
|
||||
if not is_raining and not e_notte:
|
||||
if not tempesta_attiva and not e_notte:
|
||||
particelle_vento.emitting = true
|
||||
else:
|
||||
particelle_vento.emitting = false
|
||||
@@ -293,17 +293,21 @@ func _genera_evento_meteo_casuale() -> void:
|
||||
_on_giornata_selezionata(nuovo_orario)
|
||||
|
||||
elif scelta == 1:
|
||||
var piove = randf() > 0.5
|
||||
if bottone_pioggia:
|
||||
bottone_pioggia.set_pressed_no_signal(piove)
|
||||
_on_pioggia_toggled(piove)
|
||||
# Blocca il trigger della pioggia in cinematic mode se nevica
|
||||
if not is_actively_snowing:
|
||||
var piove = randf() > 0.5
|
||||
if bottone_pioggia:
|
||||
bottone_pioggia.set_pressed_no_signal(piove)
|
||||
_on_pioggia_toggled(piove)
|
||||
|
||||
elif scelta == 2:
|
||||
if not is_raining:
|
||||
if bottone_pioggia:
|
||||
bottone_pioggia.set_pressed_no_signal(true)
|
||||
_on_pioggia_toggled(true)
|
||||
_scatena_fulmine()
|
||||
# Blocca il trigger di tempesta/fulmini se nevica
|
||||
if not is_actively_snowing:
|
||||
if not is_raining:
|
||||
if bottone_pioggia:
|
||||
bottone_pioggia.set_pressed_no_signal(true)
|
||||
_on_pioggia_toggled(true)
|
||||
_scatena_fulmine()
|
||||
|
||||
sto_cambiando_in_cinematic = false
|
||||
|
||||
@@ -372,18 +376,19 @@ func spawn_single_godray() -> void:
|
||||
ray.scale = godray_scale
|
||||
|
||||
# ==========================================
|
||||
# --- LOGICA NEVE AGGIORNATA ---
|
||||
# --- LOGICA NEVE E NEVICATA ---
|
||||
# ==========================================
|
||||
|
||||
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:
|
||||
# Attiva in automatico la nevicata quando nevica, la spegne quando si scioglie
|
||||
if is_snow_accumulated and not is_actively_snowing:
|
||||
_on_nevicata_button_pressed()
|
||||
elif 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
|
||||
@@ -394,12 +399,20 @@ func _on_snow_button_pressed():
|
||||
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
|
||||
|
||||
# Disabilita il pulsante della pioggia. Se pioveva già, spegne la pioggia.
|
||||
if bottone_pioggia:
|
||||
bottone_pioggia.disabled = is_actively_snowing
|
||||
if is_actively_snowing and is_raining:
|
||||
bottone_pioggia.set_pressed_no_signal(false)
|
||||
_on_pioggia_toggled(false)
|
||||
|
||||
if particelle_neve:
|
||||
particelle_neve.emitting = is_actively_snowing
|
||||
|
||||
|
||||
Reference in New Issue
Block a user