Merge pull request 'biome_gen_river' (#10) from biome_gen_river into main

Reviewed-on: #10
This commit was merged in pull request #10.
This commit is contained in:
2026-05-04 22:00:08 +00:00
16 changed files with 2433 additions and 15 deletions

View File

@@ -501,6 +501,7 @@ func _register_cell_with_ray(grid_pos: Vector2i) -> bool:
right_info_node = info_list[0]
var exit_found = {"north": false, "est": false, "south": false, "west": false}
var river_exit_found = {"north": false, "est": false, "south": false, "west": false}
var height_found = {"north": 0, "est": 0, "south": 0, "west": 0}
var have_lamppost = false
@@ -510,6 +511,7 @@ func _register_cell_with_ray(grid_pos: Vector2i) -> bool:
var rotation_steps = roundi(rad_to_deg(right_info_node.global_rotation.y) / -90.0)
var data = right_info_node.get_rotated_data(rotation_steps)
exit_found = data["connections"]
river_exit_found = data["river_connections"]
height_found = data["heights"]
if "have_lamppost" in right_info_node:
@@ -519,6 +521,7 @@ func _register_cell_with_ray(grid_pos: Vector2i) -> bool:
board[grid_pos] = {
"type": "obstacle",
"exit": exit_found,
"river_exit": river_exit_found,
"heights": height_found,
"node": root_chunk,
"info": right_info_node,
@@ -536,6 +539,10 @@ func _add_compatible_biome(grid_pos: Vector2i) -> void:
var req_conn_est = _needed_connection(grid_pos + Vector2i(1, 0), "west")
var req_conn_south = _needed_connection(grid_pos + Vector2i(0, 1), "north")
var req_conn_west = _needed_connection(grid_pos + Vector2i(-1, 0), "est")
var req_river_north = _needed_river_connection(grid_pos + Vector2i(0, -1), "south")
var req_river_est = _needed_river_connection(grid_pos + Vector2i(1, 0), "west")
var req_river_south = _needed_river_connection(grid_pos + Vector2i(0, 1), "north")
var req_river_west = _needed_river_connection(grid_pos + Vector2i(-1, 0), "est")
var req_height_north = _needed_heights(grid_pos + Vector2i(0, -1), "south")
var req_height_est = _needed_heights(grid_pos + Vector2i(1, 0), "west")
@@ -557,12 +564,17 @@ func _add_compatible_biome(grid_pos: Vector2i) -> void:
var rot = candidate["rotation"]
var data = candidate["data"]
var u_conn = data["connections"]
var u_river_conn = data["river_connections"]
var u_height = data["heights"]
var match_conn_n = (req_conn_north == -1) or ((req_conn_north == 1) == u_conn["north"])
var match_conn_e = (req_conn_est == -1) or ((req_conn_est == 1) == u_conn["est"])
var match_conn_s = (req_conn_south == -1) or ((req_conn_south == 1) == u_conn["south"])
var match_conn_o = (req_conn_west == -1) or ((req_conn_west == 1) == u_conn["west"])
var match_river_n = (req_river_north == -1) or ((req_river_north == 1) == u_river_conn["north"])
var match_river_e = (req_river_est == -1) or ((req_river_est == 1) == u_river_conn["est"])
var match_river_s = (req_river_south == -1) or ((req_river_south == 1) == u_river_conn["south"])
var match_river_o = (req_river_west == -1) or ((req_river_west == 1) == u_river_conn["west"])
var match_alt_n = (req_height_north == -1) or (req_height_north == u_height["north"])
var match_alt_e = (req_height_est == -1) or (req_height_est == u_height["est"])
@@ -575,7 +587,7 @@ func _add_compatible_biome(grid_pos: Vector2i) -> void:
var diff_o = abs(u_height["west"] - height_target) if req_height_west == -1 else 0
var excessive_jumps = diff_n > 1 or diff_e > 1 or diff_s > 1 or diff_o > 1
if match_conn_n and match_conn_e and match_conn_s and match_conn_o and match_alt_n and match_alt_e and match_alt_s and match_alt_o and not excessive_jumps:
if match_conn_n and match_conn_e and match_conn_s and match_conn_o and match_river_n and match_river_e and match_river_s and match_river_o and match_alt_n and match_alt_e and match_alt_s and match_alt_o and not excessive_jumps:
var score = 0
if req_height_north == -1 and u_height["north"] == height_target: score += 1
if req_height_est == -1 and u_height["est"] == height_target: score += 1
@@ -608,6 +620,7 @@ func _add_compatible_biome(grid_pos: Vector2i) -> void:
board[grid_pos] = {
"type": "bioma",
"exit": choise.data["connections"],
"river_exit": choise.data["river_connections"],
"heights": choise.data["heights"],
"node": new_chunk,
"info": info_new,
@@ -633,6 +646,7 @@ func _add_compatible_biome(grid_pos: Vector2i) -> void:
board[grid_pos] = {
"type": "biome",
"exit": {"north":false, "est":false, "south":false, "west":false},
"river_exit": {"north":false, "est":false, "south":false, "west":false},
"heights": safe_heights,
"node": backup,
"info": info_backup,
@@ -646,6 +660,13 @@ func _needed_connection(near_pos: Vector2i, side_needed: String) -> int:
return 1 if board[near_pos]["exit"][side_needed] else 0
return -1
func _needed_river_connection(near_pos: Vector2i, side_needed: String) -> int:
if not board.has(near_pos):
_register_cell_with_ray(near_pos)
if board.has(near_pos) and board[near_pos].has("river_exit"):
return 1 if board[near_pos]["river_exit"][side_needed] else 0
return -1
func _needed_heights(near_pos: Vector2i, side_needed: String) -> int:
if board.has(near_pos) and board[near_pos].has("heights"):
return board[near_pos]["heights"][side_needed]

View File

@@ -12,6 +12,12 @@ class_name ChunkInfo
@export var south: bool = false
@export var west: bool = false
@export_group("River exit")
@export var river_north: bool = false
@export var river_est: bool = false
@export var river_south: bool = false
@export var river_west: bool = false
@export_group("Margin heights (level 0, 1, 2)")
@export_range(0, 2, 1) var height_north: int = 0
@export_range(0, 2, 1) var height_est: int = 0
@@ -29,14 +35,17 @@ func _ready() -> void:
func get_rotated_data(steps_90: int) -> Dictionary:
var original_exit = [north, est, south, west]
var original_river_exit = [river_north, river_est, river_south, river_west]
var original_height = [height_north, height_est, height_south, height_west]
var calculated_exit = []
var calculated_river_exit = []
var calculated_height = []
for i in range(4):
var index = (i - steps_90 + 4) % 4
calculated_exit.append(original_exit[index])
calculated_river_exit.append(original_river_exit[index])
calculated_height.append(original_height[index])
return {
@@ -44,6 +53,10 @@ func get_rotated_data(steps_90: int) -> Dictionary:
"north": calculated_exit[0], "est": calculated_exit[1],
"south": calculated_exit[2], "west": calculated_exit[3]
},
"river_connections": {
"north": calculated_river_exit[0], "est": calculated_river_exit[1],
"south": calculated_river_exit[2], "west": calculated_river_exit[3]
},
"heights": {
"north": calculated_height[0], "est": calculated_height[1],
"south": calculated_height[2], "west": calculated_height[3]

View File

@@ -20,17 +20,14 @@ const SNOW_CAP_SHADER: Shader = preload("res://core/daynight/snow_cap.gdshader")
var _mesh_instance: MeshInstance3D
func _ready() -> void:
add_to_group("weather_overlay_ignore")
_ensure_mesh_instance()
_rebuild()
func rebuild() -> void:
_rebuild()
func _ensure_mesh_instance() -> void:
_mesh_instance = get_node_or_null("SnowCapMesh") as MeshInstance3D
if _mesh_instance != null:
@@ -41,7 +38,6 @@ func _ensure_mesh_instance() -> void:
_mesh_instance.add_to_group("weather_overlay_ignore")
add_child(_mesh_instance)
func _rebuild() -> void:
var cap_width: float = 0.0
var cap_depth: float = 0.0
@@ -78,7 +74,6 @@ func _rebuild() -> void:
_mesh_instance.material_override = _build_material(cap_width, cap_depth)
_mesh_instance.visible = true
func _build_material(cap_width: float, cap_depth: float) -> ShaderMaterial:
var material := ShaderMaterial.new()
material.shader = SNOW_CAP_SHADER
@@ -87,7 +82,6 @@ func _build_material(cap_width: float, cap_depth: float) -> ShaderMaterial:
material.set_shader_parameter("half_depth", cap_depth * 0.5)
return material
func _get_target_aabb(target_mesh: MeshInstance3D) -> AABB:
var points: Array[Vector3] = []
for point in _get_aabb_points(target_mesh.get_aabb()):
@@ -98,7 +92,6 @@ func _get_target_aabb(target_mesh: MeshInstance3D) -> AABB:
merged = merged.expand(point)
return merged
func _get_aabb_points(aabb: AABB) -> Array[Vector3]:
var p: Vector3 = aabb.position
var s: Vector3 = aabb.size

View File

@@ -51,6 +51,8 @@ var current_wind_strength: float = 0.0
var current_wind_fade: float = 0.0
var max_wind_amount: int = 0
var random_weather_restore_tween: Tween
var random_event_remaining: float = 0.0
var random_event_label_seconds: int = -1
func _init(wind: GPUParticles3D, snow: GPUParticles3D,
fireflies: GPUParticles3D, rain: GPUParticles3D, ray: PackedScene,
@@ -112,6 +114,7 @@ func _ready() -> void:
_emit_weather_event_label()
func _process(delta: float) -> void:
_update_random_event_label(delta)
_follow_camera()
@@ -449,6 +452,8 @@ func _update_wind_amount_from_strength(value: float) -> void:
func trigger_random_weather_event(duration: float = 0.0) -> void:
if random_weather_restore_tween and random_weather_restore_tween.is_valid():
random_weather_restore_tween.kill()
random_event_remaining = 0.0
random_event_label_seconds = -1
var previous_rain: bool = is_raining
var previous_snow: bool = is_snowing
@@ -466,12 +471,26 @@ func trigger_random_weather_event(duration: float = 0.0) -> void:
_apply_weather_event_state(true, false, false, true)
if duration > 0.0:
random_event_remaining = duration
_emit_weather_event_label()
random_weather_restore_tween = create_tween()
random_weather_restore_tween.tween_interval(duration)
random_weather_restore_tween.tween_callback(func():
random_event_remaining = 0.0
random_event_label_seconds = -1
_apply_weather_event_state(previous_rain, previous_snow, previous_wind, previous_storm)
)
func _update_random_event_label(delta: float) -> void:
if random_event_remaining <= 0.0:
return
random_event_remaining = maxf(random_event_remaining - delta, 0.0)
var display_seconds: int = ceili(random_event_remaining)
if display_seconds != random_event_label_seconds:
random_event_label_seconds = display_seconds
_emit_weather_event_label()
func _apply_weather_event_state(rain_enabled: bool, snow_enabled: bool, wind_enabled: bool, storm_enabled: bool = false) -> void:
if is_storm and not storm_enabled:
toggle_storm(false)
@@ -785,6 +804,8 @@ func _emit_weather_event_label() -> void:
active_events.append("Wind")
if not active_events.is_empty():
weather_label = "Weather: %s" % " + ".join(active_events)
if random_event_remaining > 0.0:
weather_label += " (%s'')" % ceili(random_event_remaining)
UIEvents.weather_event_changed.emit(weather_label)
#disable snow and set default values and shader

View File

@@ -184,3 +184,7 @@ extends Resource
@export var water_color_afternoon: Color = Color(0.889, 0.733, 0.205, 1.0) #Tint for afternoon (sunset)
@export var water_color_night: Color = Color(0.728, 0.54, 0.986, 1.0); #Tint for night
@export var water_darkening_rain: float = 0.7 #Percentage of darkening when is rainy
#Random events
@export_group("Random Events")
@export var random_event_duration: float = 30.0 #Duration time for random event

View File

@@ -12,7 +12,7 @@
[ext_resource type="PackedScene" uid="uid://cjv1e8pc6gde1" path="res://tgcc/chunk/countryside/scene/chunk_country_corner_01.tscn" id="8_nurqm"]
[ext_resource type="PackedScene" uid="uid://cu2chsjh8wuvp" path="res://tgcc/chunk/countryside/scene/chunk_country_straight_02.tscn" id="9_51cxd"]
[ext_resource type="PackedScene" uid="uid://dqoai3665vb0a" path="res://tgcc/chunk/countryside/scene/chunk_country_corner_02.tscn" id="9_q6kbb"]
[ext_resource type="PackedScene" uid="uid://c73yk6858dmwn" path="res://tgcc/chunk/countryside/scene/chunk_country_cross_4_01.tscn" id="10_ufarv"]
[ext_resource type="PackedScene" uid="uid://cjv1e8pc6gde1" path="res://tgcc/chunk/countryside/scene/chunk_country_corner_01.tscn" id="10_ufarv"]
[ext_resource type="PackedScene" uid="uid://cv5xmnow451kl" path="res://core/camera.tscn" id="11_o1bk6"]
[ext_resource type="Script" uid="uid://dboerd4a6dwj7" path="res://core/biome_generator/rails.gd" id="12_4is5r"]
[ext_resource type="PackedScene" uid="uid://qmt8bkiksgj3" path="res://tgcc/chunk/countryside/scene/chunk_country_cross_3_02.tscn" id="12_81wux"]
@@ -28,8 +28,10 @@
[ext_resource type="AudioStream" uid="uid://creenugno7hm" path="res://core/daynight/sounds/thunder_4.mp3" id="18_lfsx4"]
[ext_resource type="PackedScene" uid="uid://pxmcy0lhne5d" path="res://tgcc/chunk/countryside/scene/chunk_country_straight_03.tscn" id="19_ne4de"]
[ext_resource type="AudioStream" uid="uid://bm6dq4jwsbxf6" path="res://core/daynight/sounds/thunder_5.mp3" id="19_niwdr"]
[ext_resource type="PackedScene" uid="uid://bs3dkwcc8w2uk" path="res://tgcc/chunk/river/scene/chunk_r_l_1.tscn" id="20_q6kbb"]
[ext_resource type="AudioStream" uid="uid://byuxpukhy72n8" path="res://core/daynight/sounds/rain_1.mp3" id="20_quqod"]
[ext_resource type="PackedScene" uid="uid://1c1ion0qnho4" path="res://tgcc/map/map_1/map_1.tscn" id="20_xkcqp"]
[ext_resource type="PackedScene" uid="uid://btipd6wev016d" path="res://tgcc/chunk/river/scene/chunk_r_r_1.tscn" id="21_81wux"]
[ext_resource type="AudioStream" uid="uid://h5yhjn1x3f4j" path="res://core/daynight/sounds/rain_2.mp3" id="21_appab"]
[ext_resource type="AudioStream" uid="uid://elrjw0smm0cj" path="res://core/daynight/sounds/rain_3.mp3" id="22_yime3"]
[ext_resource type="Script" uid="uid://cx2tlvxhvatj5" path="res://docs/museums/daynight/control.gd" id="23_ou3jn"]
@@ -112,7 +114,7 @@ compositor_effects = Array[CompositorEffect]([SubResource("CompositorEffect_q52t
[sub_resource type="Resource" id="Resource_3qrd0"]
script = ExtResource("6_s3jnv")
name = "countryside"
available_chunks = Array[PackedScene]([ExtResource("7_xgfli"), ExtResource("8_nurqm"), ExtResource("9_q6kbb"), ExtResource("7_4elh6"), ExtResource("8_hvd8d"), ExtResource("12_81wux"), ExtResource("13_1ugwu"), ExtResource("10_ufarv"), ExtResource("15_ky1rt"), ExtResource("16_5g563"), ExtResource("17_tbmwr"), ExtResource("9_51cxd"), ExtResource("19_ne4de")])
available_chunks = Array[PackedScene]([ExtResource("7_xgfli"), ExtResource("8_nurqm"), ExtResource("9_q6kbb"), ExtResource("7_4elh6"), ExtResource("8_hvd8d"), ExtResource("12_81wux"), ExtResource("13_1ugwu"), ExtResource("10_ufarv"), ExtResource("15_ky1rt"), ExtResource("16_5g563"), ExtResource("17_tbmwr"), ExtResource("9_51cxd"), ExtResource("19_ne4de"), ExtResource("20_q6kbb"), ExtResource("21_81wux")])
metadata/_custom_type_script = "uid://wv6kcqkibium"
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_pypsn"]
@@ -386,7 +388,7 @@ theme_override_colors/font_pressed_color = Color(1, 1, 1, 1)
theme_override_colors/font_hover_color = Color(1, 1, 1, 1)
theme_override_colors/font_hover_pressed_color = Color(1, 1, 1, 1)
theme_override_colors/font_outline_color = Color(1, 1, 1, 1)
text = "Random Weather (10\")"
text = "Random Weather"
[node name="WeatherEventLabel" type="Label" parent="Control" unique_id=641424797]
layout_mode = 0

View File

@@ -7,6 +7,8 @@ extends Control
@onready var wind_slider: HSlider = $WindSlider
@onready var day_time_option: OptionButton = $DayTimeOptions
var default_random_event_duration: float = 10.0
func _ready() -> void:
UIEvents.day_time_changed.connect(_on_day_time_changed)
UIEvents.day_time_option_changed.connect(_on_day_time_option_changed)
@@ -29,7 +31,10 @@ func _on_wind_slider_value_changed(value: float) -> void:
UIEvents.wind_change.emit(value)
func _on_random_weather_pressed() -> void:
UIEvents.trigger_random_weather.emit(10.0)
var duration: float = default_random_event_duration
if day_night != null and day_night.environment_config != null:
duration = day_night.environment_config.random_event_duration
UIEvents.trigger_random_weather.emit(duration)
func _on_fireflies_toggled(toggled_on: bool) -> void:
UIEvents.toggle_fireflies.emit(toggled_on)

View File

@@ -114,7 +114,7 @@ surface_material_override/1 = ExtResource("6_b82gs")
surface_material_override/0 = ExtResource("6_b82gs")
surface_material_override/1 = ExtResource("5_wbwk3")
[node name="MSH_Staccioanta_1_017" parent="." index="10" unique_id=1757093874]
[node name="MSH_Staccioanta_1_017" parent="." index="10" unique_id=845283196]
surface_material_override/0 = ExtResource("7_be1u8")
[node name="PaliLuci_001" parent="." index="11" unique_id=239883314]

View File

@@ -171,7 +171,7 @@ surface_material_override/0 = ExtResource("2_t65ww")
[node name="Bags" parent="." index="1" unique_id=885374680]
surface_material_override/0 = SubResource("ShaderMaterial_q2s76")
[node name="Cart" parent="." index="2" unique_id=1431553734]
[node name="Cart" parent="." index="2" unique_id=884973125]
surface_material_override/0 = ExtResource("11_iulsg")
surface_material_override/1 = SubResource("ShaderMaterial_mqw0y")
surface_material_override/2 = SubResource("ShaderMaterial_dxwao")
@@ -212,7 +212,7 @@ surface_material_override/1 = ExtResource("7_q2s76")
[node name="Water_006" parent="." index="12" unique_id=2064105008]
surface_material_override/0 = ExtResource("10_r4bww")
[node name="WoodPile" parent="." index="13" unique_id=1512653267]
[node name="WoodPile" parent="." index="13" unique_id=1088104699]
surface_material_override/0 = ExtResource("11_iulsg")
surface_material_override/1 = ExtResource("12_ytk0o")
surface_material_override/2 = SubResource("ShaderMaterial_ytk0o")

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -0,0 +1,44 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://d0rca3oo1k30n"
path="res://.godot/imported/Chunk_R_L_1.fbx-f315be000da513deddf8c1537ffe1a0f.scn"
[deps]
source_file="res://tgcc/chunk/river/mesh/Chunk_R_L_1.fbx"
dest_files=["res://.godot/imported/Chunk_R_L_1.fbx-f315be000da513deddf8c1537ffe1a0f.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/root_script=null
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=true
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
fbx/importer=0
fbx/allow_geometry_helper_nodes=false
fbx/embedded_image_handling=1
fbx/naming_version=2

Binary file not shown.

View File

@@ -0,0 +1,44 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://bryeoru3tfbcq"
path="res://.godot/imported/Chunk_R_R_1.fbx-3c3c617da890fc412ffcc0f1d56c3abe.scn"
[deps]
source_file="res://tgcc/chunk/river/mesh/Chunk_R_R_1.fbx"
dest_files=["res://.godot/imported/Chunk_R_R_1.fbx-3c3c617da890fc412ffcc0f1d56c3abe.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/root_script=null
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=true
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
fbx/importer=0
fbx/allow_geometry_helper_nodes=false
fbx/embedded_image_handling=1
fbx/naming_version=2

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long