Merge branch 'main' into refactoring-UI
This commit is contained in:
@@ -520,17 +520,15 @@ func _update_wagon_progress_offsets() -> void:
|
||||
|
||||
for wagon in wagon_instances:
|
||||
var wagon_length: float = _get_vehicle_length(wagon)
|
||||
accumulated_distance += _get_wagon_spacing(previous_length, wagon_length)
|
||||
if wagon_spacing_override > 0.0:
|
||||
accumulated_distance += wagon_spacing_override + wagon_gap
|
||||
else:
|
||||
var detected_spacing: float = previous_length * 0.5 + wagon_length * 0.5
|
||||
accumulated_distance += detected_spacing * wagon_spacing_scale + wagon_gap
|
||||
|
||||
wagon_progress_offsets.append(accumulated_distance)
|
||||
previous_length = wagon_length
|
||||
|
||||
func _get_wagon_spacing(previous_length: float, wagon_length: float) -> float:
|
||||
if wagon_spacing_override > 0.0:
|
||||
return wagon_spacing_override + wagon_gap
|
||||
|
||||
var detected_spacing: float = previous_length * 0.5 + wagon_length * 0.5
|
||||
return detected_spacing * wagon_spacing_scale + wagon_gap
|
||||
|
||||
func _snap_wagons_to_progress(total_length: float = 0.0) -> void:
|
||||
if curve == null or wagon_instances.is_empty():
|
||||
return
|
||||
@@ -554,18 +552,16 @@ func _snap_wagons_to_progress(total_length: float = 0.0) -> void:
|
||||
wagon_offset = wagon_progress_offsets[i]
|
||||
|
||||
var wagon_progress: float = train_progress - direction * wagon_offset
|
||||
_snap_vehicle_to_progress(wagon, wagon_progress, total_length)
|
||||
|
||||
func _snap_vehicle_to_progress(vehicle: Node3D, progress: float, total_length: float) -> void:
|
||||
var vehicle_progress: float = wrapf(progress, 0.0, total_length)
|
||||
var center_position: Vector3 = to_global(curve.sample_baked(vehicle_progress, true))
|
||||
var prog_forward: float = wrapf(vehicle_progress + 2.0, 0.0, total_length)
|
||||
var forward_position: Vector3 = to_global(curve.sample_baked(prog_forward, true))
|
||||
var vehicle_progress: float = wrapf(wagon_progress, 0.0, total_length)
|
||||
var center_position: Vector3 = to_global(curve.sample_baked(vehicle_progress, true))
|
||||
var prog_forward: float = wrapf(vehicle_progress + 2.0, 0.0, total_length)
|
||||
var forward_position: Vector3 = to_global(curve.sample_baked(prog_forward, true))
|
||||
|
||||
vehicle.global_position = center_position
|
||||
if center_position.distance_to(forward_position) > 0.01:
|
||||
vehicle.look_at(forward_position, Vector3.UP)
|
||||
vehicle.rotate_y(PI)
|
||||
wagon.global_position = center_position
|
||||
if center_position.distance_to(forward_position) > 0.01:
|
||||
wagon.look_at(forward_position, Vector3.UP)
|
||||
wagon.rotate_y(PI)
|
||||
|
||||
func _get_vehicle_length(vehicle: Node3D) -> float:
|
||||
var bounds: AABB = _get_node_local_bounds(vehicle, vehicle)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[gd_resource type="Resource" script_class="WagonPool" format=3 uid="uid://bjnytgwt8tmf4"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dvk3bytqn3m5s" path="res://tgcc/train/main_train.tscn" id="1_t6q5r"]
|
||||
[ext_resource type="Script" uid="uid://b6xk0gtn2pwa" path="res://core/biome_generator/wagon_pool.gd" id="2_x6bmc"]
|
||||
[ext_resource type="PackedScene" uid="uid://bny4kv08j8j40" path="res://tgcc/train/wagon.tscn" id="1_t6q5r"]
|
||||
[ext_resource type="Script" uid="uid://c3bgupfogjvv2" path="res://core/biome_generator/wagon_pool.gd" id="2_x6bmc"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_x6bmc")
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
[ext_resource type="AudioStream" uid="uid://elrjw0smm0cj" path="res://core/daynight/sounds/rain_3.mp3" id="42_mh642"]
|
||||
[ext_resource type="PackedScene" uid="uid://1c1ion0qnho4" path="res://tgcc/map/map_1/map_1.tscn" id="43_ysd85"]
|
||||
[ext_resource type="Script" uid="uid://dboerd4a6dwj7" path="res://core/biome_generator/rails.gd" id="44_rcqo0"]
|
||||
[ext_resource type="PackedScene" uid="uid://dvk3bytqn3m5s" path="res://tgcc/train/test/Train_test.tscn" id="45_c0jxs"]
|
||||
[ext_resource type="PackedScene" uid="uid://otptvwer4par" path="res://tgcc/train/train.tscn" id="46_8w5ju"]
|
||||
[ext_resource type="Resource" uid="uid://bjnytgwt8tmf4" path="res://core/biome_generator/wagon_pool.tres" id="46_exdk1"]
|
||||
[ext_resource type="PackedScene" uid="uid://0kgjaqijaqku" path="res://docs/museums/biome_generator/rails.tscn" id="46_lbmv2"]
|
||||
[ext_resource type="PackedScene" uid="uid://dn1btv0e0ses7" path="res://core/fireworks.tscn" id="47_q7p65"]
|
||||
@@ -202,11 +202,11 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 280, 0, 0)
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 270, 2, -0.101)
|
||||
curve = SubResource("Curve3D_ndco5")
|
||||
script = ExtResource("44_rcqo0")
|
||||
train_model = ExtResource("45_c0jxs")
|
||||
train_model = ExtResource("46_8w5ju")
|
||||
wagon_pool = ExtResource("46_exdk1")
|
||||
wagon_count = 4
|
||||
wagon_gap = 0.5
|
||||
wagon_spacing_scale = 0.7999999999999999
|
||||
wagon_count = 5
|
||||
wagon_gap = 0.8
|
||||
wagon_spacing_scale = 0.9
|
||||
cameras = NodePath("../cameras")
|
||||
sleepers_model = ExtResource("46_lbmv2")
|
||||
fireworks_scene = ExtResource("47_q7p65")
|
||||
|
||||
Reference in New Issue
Block a user