From d73b59a24d653ce7527ceb00068d446d42c7b893 Mon Sep 17 00:00:00 2001 From: Overside srl Date: Mon, 25 May 2026 08:53:41 +0200 Subject: [PATCH] change props logic --- core/biome_generator/biome_generator.gd | 57 ++++++++++++++----- core/biome_generator/prop_info.gd | 3 +- .../scene/chunk_country_corner_02.tscn | 5 +- .../scene/chunk_country_cross_3_01.tscn | 13 ++--- .../scene/chunk_country_cross_3_02.tscn | 9 +-- .../scene/chunk_country_cross_3_03.tscn | 6 +- .../scene/chunk_country_cross_4_01.tscn | 5 +- .../scene/chunk_country_straight_02.tscn | 8 +-- .../scene/chunk_country_straight_03.tscn | 9 ++- 9 files changed, 73 insertions(+), 42 deletions(-) diff --git a/core/biome_generator/biome_generator.gd b/core/biome_generator/biome_generator.gd index c37bbdf..8a1eb40 100644 --- a/core/biome_generator/biome_generator.gd +++ b/core/biome_generator/biome_generator.gd @@ -193,6 +193,15 @@ func collect_all_propinfo(root: Node, list: Array[Node]) -> void: for child in root.get_children(): collect_all_propinfo(child, list) +func collect_all_prop_markers(root: Node, list: Array[Node]) -> void: + if root == null: return + + if root is Marker3D and _is_prop_marker(root): + list.append(root) + + for child in root.get_children(): + collect_all_prop_markers(child, list) + func collect_all_entityinfo(root: Node, list: Array[Node]) -> void: if root == null: return @@ -700,17 +709,29 @@ func _get_prop_scene_uniqueness(scene: PackedScene) -> int: prop_candidate_cache[key] = uniqueness return uniqueness -func _get_marker_prop_uniqueness(marker: Node) -> int: - var uniqueness = _get_prop_uniqueness_from_info(marker) +func _is_prop_marker(node: Node) -> bool: + return node.is_in_group("prop_marker") or node.name.begins_with("Prop") + +func _get_scene_prop_info(root: Node) -> Node: + var prop_info_list: Array[Node] = [] + collect_all_propinfo(root, prop_info_list) + + for info_node in prop_info_list: + if not (info_node is Marker3D): + return info_node + return null + +func _get_prop_config_uniqueness(prop_info: Node) -> int: + var uniqueness = _get_prop_uniqueness_from_info(prop_info) if uniqueness == -1: return 0 return uniqueness -func _pick_weighted_prop_scene(marker: Node) -> PackedScene: +func _pick_weighted_prop_scene(prop_info: Node) -> PackedScene: var candidates = [] - var fallback_uniqueness = _get_marker_prop_uniqueness(marker) + var fallback_uniqueness = _get_prop_config_uniqueness(prop_info) - for prop_scene in marker.available_props: + for prop_scene in prop_info.available_props: if prop_scene == null: continue @@ -729,17 +750,27 @@ func _pick_weighted_prop_scene(marker: Node) -> PackedScene: return _pick_weighted_candidate(candidates).scene func _spawn_props_for_chunk(root: Node) -> void: - var prop_markers: Array[Node] = [] - collect_all_propinfo(root, prop_markers) + var scene_prop_info = _get_scene_prop_info(root) + if scene_prop_info != null: + var scene_prop_markers: Array[Node] = [] + collect_all_prop_markers(root, scene_prop_markers) - for marker in prop_markers: - _spawn_prop_for_marker(marker) - -func _spawn_prop_for_marker(marker: Node) -> void: - if marker.available_props.is_empty(): + for marker in scene_prop_markers: + _spawn_prop_for_marker(marker, scene_prop_info) return - var prop_scene = _pick_weighted_prop_scene(marker) + var legacy_prop_markers: Array[Node] = [] + collect_all_propinfo(root, legacy_prop_markers) + + for marker in legacy_prop_markers: + if marker is Marker3D: + _spawn_prop_for_marker(marker, marker) + +func _spawn_prop_for_marker(marker: Node, prop_info: Node) -> void: + if prop_info.available_props.is_empty(): + return + + var prop_scene = _pick_weighted_prop_scene(prop_info) if prop_scene == null: return diff --git a/core/biome_generator/prop_info.gd b/core/biome_generator/prop_info.gd index 72e2962..444cd49 100644 --- a/core/biome_generator/prop_info.gd +++ b/core/biome_generator/prop_info.gd @@ -1,5 +1,6 @@ -extends Marker3D +## Scene-level configuration for props spawned on Prop* markers. class_name PropInfo +extends Node3D @export var available_props: Array[PackedScene] @export_range(0, 5, 1) var uniqueness: int = 0 #0=common; 5=unique diff --git a/tgcc/chunk/countryside/scene/chunk_country_corner_02.tscn b/tgcc/chunk/countryside/scene/chunk_country_corner_02.tscn index 755ab3c..12c67e7 100644 --- a/tgcc/chunk/countryside/scene/chunk_country_corner_02.tscn +++ b/tgcc/chunk/countryside/scene/chunk_country_corner_02.tscn @@ -963,10 +963,11 @@ transform = Transform3D(-0.99390334, -0.110254735, -8.742278e-08, -0.110254735, [node name="Prop1" type="Marker3D" parent="." index="7" unique_id=308396303] transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -5.899247, 0.35683155, 5.9334393) -script = ExtResource("11_wt3n1") -available_props = Array[PackedScene]([ExtResource("12_wjqm7"), ExtResource("13_newgk"), ExtResource("14_lgi3t"), ExtResource("15_8pj4d")]) [node name="Prop2" type="Marker3D" parent="." index="8" unique_id=1683081972] transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -0.00079250336, 0.35683155, -5.8335304) + +[node name="PropInfo" type="Node3D" parent="."] script = ExtResource("11_wt3n1") available_props = Array[PackedScene]([ExtResource("12_wjqm7"), ExtResource("13_newgk"), ExtResource("14_lgi3t"), ExtResource("15_8pj4d")]) + diff --git a/tgcc/chunk/countryside/scene/chunk_country_cross_3_01.tscn b/tgcc/chunk/countryside/scene/chunk_country_cross_3_01.tscn index a638dfa..9381b64 100644 --- a/tgcc/chunk/countryside/scene/chunk_country_cross_3_01.tscn +++ b/tgcc/chunk/countryside/scene/chunk_country_cross_3_01.tscn @@ -912,25 +912,20 @@ transform = Transform3D(-2.6226832e-08, 0, -0.59999996, 0, 0.59999996, 0, 0.5999 [node name="Prop2" type="Marker3D" parent="." index="9" unique_id=778261734] transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -6.009877, 0.35683155, 0.043001175) -script = ExtResource("13_3qh3w") -available_props = Array[PackedScene]([ExtResource("13_fspb5"), ExtResource("15_yg7g5"), ExtResource("16_x3b0m"), ExtResource("17_fo87f")]) [node name="Prop3" type="Marker3D" parent="." index="10" unique_id=820130140] transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, 5.9794493, 0.7136631, -5.921642) -script = ExtResource("13_3qh3w") -available_props = Array[PackedScene]([ExtResource("13_fspb5"), ExtResource("15_yg7g5"), ExtResource("16_x3b0m"), ExtResource("17_fo87f")]) [node name="Prop4" type="Marker3D" parent="." index="11" unique_id=632231780] transform = Transform3D(1.3113416e-07, 0, 1, 0, 1, 0, -1, 0, 1.3113416e-07, 5.927927, 1.0704947, 6.158152) -script = ExtResource("13_3qh3w") -available_props = Array[PackedScene]([ExtResource("13_fspb5"), ExtResource("15_yg7g5"), ExtResource("16_x3b0m"), ExtResource("17_fo87f")]) [node name="Prop6" type="Marker3D" parent="." index="12" unique_id=871422935] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.1217992, 0.042618692, 9.309157) -script = ExtResource("13_3qh3w") -available_props = Array[PackedScene]([ExtResource("17_fo87f"), ExtResource("19_13g36"), ExtResource("18_aebao"), ExtResource("21_f427r"), ExtResource("20_le1e5")]) [node name="Prop7" type="Marker3D" parent="." index="13" unique_id=1199373586] transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 1.663, 0, -1.181) + +[node name="PropInfo" type="Node3D" parent="."] script = ExtResource("13_3qh3w") -available_props = Array[PackedScene]([ExtResource("17_fo87f"), ExtResource("19_13g36"), ExtResource("18_aebao"), ExtResource("21_f427r"), ExtResource("20_le1e5")]) +available_props = Array[PackedScene]([ExtResource("13_fspb5"), ExtResource("15_yg7g5"), ExtResource("16_x3b0m"), ExtResource("17_fo87f"), ExtResource("19_13g36"), ExtResource("18_aebao"), ExtResource("21_f427r"), ExtResource("20_le1e5")]) + diff --git a/tgcc/chunk/countryside/scene/chunk_country_cross_3_02.tscn b/tgcc/chunk/countryside/scene/chunk_country_cross_3_02.tscn index bb6226b..f049a13 100644 --- a/tgcc/chunk/countryside/scene/chunk_country_cross_3_02.tscn +++ b/tgcc/chunk/countryside/scene/chunk_country_cross_3_02.tscn @@ -791,16 +791,17 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.6109447, 0, 1.013597) [node name="Prop7" type="Marker3D" parent="." index="19" unique_id=228771879] transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 1.7960589, 0.042618692, -0.8912107) -script = ExtResource("19_mw0dk") -available_props = Array[PackedScene]([ExtResource("20_qayvj"), ExtResource("21_6iw0h"), ExtResource("22_e3wev"), ExtResource("23_xydfo"), ExtResource("24_1bb53")]) [node name="Prop2" type="Marker3D" parent="." index="20" unique_id=1453317700] transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -6.009877, 0.35683155, 0.043001175) -script = ExtResource("19_mw0dk") -available_props = Array[PackedScene]([ExtResource("25_e3wev"), ExtResource("26_xydfo"), ExtResource("27_1bb53"), ExtResource("20_qayvj")]) [node name="WindDecoration" parent="." index="21" unique_id=2146740679 instance=ExtResource("28_xydfo")] transform = Transform3D(1.9905398, 0.19395185, 0.011580614, -0.19368553, 1.9901968, -0.04003887, -0.015406657, 0.03872799, 1.9995658, 4.4318647, 2.1423423, -3.9336014) [node name="WindDecoration2" parent="." index="22" unique_id=1273410990 instance=ExtResource("28_xydfo")] transform = Transform3D(1.999275, -0.053754073, 0.003284915, 0.05310862, 1.9881506, 0.21080151, -0.008931173, -0.21063784, 1.9888572, 4.7311583, 2.1197329, -3.9115348) + +[node name="PropInfo" type="Node3D" parent="."] +script = ExtResource("19_mw0dk") +available_props = Array[PackedScene]([ExtResource("20_qayvj"), ExtResource("21_6iw0h"), ExtResource("22_e3wev"), ExtResource("23_xydfo"), ExtResource("24_1bb53"), ExtResource("25_e3wev"), ExtResource("26_xydfo"), ExtResource("27_1bb53")]) + diff --git a/tgcc/chunk/countryside/scene/chunk_country_cross_3_03.tscn b/tgcc/chunk/countryside/scene/chunk_country_cross_3_03.tscn index 76cbed6..defccc2 100644 --- a/tgcc/chunk/countryside/scene/chunk_country_cross_3_03.tscn +++ b/tgcc/chunk/countryside/scene/chunk_country_cross_3_03.tscn @@ -568,8 +568,6 @@ transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -7.9 [node name="Prop7" type="Marker3D" parent="." index="26" unique_id=1712576644] transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 1.7960589, 0.042618692, -0.8912107) -script = ExtResource("25_8sefc") -available_props = Array[PackedScene]([ExtResource("26_dvfkd"), ExtResource("27_ap8sf"), ExtResource("28_mtqws"), ExtResource("29_kujqa"), ExtResource("30_jwe44")]) [node name="Tenda" parent="." index="27" unique_id=1345812366 instance=ExtResource("31_dvfkd")] transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -3.3930097, 0.71891594, -1.0331697) @@ -577,6 +575,10 @@ transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -3.3 [node name="Tenda2" parent="." index="28" unique_id=1021665362 instance=ExtResource("31_dvfkd")] transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -3.3930097, 0.71891594, -3.0399761) +[node name="PropInfo" type="Node3D" parent="."] +script = ExtResource("25_8sefc") +available_props = Array[PackedScene]([ExtResource("26_dvfkd"), ExtResource("27_ap8sf"), ExtResource("28_mtqws"), ExtResource("29_kujqa"), ExtResource("30_jwe44")]) + [editable path="TreeTest5"] [editable path="TreeTest6"] [editable path="VendingMachine_1"] diff --git a/tgcc/chunk/countryside/scene/chunk_country_cross_4_01.tscn b/tgcc/chunk/countryside/scene/chunk_country_cross_4_01.tscn index 3bd0a84..c750884 100644 --- a/tgcc/chunk/countryside/scene/chunk_country_cross_4_01.tscn +++ b/tgcc/chunk/countryside/scene/chunk_country_cross_4_01.tscn @@ -491,10 +491,11 @@ transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, 1.38 [node name="Prop7" type="Marker3D" parent="." index="18" unique_id=704248250] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.0779345, 0.042618692, 1.6671067) -script = ExtResource("16_8x1q3") -available_props = Array[PackedScene]([ExtResource("17_jc462"), ExtResource("18_e8hed"), ExtResource("19_3vlla"), ExtResource("20_qj7ai"), ExtResource("21_jjc32")]) [node name="Prop8" type="Marker3D" parent="." index="19" unique_id=572971113] transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, -1.4561574, 0.042618692, -1.8439876) + +[node name="PropInfo" type="Node3D" parent="."] script = ExtResource("16_8x1q3") available_props = Array[PackedScene]([ExtResource("17_jc462"), ExtResource("18_e8hed"), ExtResource("19_3vlla"), ExtResource("20_qj7ai"), ExtResource("21_jjc32")]) + diff --git a/tgcc/chunk/countryside/scene/chunk_country_straight_02.tscn b/tgcc/chunk/countryside/scene/chunk_country_straight_02.tscn index b99e675..2b9b621 100644 --- a/tgcc/chunk/countryside/scene/chunk_country_straight_02.tscn +++ b/tgcc/chunk/countryside/scene/chunk_country_straight_02.tscn @@ -784,15 +784,15 @@ transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, 5.77 [node name="Prop2" type="Marker3D" parent="." index="23" unique_id=1220014029] transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 5.8930645, 0.35683155, -5.7293277) -script = ExtResource("24_vmqe2") -available_props = Array[PackedScene]([ExtResource("25_g8i5r"), ExtResource("26_tmdaq"), ExtResource("27_w64vi"), ExtResource("28_1wvnd")]) [node name="Prop2" type="Marker3D" parent="Prop2" index="0" unique_id=1596157579] transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 11.625584, 0.35683155, 0.003191471) -script = ExtResource("24_vmqe2") -available_props = Array[PackedScene]([ExtResource("25_g8i5r"), ExtResource("26_tmdaq"), ExtResource("27_w64vi"), ExtResource("28_1wvnd")]) [node name="Tenda" parent="." index="24" unique_id=1345812366 instance=ExtResource("29_g8i5r")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.8348045, 1.0869424, -1.5693097) +[node name="PropInfo" type="Node3D" parent="."] +script = ExtResource("24_vmqe2") +available_props = Array[PackedScene]([ExtResource("25_g8i5r"), ExtResource("26_tmdaq"), ExtResource("27_w64vi"), ExtResource("28_1wvnd")]) + [editable path="PaloLuce"] diff --git a/tgcc/chunk/countryside/scene/chunk_country_straight_03.tscn b/tgcc/chunk/countryside/scene/chunk_country_straight_03.tscn index a588b86..199c6c2 100644 --- a/tgcc/chunk/countryside/scene/chunk_country_straight_03.tscn +++ b/tgcc/chunk/countryside/scene/chunk_country_straight_03.tscn @@ -872,15 +872,14 @@ transform = Transform3D(-0.92917824, 0.06943477, 0.363052, 0.08790589, 0.9955283 [node name="Prop1" type="Marker3D" parent="." index="7" unique_id=362853951] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.8943415, 0.35683155, 0.043001175) -script = ExtResource("12_keqgb") -available_props = Array[PackedScene]([ExtResource("13_45od3"), ExtResource("12_kkc6w"), ExtResource("15_2hsar")]) [node name="Prop2" type="Marker3D" parent="." index="8" unique_id=1556303512] transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -6.009877, 0.35683155, 0.043001175) -script = ExtResource("12_keqgb") -available_props = Array[PackedScene]([ExtResource("16_gable"), ExtResource("17_a0gn5"), ExtResource("18_e3c12"), ExtResource("13_45od3")]) [node name="Prop3" type="Marker3D" parent="." index="9" unique_id=1117362414] transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 6.1461954, 0.35683155, 0.043001175) + +[node name="PropInfo" type="Node3D" parent="."] script = ExtResource("12_keqgb") -available_props = Array[PackedScene]([ExtResource("16_gable"), ExtResource("17_a0gn5"), ExtResource("18_e3c12"), ExtResource("13_45od3")]) +available_props = Array[PackedScene]([ExtResource("13_45od3"), ExtResource("12_kkc6w"), ExtResource("15_2hsar"), ExtResource("16_gable"), ExtResource("17_a0gn5"), ExtResource("18_e3c12")]) +