Merge pull request 'main' (#2) from main into Chunk

Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
2026-04-21 16:36:48 +00:00
13 changed files with 191 additions and 63 deletions

View File

@@ -6,17 +6,17 @@ class_name ChunkInfo
@export_group("Set Piece Rules (Unique pieces)") @export_group("Set Piece Rules (Unique pieces)")
@export var exclusive_biome: String = "" # Es: "Forest" @export var exclusive_biome: String = "" # Es: "Forest"
@export_group("Base exit (no roation)") @export_group("Base exit")
@export var north: bool = false @export var north: bool = false
@export var est: bool = false @export var est: bool = false
@export var south: bool = false @export var south: bool = false
@export var west: bool = false @export var west: bool = false
@export_group("Margin heights (level 0, 1, 2)") @export_group("Margin heights (level 0, 1, 2)")
@export var height_north: int = 0 @export_range(0, 2, 1) var height_north: int = 0
@export var height_est: int = 0 @export_range(0, 2, 1) var height_est: int = 0
@export var height_south: int = 0 @export_range(0, 2, 1) var height_south: int = 0
@export var height_west: int = 0 @export_range(0, 2, 1) var height_west: int = 0
@export_group("Lamppost") @export_group("Lamppost")
@export var have_lamppost: bool = false @export var have_lamppost: bool = false

View File

@@ -6,19 +6,24 @@ uniform vec4 albedo_color : source_color = vec4(0.1, 0.1, 0.1, 1.0);
global uniform float global_wind_strength; global uniform float global_wind_strength;
global uniform float global_wind_speed; global uniform float global_wind_speed;
global uniform float global_wind_fade;
void vertex() { void vertex() {
//COLOR.r is the drawing. 0 -> lampost (no move); 1.0 is the center of the wire //COLOR.r is the drawing. 0 -> lampost (no move); 1.0 is the center of the wire
float movement = COLOR.r; float movement = COLOR.r;
float wind_amount = global_wind_strength * global_wind_fade;
//Create a wave (based on position and time to be random) //Create a wave (based on position and time to be random)
float wind_wave = 0.0; float wind_wave = 0.0;
if (global_wind_speed > 0.0 && global_wind_strength > 0.0) { float vertical_wave = 0.0;
wind_wave = sin(TIME * global_wind_speed + NODE_POSITION_WORLD.x * 0.5) * global_wind_strength; if (global_wind_speed > 0.0 && wind_amount > 0.0) {
wind_wave = sin(TIME * global_wind_speed + NODE_POSITION_WORLD.x * 0.5 + NODE_POSITION_WORLD.z * 0.35) * wind_amount;
vertical_wave = sin(TIME * global_wind_speed * 0.7 + NODE_POSITION_WORLD.z * 0.35) * wind_amount;
} }
VERTEX.x += wind_wave * 0.1 * movement; VERTEX.x += wind_wave * 0.28 * movement;
VERTEX.z += wind_wave * 0.05 * movement; VERTEX.y += vertical_wave * 0.125 * movement;
VERTEX.z += wind_wave * 0.24 * movement;
} }
void fragment() { void fragment() {

View File

@@ -2,6 +2,7 @@ shader_type canvas_item;
uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap; uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
global uniform float global_wind_speed; global uniform float global_wind_speed;
global uniform float global_wind_fade;
uniform vec4 dust_color : source_color = vec4(1.0, 0.456, 0.125, 0.6); uniform vec4 dust_color : source_color = vec4(1.0, 0.456, 0.125, 0.6);
@@ -30,7 +31,7 @@ void fragment() {
float base_time = TIME * dust_speed; float base_time = TIME * dust_speed;
vec2 osc = vec2(sin(TIME * 0.5), cos(TIME * 0.3)) * wind_oscillation; vec2 osc = vec2(sin(TIME * 0.5), cos(TIME * 0.3)) * wind_oscillation;
float wind_active = step(0.0001, abs(global_wind_speed)); float wind_active = global_wind_fade * step(0.0001, abs(global_wind_speed));
vec2 final_wind = ((wind_speed + osc) * dust_speed) * wind_active; vec2 final_wind = ((wind_speed + osc) * dust_speed) * wind_active;
float final_particle_alpha = 0.0; float final_particle_alpha = 0.0;

View File

@@ -5,6 +5,7 @@ global uniform float global_wind_speed;
global uniform vec2 global_wind_direction; global uniform vec2 global_wind_direction;
global uniform float global_wind_scale; global uniform float global_wind_scale;
global uniform float global_wind_strength; global uniform float global_wind_strength;
global uniform float global_wind_fade;
global uniform float global_snow_start_time; global uniform float global_snow_start_time;
global uniform float global_snow_accumulation_speed; global uniform float global_snow_accumulation_speed;
global uniform float global_snow_melt_time; global uniform float global_snow_melt_time;
@@ -43,12 +44,12 @@ void vertex() {
vec3 instance_pos = MODEL_MATRIX[3].xyz; vec3 instance_pos = MODEL_MATRIX[3].xyz;
float total_angle = radians(rotation_degrees); float total_angle = radians(rotation_degrees);
if (wind_enabled && global_wind_speed > 0.0 && global_wind_strength > 0.0) { if (wind_enabled && global_wind_speed > 0.0 && global_wind_strength > 0.0 && global_wind_fade > 0.0) {
float time = TIME * global_wind_speed; float time = TIME * global_wind_speed;
vec2 noise_uv = (instance_pos.xz * global_wind_scale) + (time * global_wind_direction * 0.5); vec2 noise_uv = (instance_pos.xz * global_wind_scale) + (time * global_wind_direction * 0.5);
float noise_val = textureLod(wind_noise, noise_uv, 2.0).r; float noise_val = textureLod(wind_noise, noise_uv, 2.0).r;
float sway = sin(time + (noise_val * 10.0)); float sway = sin(time + (noise_val * 10.0));
total_angle += (sway * global_wind_strength); total_angle += (sway * global_wind_strength * global_wind_fade);
} }
float h_factor = clamp((instance_pos.y - height_min) / (height_max - height_min), 0.0, 1.0); float h_factor = clamp((instance_pos.y - height_min) / (height_max - height_min), 0.0, 1.0);

View File

@@ -42,8 +42,13 @@ var actual_snow_amount: float = 0.0
var is_storm: bool = false var is_storm: bool = false
var cold_tween: Tween var cold_tween: Tween
var wind_tween: Tween
var is_windy: bool = false var is_windy: bool = false
var thereare_fireflies: bool = false var thereare_fireflies: bool = false
var current_wind_speed: float = 0.0
var current_wind_strength: float = 0.0
var current_wind_fade: float = 0.0
var max_wind_amount: int = 0
func _init(wind: GPUParticles3D, snow: GPUParticles3D, func _init(wind: GPUParticles3D, snow: GPUParticles3D,
fireflies: GPUParticles3D, rain: GPUParticles3D, ray: PackedScene, fireflies: GPUParticles3D, rain: GPUParticles3D, ray: PackedScene,
@@ -61,6 +66,7 @@ func _init(wind: GPUParticles3D, snow: GPUParticles3D,
environment_shadows = envshadows environment_shadows = envshadows
environment = theenvironment environment = theenvironment
environment_config = environmentconfig environment_config = environmentconfig
max_wind_amount = environment_config.wind_amount if environment_config != null else 0
camera = thecamera camera = thecamera
camera_pivot = thecamerapivot camera_pivot = thecamerapivot
thunder_sounds = thundersounds thunder_sounds = thundersounds
@@ -91,6 +97,7 @@ func _ready() -> void:
UIEvents.toggle_rain.connect(toggle_rain) UIEvents.toggle_rain.connect(toggle_rain)
UIEvents.toggle_snow.connect(toggle_snow) UIEvents.toggle_snow.connect(toggle_snow)
UIEvents.toggle_wind.connect(toggle_wind) UIEvents.toggle_wind.connect(toggle_wind)
UIEvents.wind_change.connect(change_wind_strength)
UIEvents.toggle_fireflies.connect(toggle_fireflies) UIEvents.toggle_fireflies.connect(toggle_fireflies)
UIEvents.toggle_storm.connect(toggle_storm) UIEvents.toggle_storm.connect(toggle_storm)
UIEvents.toggle_dust.connect(toggle_dust) UIEvents.toggle_dust.connect(toggle_dust)
@@ -303,6 +310,7 @@ func toggle_wind(value: bool):
#disable wind and set default values and materials #disable wind and set default values and materials
func init_wind(): func init_wind():
_update_wind_amount_from_strength(environment_config.wind_strength)
if particles_wind: if particles_wind:
particles_wind.visible = true particles_wind.visible = true
particles_wind.emitting = false particles_wind.emitting = false
@@ -334,16 +342,73 @@ func _apply_wind_config() -> void:
proc_mat_wind.direction = wind_axis proc_mat_wind.direction = wind_axis
particles_wind.global_transform = Transform3D(Basis(wind_cross, wind_axis, wind_up), particles_wind.global_position) particles_wind.global_transform = Transform3D(Basis(wind_cross, wind_axis, wind_up), particles_wind.global_position)
_apply_wind_state() _apply_wind_state(true)
func _apply_wind_state() -> void: func _apply_wind_state(immediate: bool = false) -> void:
if environment_config == null: if environment_config == null:
return return
if wind_tween and wind_tween.is_valid():
wind_tween.kill()
var active_wind_speed := environment_config.wind_speed if is_windy else 0.0 var active_wind_speed := environment_config.wind_speed if is_windy else 0.0
var active_wind_strength := environment_config.wind_strength if is_windy else 0.0 var active_wind_strength := environment_config.wind_strength if is_windy else 0.0
RenderingServer.global_shader_parameter_set("global_wind_speed", active_wind_speed) var active_wind_fade := 1.0 if is_windy else 0.0
RenderingServer.global_shader_parameter_set("global_wind_strength", active_wind_strength) if immediate:
_set_current_wind_speed(active_wind_speed)
_set_current_wind_strength(active_wind_strength)
_set_current_wind_fade(active_wind_fade)
return
_set_current_wind_speed(environment_config.wind_speed)
_set_current_wind_strength(environment_config.wind_strength)
wind_tween = create_tween()
wind_tween.tween_method(_set_current_wind_fade, current_wind_fade, active_wind_fade, environment_config.wind_fade_in_out_time)
wind_tween.tween_callback(_finish_wind_fade_out)
func _set_current_wind_speed(value: float) -> void:
current_wind_speed = value
RenderingServer.global_shader_parameter_set("global_wind_speed", value)
func _set_current_wind_strength(value: float) -> void:
current_wind_strength = value
RenderingServer.global_shader_parameter_set("global_wind_strength", value)
func _set_current_wind_fade(value: float) -> void:
current_wind_fade = value
RenderingServer.global_shader_parameter_set("global_wind_fade", value)
func _finish_wind_fade_out() -> void:
if is_windy:
return
_set_current_wind_speed(0.0)
_set_current_wind_strength(0.0)
_set_current_wind_fade(0.0)
func change_wind_strength(value: float) -> void:
if environment_config == null:
return
environment_config.wind_strength = value
_update_wind_amount_from_strength(value)
if is_windy or current_wind_fade > 0.0:
_set_current_wind_strength(value)
if particles_wind:
particles_wind.amount = environment_config.wind_amount
func _update_wind_amount_from_strength(value: float) -> void:
if environment_config == null:
return
if max_wind_amount <= 0:
max_wind_amount = max(environment_config.wind_amount, 1)
var normalized_strength: float = clamp(value, 0.0, 1.0)
var amount_ratio: float = normalized_strength
if normalized_strength > 0.0 and normalized_strength < 0.3:
amount_ratio = lerp(0.08, 0.25, normalized_strength / 0.3)
environment_config.wind_amount = roundi(max_wind_amount * amount_ratio)
func _apply_cloud_config() -> void: func _apply_cloud_config() -> void:
var dir = environment_config.wind_direction var dir = environment_config.wind_direction

View File

@@ -157,6 +157,7 @@ extends Resource
@export var cloud_speed: float = 0.05 #Cloud movement speed in sky shader @export var cloud_speed: float = 0.05 #Cloud movement speed in sky shader
@export_range(0.01, 1.0) var cloud_scale_envshadows_rate: float = 0.01 #Cloud scale multiplier for environment shadows @export_range(0.01, 1.0) var cloud_scale_envshadows_rate: float = 0.01 #Cloud scale multiplier for environment shadows
@export_range(0.01, 1.0) var cloud_speed_envshadows_rate: float = 0.5 #Cloud speed multiplier for environment shadows @export_range(0.01, 1.0) var cloud_speed_envshadows_rate: float = 0.5 #Cloud speed multiplier for environment shadows
@export var wind_fade_in_out_time: float = 1.2 #fade out to time when wind is turned off or when is turned on
#Firefly settings (visible only at night) #Firefly settings (visible only at night)
@export_group("Fireflies") @export_group("Fireflies")

View File

@@ -19,7 +19,7 @@ func set_particles_node_color(node: GPUParticles3D, new_color: Color) -> void:
unique_mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED unique_mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
mesh.material = unique_mat mesh.material = unique_mat
func turnon() -> void: func turn_on() -> void:
if rocket: if rocket:
rocket.emitting = true rocket.emitting = true

View File

@@ -8,6 +8,8 @@ signal toggle_snow(value: bool)
@warning_ignore("unused_signal") @warning_ignore("unused_signal")
signal toggle_wind(value: bool) signal toggle_wind(value: bool)
@warning_ignore("unused_signal") @warning_ignore("unused_signal")
signal wind_change(value: float)
@warning_ignore("unused_signal")
signal toggle_fireflies(value: bool) signal toggle_fireflies(value: bool)
@warning_ignore("unused_signal") @warning_ignore("unused_signal")
signal toggle_storm(value: bool) signal toggle_storm(value: bool)

View File

@@ -225,12 +225,21 @@ theme_override_colors/font_hover_pressed_color = Color(1, 1, 1, 1)
theme_override_colors/font_outline_color = Color(1, 1, 1, 1) theme_override_colors/font_outline_color = Color(1, 1, 1, 1)
text = "Wind" text = "Wind"
[node name="WindSlider" type="HSlider" parent="Control" unique_id=28050098]
layout_mode = 0
offset_left = 26.0
offset_top = 124.0
offset_right = 205.0
offset_bottom = 140.0
max_value = 1.0
step = 0.01
[node name="Fireflies" type="CheckButton" parent="Control" unique_id=1046228444] [node name="Fireflies" type="CheckButton" parent="Control" unique_id=1046228444]
layout_mode = 0 layout_mode = 0
offset_left = 21.0 offset_left = 21.0
offset_top = 115.0 offset_top = 169.0
offset_right = 130.0 offset_right = 130.0
offset_bottom = 146.0 offset_bottom = 200.0
theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_focus_color = Color(1, 1, 1, 1) theme_override_colors/font_focus_color = Color(1, 1, 1, 1)
theme_override_colors/font_pressed_color = Color(1, 1, 1, 1) theme_override_colors/font_pressed_color = Color(1, 1, 1, 1)
@@ -266,18 +275,18 @@ text = "Time 00:00"
[node name="DayTimeSlider" type="HSlider" parent="Control" unique_id=1865778345] [node name="DayTimeSlider" type="HSlider" parent="Control" unique_id=1865778345]
layout_mode = 0 layout_mode = 0
offset_left = 26.0 offset_left = 26.0
offset_top = 174.0 offset_top = 228.0
offset_right = 205.0 offset_right = 205.0
offset_bottom = 190.0 offset_bottom = 244.0
max_value = 1.0 max_value = 1.0
step = 0.01 step = 0.01
[node name="Dust" type="CheckButton" parent="Control" unique_id=760281365] [node name="Dust" type="CheckButton" parent="Control" unique_id=760281365]
layout_mode = 0 layout_mode = 0
offset_left = 21.0 offset_left = 21.0
offset_top = 250.0 offset_top = 304.0
offset_right = 150.0 offset_right = 150.0
offset_bottom = 281.0 offset_bottom = 335.0
theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_focus_color = Color(1, 1, 1, 1) theme_override_colors/font_focus_color = Color(1, 1, 1, 1)
theme_override_colors/font_pressed_color = Color(1, 1, 1, 1) theme_override_colors/font_pressed_color = Color(1, 1, 1, 1)
@@ -290,9 +299,9 @@ text = "Dust"
[node name="Blur" type="CheckButton" parent="Control" unique_id=1083708100] [node name="Blur" type="CheckButton" parent="Control" unique_id=1083708100]
layout_mode = 0 layout_mode = 0
offset_left = 21.0 offset_left = 21.0
offset_top = 278.0 offset_top = 332.0
offset_right = 150.0 offset_right = 150.0
offset_bottom = 309.0 offset_bottom = 363.0
theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_focus_color = Color(1, 1, 1, 1) theme_override_colors/font_focus_color = Color(1, 1, 1, 1)
theme_override_colors/font_pressed_color = Color(1, 1, 1, 1) theme_override_colors/font_pressed_color = Color(1, 1, 1, 1)
@@ -305,9 +314,9 @@ text = "Blur"
[node name="Pause" type="CheckButton" parent="Control" unique_id=1587043871] [node name="Pause" type="CheckButton" parent="Control" unique_id=1587043871]
layout_mode = 0 layout_mode = 0
offset_left = 21.0 offset_left = 21.0
offset_top = 189.0 offset_top = 243.0
offset_right = 158.0 offset_right = 158.0
offset_bottom = 220.0 offset_bottom = 274.0
theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_focus_color = Color(1, 1, 1, 1) theme_override_colors/font_focus_color = Color(1, 1, 1, 1)
theme_override_colors/font_pressed_color = Color(1, 1, 1, 1) theme_override_colors/font_pressed_color = Color(1, 1, 1, 1)
@@ -319,9 +328,9 @@ text = "Pause Time"
[node name="Shadows" type="CheckButton" parent="Control" unique_id=283354318] [node name="Shadows" type="CheckButton" parent="Control" unique_id=283354318]
layout_mode = 0 layout_mode = 0
offset_left = 21.0 offset_left = 21.0
offset_top = 302.0 offset_top = 356.0
offset_right = 150.0 offset_right = 150.0
offset_bottom = 333.0 offset_bottom = 387.0
theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_focus_color = Color(1, 1, 1, 1) theme_override_colors/font_focus_color = Color(1, 1, 1, 1)
theme_override_colors/font_pressed_color = Color(1, 1, 1, 1) theme_override_colors/font_pressed_color = Color(1, 1, 1, 1)
@@ -334,19 +343,22 @@ text = "Shadows"
[node name="Guide" type="Label" parent="Control" unique_id=2121474959] [node name="Guide" type="Label" parent="Control" unique_id=2121474959]
layout_mode = 0 layout_mode = 0
offset_left = 26.0 offset_left = 26.0
offset_top = 347.0 offset_top = 401.0
offset_right = 236.0 offset_right = 339.0
offset_bottom = 474.0 offset_bottom = 606.0
text = "R-> Reset isometric camera text = "R-> Reset isometric camera
C-> Toggle cinematic mode C-> Toggle cinematic mode
Z-> soft zoom Z-> soft zoom
Manual controls (1-5) Manual controls (1-5)
T -> go to next stop T -> go to next stop
F -> fireworks" F -> fireworks
BACKSPACE -> stop train
ARROW UP/DOWN -> change train speed"
[connection signal="toggled" from="Control/Snow" to="Control" method="_on_snow_toggled"] [connection signal="toggled" from="Control/Snow" to="Control" method="_on_snow_toggled"]
[connection signal="toggled" from="Control/Rain" to="Control" method="_on_rain_toggled"] [connection signal="toggled" from="Control/Rain" to="Control" method="_on_rain_toggled"]
[connection signal="toggled" from="Control/Wind" to="Control" method="_on_wind_toggled"] [connection signal="toggled" from="Control/Wind" to="Control" method="_on_wind_toggled"]
[connection signal="value_changed" from="Control/WindSlider" to="Control" method="_on_wind_slider_value_changed"]
[connection signal="toggled" from="Control/Fireflies" to="Control" method="_on_fireflies_toggled"] [connection signal="toggled" from="Control/Fireflies" to="Control" method="_on_fireflies_toggled"]
[connection signal="toggled" from="Control/Storm" to="Control" method="_on_storm_toggled"] [connection signal="toggled" from="Control/Storm" to="Control" method="_on_storm_toggled"]
[connection signal="value_changed" from="Control/DayTimeSlider" to="Control" method="_on_day_time_slider_value_changed"] [connection signal="value_changed" from="Control/DayTimeSlider" to="Control" method="_on_day_time_slider_value_changed"]

View File

@@ -7,7 +7,7 @@ extends Path3D
@export var axes_distance: float = 3.0 @export var axes_distance: float = 3.0
@export var rail_distance: float = 1.2 @export var rail_distance: float = 1.2
@export var cameras: Node3D @export var cameras: Node3D
@export_range(0.0, 1.0) var basic_swing: float = 0.5 @export_range(0.0, 1.0) var basic_swing: float = 0.1
@export_group("Rails Bulding") @export_group("Rails Bulding")
@export var sleepers_distance: float = 1.0 @export var sleepers_distance: float = 1.0
@@ -37,6 +37,8 @@ var fireworks_colors: Array[Color] = [
var train_instance: Node3D var train_instance: Node3D
var train_progress: float = 0.0 var train_progress: float = 0.0
var swing_time: float = 0.0 var swing_time: float = 0.0
var curve_roll: float = 0.0
var curve_pitch: float = 0.0
var stop_offset: Array[float] = [] var stop_offset: Array[float] = []
var stops_position: Array[Vector3] = [] var stops_position: Array[Vector3] = []
@@ -52,7 +54,7 @@ func _ready() -> void:
build_train() build_train()
_plan_stops() _plan_stops()
else: else:
print("WARNING: Draw your Path3D!") print("WARNING: Draw Path3D for rails!")
func build_rails() -> void: func build_rails() -> void:
var mat_wood = StandardMaterial3D.new() var mat_wood = StandardMaterial3D.new()
@@ -112,16 +114,16 @@ func build_rails() -> void:
rail_piece.add_child(rail_dx) rail_piece.add_child(rail_dx)
func _plan_stops() -> void: func _plan_stops() -> void:
var currnet_stops = [] var current_stops = []
for child in get_children(): for child in get_children():
if child is Marker3D: if child is Marker3D:
var offset = curve.get_closest_offset(child.position) var offset = curve.get_closest_offset(child.position)
currnet_stops.append({ current_stops.append({
"offset": offset, "offset": offset,
"position": child.global_position "position": child.global_position
}) })
currnet_stops.sort_custom(func(a, b): return a["offset"] < b["offset"]) current_stops.sort_custom(func(a, b): return a["offset"] < b["offset"])
for data in currnet_stops: for data in current_stops:
stop_offset.append(data["offset"]) stop_offset.append(data["offset"])
stops_position.append(data["position"]) stops_position.append(data["position"])
@@ -130,9 +132,9 @@ func _input(event: InputEvent) -> void:
if event.keycode == KEY_T: if event.keycode == KEY_T:
_goto_next_stop() _goto_next_stop()
elif event.keycode == KEY_F: elif event.keycode == KEY_F:
_test_manual_fires() _test_manual_fireworks()
func _test_manual_fires() -> void: func _test_manual_fireworks() -> void:
if fireworks_scene == null or train_instance == null: return if fireworks_scene == null or train_instance == null: return
var firework_number = randi_range(5, 8) var firework_number = randi_range(5, 8)
@@ -146,8 +148,8 @@ func _test_manual_fires() -> void:
if fire_root.has_method("set_color"): if fire_root.has_method("set_color"):
fire_root.set_color(fireworks_colors.pick_random()) fire_root.set_color(fireworks_colors.pick_random())
if fire_root.has_method("turnon"): if fire_root.has_method("turn_on"):
fire_root.turnon() fire_root.turn_on()
await get_tree().create_timer(randf_range(0.2, 0.6)).timeout await get_tree().create_timer(randf_range(0.2, 0.6)).timeout
@@ -168,6 +170,8 @@ func input_controls_management(delta: float) -> void:
train_speed += manual_acceleration * delta train_speed += manual_acceleration * delta
elif Input.is_action_pressed("ui_down"): elif Input.is_action_pressed("ui_down"):
train_speed -= manual_acceleration * delta train_speed -= manual_acceleration * delta
elif Input.is_action_pressed("ui_text_backspace"):
train_speed = 0
train_speed = clamp(train_speed, speed_min, speed_max) train_speed = clamp(train_speed, speed_min, speed_max)
func train_move(delta: float) -> void: func train_move(delta: float) -> void:
@@ -209,25 +213,42 @@ func train_move(delta: float) -> void:
if stop_offset.size() > 0: next_stop_index = stop_offset.size() - 1 if stop_offset.size() > 0: next_stop_index = stop_offset.size() - 1
var center_position = to_global(curve.sample_baked(train_progress, true)) var center_position = to_global(curve.sample_baked(train_progress, true))
var prog_back = wrapf(train_progress - 2.0, 0.0, total_length)
var back_position = to_global(curve.sample_baked(prog_back, true))
var prog_forward = wrapf(train_progress + 2.0, 0.0, total_length) var prog_forward = wrapf(train_progress + 2.0, 0.0, total_length)
var forward_position = to_global(curve.sample_baked(prog_forward, true)) var forward_position = to_global(curve.sample_baked(prog_forward, true))
if center_position.distance_to(forward_position) > 0.01: if center_position.distance_to(forward_position) > 0.01:
train_instance.global_position = center_position train_instance.global_position = center_position
train_instance.look_at(forward_position, Vector3.UP) train_instance.look_at(forward_position, Vector3.UP)
train_instance.rotate_y(PI) train_instance.rotate_y(PI)
if cameras: if cameras:
cameras.global_position = center_position cameras.global_position = center_position
cameras.global_basis = train_instance.global_basis cameras.global_basis = train_instance.global_basis
var real_speed = abs(train_speed * stop_multiply)
var speed_factor = clamp(real_speed / max(speed_max, 0.001), 0.0, 1.0)
var dir_prev = (center_position - back_position).normalized()
var dir_next = (forward_position - center_position).normalized()
var signed_curve = dir_prev.cross(dir_next).y
var curve_amount = clamp(abs(signed_curve) * 8.0, 0.0, 1.0)
curve_roll = lerp(curve_roll, (-signed_curve * 0.08) * speed_factor, delta * 4.0)
curve_pitch = lerp(curve_pitch, curve_amount * 0.012 * speed_factor, delta * 4.0)
if not stop_ongoing: if not stop_ongoing:
var real_speed = abs(train_speed * stop_multiply) swing_time += delta * real_speed * (2.0 + curve_amount)
swing_time += delta * real_speed * 2.0
var amplitude_z = 0.006 * basic_swing var amplitude_z = 0.006 * basic_swing
var amplitude_x = 0.004 * basic_swing var amplitude_x = 0.004 * basic_swing
var curve_sway = sin(swing_time * 1.35) * 0.01 * curve_amount * speed_factor
train_instance.rotation.z += sin(swing_time) * amplitude_z train_instance.rotation.z += sin(swing_time) * amplitude_z
train_instance.rotation.x += cos(swing_time * 0.8) * amplitude_x train_instance.rotation.x += cos(swing_time * 0.8) * amplitude_x
train_instance.rotation.z += curve_roll + curve_sway
train_instance.rotation.x += curve_pitch
else:
train_instance.rotation.z += curve_roll
train_instance.rotation.x += curve_pitch
func _execute_stop(go_forward: bool = true) -> void: func _execute_stop(go_forward: bool = true) -> void:
stop_ongoing = true stop_ongoing = true
@@ -258,8 +279,8 @@ func _execute_stop(go_forward: bool = true) -> void:
if fire_root.has_method("set_color"): if fire_root.has_method("set_color"):
fire_root.set_color(fireworks_colors.pick_random()) fire_root.set_color(fireworks_colors.pick_random())
if fire_root.has_method("turnon"): if fire_root.has_method("turn_on"):
fire_root.turnon() fire_root.turn_on()
await get_tree().create_timer(randf_range(0.3, 0.8)).timeout await get_tree().create_timer(randf_range(0.3, 0.8)).timeout

View File

@@ -3,10 +3,13 @@ extends Control
@onready var day_night: EnvironmentManagerRoot = get_node_or_null("../DayNight") as EnvironmentManagerRoot @onready var day_night: EnvironmentManagerRoot = get_node_or_null("../DayNight") as EnvironmentManagerRoot
@onready var day_time_label: Label = $DayTimeLabel @onready var day_time_label: Label = $DayTimeLabel
@onready var day_time_slider: HSlider = $DayTimeSlider @onready var day_time_slider: HSlider = $DayTimeSlider
@onready var wind_slider: HSlider = get_node_or_null("WindSlider") as HSlider
func _ready() -> void: func _ready() -> void:
UIEvents.day_time_changed.connect(_on_day_time_changed) UIEvents.day_time_changed.connect(_on_day_time_changed)
if day_night != null and day_night.environment_config != null and wind_slider != null:
wind_slider.set_value_no_signal(day_night.environment_config.wind_strength)
_sync_day_time_ui() _sync_day_time_ui()
func _on_rain_toggled(toggled_on: bool) -> void: func _on_rain_toggled(toggled_on: bool) -> void:
@@ -18,6 +21,9 @@ func _on_snow_toggled(toggled_on: bool) -> void:
func _on_wind_toggled(toggled_on: bool) -> void: func _on_wind_toggled(toggled_on: bool) -> void:
UIEvents.toggle_wind.emit(toggled_on) UIEvents.toggle_wind.emit(toggled_on)
func _on_wind_slider_value_changed(value: float) -> void:
UIEvents.wind_change.emit(value)
func _on_fireflies_toggled(toggled_on: bool) -> void: func _on_fireflies_toggled(toggled_on: bool) -> void:
UIEvents.toggle_fireflies.emit(toggled_on) UIEvents.toggle_fireflies.emit(toggled_on)

View File

@@ -220,9 +220,9 @@ text = "Storm"
[node name="DayTimeLabel" type="Label" parent="Control" unique_id=1673596218] [node name="DayTimeLabel" type="Label" parent="Control" unique_id=1673596218]
layout_mode = 0 layout_mode = 0
offset_left = 26.0 offset_left = 26.0
offset_top = 150.0 offset_top = 172.0
offset_right = 360.0 offset_right = 360.0
offset_bottom = 173.0 offset_bottom = 195.0
theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_outline_color = Color(1, 1, 1, 1) theme_override_colors/font_outline_color = Color(1, 1, 1, 1)
text = "Time 00:00" text = "Time 00:00"
@@ -230,18 +230,18 @@ text = "Time 00:00"
[node name="DayTimeSlider" type="HSlider" parent="Control" unique_id=530788076] [node name="DayTimeSlider" type="HSlider" parent="Control" unique_id=530788076]
layout_mode = 0 layout_mode = 0
offset_left = 26.0 offset_left = 26.0
offset_top = 174.0 offset_top = 196.0
offset_right = 205.0 offset_right = 205.0
offset_bottom = 190.0 offset_bottom = 212.0
max_value = 1.0 max_value = 1.0
step = 0.01 step = 0.01
[node name="Dust" type="CheckButton" parent="Control" unique_id=2023312048] [node name="Dust" type="CheckButton" parent="Control" unique_id=2023312048]
layout_mode = 0 layout_mode = 0
offset_left = 21.0 offset_left = 21.0
offset_top = 250.0 offset_top = 272.0
offset_right = 150.0 offset_right = 150.0
offset_bottom = 281.0 offset_bottom = 303.0
theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_focus_color = Color(1, 1, 1, 1) theme_override_colors/font_focus_color = Color(1, 1, 1, 1)
theme_override_colors/font_pressed_color = Color(1, 1, 1, 1) theme_override_colors/font_pressed_color = Color(1, 1, 1, 1)
@@ -254,9 +254,9 @@ text = "Dust"
[node name="Blur" type="CheckButton" parent="Control" unique_id=1758807681] [node name="Blur" type="CheckButton" parent="Control" unique_id=1758807681]
layout_mode = 0 layout_mode = 0
offset_left = 21.0 offset_left = 21.0
offset_top = 278.0 offset_top = 300.0
offset_right = 150.0 offset_right = 150.0
offset_bottom = 309.0 offset_bottom = 331.0
theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_focus_color = Color(1, 1, 1, 1) theme_override_colors/font_focus_color = Color(1, 1, 1, 1)
theme_override_colors/font_pressed_color = Color(1, 1, 1, 1) theme_override_colors/font_pressed_color = Color(1, 1, 1, 1)
@@ -269,9 +269,9 @@ text = "Blur"
[node name="Pause" type="CheckButton" parent="Control" unique_id=156986934] [node name="Pause" type="CheckButton" parent="Control" unique_id=156986934]
layout_mode = 0 layout_mode = 0
offset_left = 21.0 offset_left = 21.0
offset_top = 189.0 offset_top = 211.0
offset_right = 158.0 offset_right = 158.0
offset_bottom = 220.0 offset_bottom = 242.0
theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_focus_color = Color(1, 1, 1, 1) theme_override_colors/font_focus_color = Color(1, 1, 1, 1)
theme_override_colors/font_pressed_color = Color(1, 1, 1, 1) theme_override_colors/font_pressed_color = Color(1, 1, 1, 1)
@@ -283,9 +283,9 @@ text = "Pause Time"
[node name="Shadows" type="CheckButton" parent="Control" unique_id=1751516495] [node name="Shadows" type="CheckButton" parent="Control" unique_id=1751516495]
layout_mode = 0 layout_mode = 0
offset_left = 21.0 offset_left = 21.0
offset_top = 302.0 offset_top = 324.0
offset_right = 150.0 offset_right = 150.0
offset_bottom = 333.0 offset_bottom = 355.0
theme_override_colors/font_color = Color(1, 1, 1, 1) theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_focus_color = Color(1, 1, 1, 1) theme_override_colors/font_focus_color = Color(1, 1, 1, 1)
theme_override_colors/font_pressed_color = Color(1, 1, 1, 1) theme_override_colors/font_pressed_color = Color(1, 1, 1, 1)
@@ -295,6 +295,15 @@ theme_override_colors/font_outline_color = Color(1, 1, 1, 1)
button_pressed = true button_pressed = true
text = "Shadows" text = "Shadows"
[node name="WindSlider" type="HSlider" parent="Control" unique_id=25258103]
layout_mode = 0
offset_left = 26.0
offset_top = 146.0
offset_right = 205.0
offset_bottom = 162.0
max_value = 1.0
step = 0.01
[node name="Scene" type="Node" parent="." unique_id=701973010] [node name="Scene" type="Node" parent="." unique_id=701973010]
[node name="Grass2" parent="Scene" unique_id=838519336 instance=ExtResource("7_pd1r3")] [node name="Grass2" parent="Scene" unique_id=838519336 instance=ExtResource("7_pd1r3")]
@@ -331,3 +340,4 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 23)
[connection signal="toggled" from="Control/Blur" to="Control" method="_on_blur_toggled"] [connection signal="toggled" from="Control/Blur" to="Control" method="_on_blur_toggled"]
[connection signal="toggled" from="Control/Pause" to="Control" method="_on_pause_toggled"] [connection signal="toggled" from="Control/Pause" to="Control" method="_on_pause_toggled"]
[connection signal="toggled" from="Control/Shadows" to="Control" method="_on_shadows_toggled"] [connection signal="toggled" from="Control/Shadows" to="Control" method="_on_shadows_toggled"]
[connection signal="value_changed" from="Control/WindSlider" to="Control" method="_on_wind_slider_value_changed"]

View File

@@ -109,3 +109,7 @@ global_rain_puddle_amount={
"type": "float", "type": "float",
"value": 0.0 "value": 0.0
} }
global_wind_fade={
"type": "float",
"value": 1.2
}