diff --git a/src/base-environments/transition/code/dolly.gd b/src/base-environments/transition/code/dolly.gd index 07c7c69..ae2dbb7 100644 --- a/src/base-environments/transition/code/dolly.gd +++ b/src/base-environments/transition/code/dolly.gd @@ -1,4 +1,4 @@ -## A dolly tweens all contents to and from two destination points, and to its origin. +## A dolly tweens all contents to and from two destination points, and to its origin. class_name Dolly extends Node3D @@ -11,9 +11,9 @@ extends Node3D @export var post_leave_time : float = 5.0 @onready var origination : Node3D = $Origination -@onready var destination : Node3D = $Destination +@onready var destination : Node3D = $Destination -@onready var subway : SubwayTrain = %Subway +@onready var subway : SubwayTrain = $Train var tween : Tween = null @@ -22,13 +22,23 @@ func _ready() -> void: for child in get_children(true): if not child.visible: continue child.global_position = origination.global_position - - -## One arrival and departure + + +## One arrival and departure func cycle() -> void: await arrive() await leave() +func _seat_player_if_inside() -> void: + if %EntryDetect.overlaps_body(State.player): + prints("Player is inside Train on", self.name) + State.player.sleeping = true + var s1 := %Seat1 + var s2 := %Seat2 + + var seat : Node3D = s1 if (s1.global_position-State.player.global_position).length() < (s2.global_position-State.player.global_position).length() else s2 + State.player.reparent(seat) + func arrive() -> void: %SubwayTrainAudio.play(0) @@ -40,13 +50,14 @@ func arrive() -> void: if not child.visible: continue tween.parallel().tween_property(child, "global_position", self.global_position, arrival_time) await tween.finished - subway.door_open = true + subway.door_open = true func leave() -> void: await get_tree().create_timer(pre_leave_time).timeout subway.door_open = false await get_tree().create_timer(door_close_time).timeout + _seat_player_if_inside() if tween: tween.kill() tween = create_tween().set_trans(Tween.TRANS_QUART).set_ease(Tween.EASE_IN) for child in get_children(true): diff --git a/src/base-environments/transition/code/subway_train.gd b/src/base-environments/transition/code/subway_train.gd index cb04ad9..f8b3398 100644 --- a/src/base-environments/transition/code/subway_train.gd +++ b/src/base-environments/transition/code/subway_train.gd @@ -6,6 +6,12 @@ class_name SubwayTrain if door_open == open: return door_open=open if open: - $AnimationPlayer.play("door_open") + $Subway/AnimationPlayer.play("door_open") else: - $AnimationPlayer.play("door_close") \ No newline at end of file + $Subway/AnimationPlayer.play("door_close") + +func _ready() -> void: + $Subway/AnimationPlayer.animation_finished.connect(_on_animation_finished) + +func _on_animation_finished(_discard) -> void: + %FrontWallClosed.disabled = door_open diff --git a/src/base-environments/transition/subway_track.tscn b/src/base-environments/transition/subway_track.tscn index ee8f07a..24f47e3 100644 --- a/src/base-environments/transition/subway_track.tscn +++ b/src/base-environments/transition/subway_track.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=22 format=3 uid="uid://df3ur5wll8vx7"] +[gd_scene load_steps=23 format=3 uid="uid://df3ur5wll8vx7"] [ext_resource type="PackedScene" uid="uid://4j1tlhfm3p40" path="res://base-environments/transition/subway_train.tscn" id="1_2h2xx"] [ext_resource type="Script" uid="uid://dgfje4druu3sw" path="res://base-environments/transition/code/dolly.gd" id="1_5jpg8"] +[ext_resource type="Script" uid="uid://cyohujvfoiof7" path="res://base-environments/transition/code/subway_train.gd" id="2_aacjs"] [ext_resource type="AudioStream" uid="uid://cwfr6sgcwg7sl" path="res://base-environments/transition/audio/450918__kyles__metro-subway-montreal-verdun-station-arrive-and-leave-semidistant-from-bridge-over-tracks-overpass.ogg" id="3_4h0n7"] [sub_resource type="Shader" id="Shader_tpaj8"] @@ -79,24 +80,24 @@ shader_parameter/vertical_emission = SubResource("GradientTexture1D_v43sq") [sub_resource type="BoxShape3D" id="BoxShape3D_5jpg8"] size = Vector3(1.565918, 2.3292236, 3.8251343) +[sub_resource type="BoxShape3D" id="BoxShape3D_e1qmr"] +size = Vector3(30.492157, 4.4813232, 3.4832764) + [sub_resource type="BoxShape3D" id="BoxShape3D_aacjs"] size = Vector3(31.245972, 4.7752075, 1) [sub_resource type="BoxShape3D" id="BoxShape3D_4h0n7"] -size = Vector3(16.2845, 4.7752075, 1) +size = Vector3(16.285, 4.775, 3) [sub_resource type="BoxShape3D" id="BoxShape3D_xhnml"] -size = Vector3(6.0409546, 4.7752075, 1) +size = Vector3(6.041, 4.775, 3) [sub_resource type="BoxShape3D" id="BoxShape3D_5b47p"] -size = Vector3(5.908142, 4.7752075, 1) +size = Vector3(5.908, 4.775, 3) [sub_resource type="SphereShape3D" id="SphereShape3D_5jpg8"] radius = 2.0 -[sub_resource type="BoxShape3D" id="BoxShape3D_e1qmr"] -size = Vector3(30.492157, 4.4813232, 3.4832764) - [node name="TrainDolly" type="Node3D"] script = ExtResource("1_5jpg8") metadata/_custom_type_script = "uid://dgfje4druu3sw" @@ -109,8 +110,9 @@ visible = false transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -150) visible = false -[node name="Train" type="Node3D" parent="."] +[node name="Train" type="AnimatableBody3D" parent="."] transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, 0) +script = ExtResource("2_aacjs") [node name="ParticleScreen" type="MeshInstance3D" parent="Train"] transform = Transform3D(-42.01, 4.0756225e-07, 4.340116e-07, -6.330816e-06, -2.8743172, -0.1808367, -5.9450595e-06, 0.1808367, -2.8743172, -3.9468384, 1.286, 2.488358) @@ -119,58 +121,28 @@ material_override = SubResource("ShaderMaterial_0vobo") mesh = SubResource("QuadMesh_ppxbm") [node name="Subway" parent="Train" instance=ExtResource("1_2h2xx")] -unique_name_in_owner = true transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.7804413, 0, 0) +script = null [node name="EntryDetect" type="Area3D" parent="Train"] +unique_name_in_owner = true -[node name="Shape1" type="CollisionShape3D" parent="Train/EntryDetect"] +[node name="EntryShape1" type="CollisionShape3D" parent="Train/EntryDetect"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.105429, 1.1704571, 0.0023494991) shape = SubResource("BoxShape3D_5jpg8") -[node name="Seat1" type="Node3D" parent="Train/EntryDetect/Shape1"] +[node name="Seat1" type="Node3D" parent="Train/EntryDetect/EntryShape1"] +unique_name_in_owner = true transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00042915344, -1.042389, 3.5422485e-07) -[node name="Shape2" type="CollisionShape3D" parent="Train/EntryDetect"] +[node name="EntryShape2" type="CollisionShape3D" parent="Train/EntryDetect"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 9.689882, 1.1704571, 4.236329e-07) shape = SubResource("BoxShape3D_5jpg8") -[node name="Seat2" type="Node3D" parent="Train/EntryDetect/Shape2"] +[node name="Seat2" type="Node3D" parent="Train/EntryDetect/EntryShape2"] +unique_name_in_owner = true transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00042915344, -1.042389, 3.5422485e-07) -[node name="ClosedCollider" type="AnimatableBody3D" parent="Train"] - -[node name="FrontWallClosed" type="CollisionShape3D" parent="Train/ClosedCollider"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.8395386, 1.4940796, -1.533) -shape = SubResource("BoxShape3D_aacjs") -disabled = true - -[node name="FrontWallOpen1" type="CollisionShape3D" parent="Train/ClosedCollider"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.8054885, 1.4940796, -1.533) -shape = SubResource("BoxShape3D_4h0n7") - -[node name="FrontWallOpen2" type="CollisionShape3D" parent="Train/ClosedCollider"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 13.442047, 1.4940796, -1.533) -shape = SubResource("BoxShape3D_xhnml") - -[node name="FrontWallOpen3" type="CollisionShape3D" parent="Train/ClosedCollider"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -11.829376, 1.4940796, -1.533) -shape = SubResource("BoxShape3D_5b47p") - -[node name="RearWall" type="CollisionShape3D" parent="Train/ClosedCollider"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.344, 1.457) -shape = SubResource("BoxShape3D_aacjs") - -[node name="DriverCabin1" type="CollisionShape3D" parent="Train/ClosedCollider"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 15.448963, 1.0697384, 0) -shape = SubResource("SphereShape3D_5jpg8") -disabled = true - -[node name="DriverCabin2" type="CollisionShape3D" parent="Train/ClosedCollider"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -13.730333, 1.0697384, 0) -shape = SubResource("SphereShape3D_5jpg8") -disabled = true - [node name="SubwayTrainAudio" type="AudioStreamPlayer3D" parent="Train"] unique_name_in_owner = true stream = ExtResource("3_4h0n7") @@ -203,3 +175,34 @@ spot_angle = 15.0 [node name="CollisionShape3D" type="CollisionShape3D" parent="Train/SubwaySoundAttenuationArea"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.6517792, 1.7406616, 0.034606963) shape = SubResource("BoxShape3D_e1qmr") + +[node name="FrontWallClosed" type="CollisionShape3D" parent="Train"] +unique_name_in_owner = true +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.8395386, 1.4940796, -1.533) +shape = SubResource("BoxShape3D_aacjs") + +[node name="FrontWallOpen1" type="CollisionShape3D" parent="Train"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.80548847, 1.4940796, 0) +shape = SubResource("BoxShape3D_4h0n7") + +[node name="FrontWallOpen2" type="CollisionShape3D" parent="Train"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 13.442047, 1.4940796, 0) +shape = SubResource("BoxShape3D_xhnml") + +[node name="FrontWallOpen3" type="CollisionShape3D" parent="Train"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -11.829376, 1.4940796, 0) +shape = SubResource("BoxShape3D_5b47p") + +[node name="RearWall" type="CollisionShape3D" parent="Train"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.344, 1.457) +shape = SubResource("BoxShape3D_aacjs") + +[node name="DriverCabin1" type="CollisionShape3D" parent="Train"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 15.448963, 1.0697384, 0) +shape = SubResource("SphereShape3D_5jpg8") +disabled = true + +[node name="DriverCabin2" type="CollisionShape3D" parent="Train"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -13.730333, 1.0697384, 0) +shape = SubResource("SphereShape3D_5jpg8") +disabled = true