extends Node3D ## Kies-Kurve zwischen zwei Terrassen (CR-003). ## ## Eine schulterbreite Serpentinen-Kehre am Terrassen-Ende: Sie schwingt ## über den Sturzkorridor hinaus (Sichtlinie auf stürzende Rivalen), ## steigt über zwei Rampen und eine Wende-Plattform um height_gain und ## mündet auf der nächsten Terrasse. Echte Laufwege mit Zeitanteil im ## Ernstlauf und Rast-Zone (Griff-Erholung) im Training wie im Lauf. ## side spiegelt die Kurve für linke Terrassen-Enden. exit_reached feuert, ## wenn Tyrveil oben ankommt (Checkpoint/Story-Hook übernimmt die Szene). signal exit_reached @export var height_gain := 6.0 @export var side := 1 @export var curve_length := 4.0 @export var curve_width := 0.9 var _has_fired := false ## Baut Einstiegs-Plattform, Hinauf-Rampe, Wende-Plattform, Rück-Rampe, ## Ausstiegs-Plattform sowie Rast- und Ausstiegs-Zone. func _ready() -> void: var h := height_gain var out_z := curve_length + 0.6 _build_walk_box(Vector3(2.0, 0.3, 2.4), Vector3(0, -0.15, 0), 0.0) var slope := atan2(h / 2.0, out_z - 0.7) var ramp_length := sqrt(pow(h / 2.0, 2.0) + pow(out_z - 0.7, 2.0)) + 0.6 _build_walk_box(Vector3(curve_width, 0.25, ramp_length), Vector3(-0.6 * float(side), h * 0.25, out_z / 2.0 + 0.2), -slope) _build_walk_box(Vector3(2.6, 0.3, 1.5), Vector3(0.4 * float(side), h * 0.5 - 0.15, out_z + 0.7), 0.0) _build_walk_box(Vector3(curve_width, 0.25, ramp_length), Vector3(1.5 * float(side), h * 0.75, out_z / 2.0 + 0.2), slope) _build_walk_box(Vector3(3.2, 0.3, 2.0), Vector3(0.4 * float(side), h - 0.15, -0.3), 0.0) var rest := _build_zone(Vector3(4.6, h + 3.0, out_z + 3.0), Vector3(0.4 * float(side), h * 0.5 + 1.0, out_z / 2.0)) rest.add_to_group("gauntlet_rest") var exit_zone := _build_zone(Vector3(3.2, 2.2, 2.0), Vector3(0.4 * float(side), h + 1.1, -0.3)) exit_zone.body_entered.connect(_on_exit_entered) ## Liefert die Welt-Position des Kurven-Ausstiegs (Respawn-Punkt). func get_exit_position() -> Vector3: return to_global(Vector3(0.4 * float(side), height_gain + 0.2, -0.3)) ## Meldet das Erreichen des Ausstiegs einmalig. func _on_exit_entered(body: Node3D) -> void: if _has_fired or not body.is_in_group("player"): return _has_fired = true exit_reached.emit() ## Baut ein begehbares Kurven-Stück (Kollision + Mesh), optional geneigt. func _build_walk_box(box_size: Vector3, local_position: Vector3, tilt: float) -> void: var body := StaticBody3D.new() body.position = local_position body.rotation.x = tilt var shape := CollisionShape3D.new() var box := BoxShape3D.new() box.size = box_size shape.shape = box body.add_child(shape) var mesh_instance := MeshInstance3D.new() var mesh := BoxMesh.new() mesh.size = box_size var material := StandardMaterial3D.new() material.albedo_color = Color(0.62, 0.58, 0.5) mesh.material = material mesh_instance.mesh = mesh body.add_child(mesh_instance) add_child(body) ## Baut eine Trigger-Zone (nur Spieler-Layer). func _build_zone(box_size: Vector3, local_position: Vector3) -> Area3D: var area := Area3D.new() area.collision_layer = 0 area.collision_mask = 2 area.position = local_position var shape := CollisionShape3D.new() var box := BoxShape3D.new() box.size = box_size shape.shape = box area.add_child(shape) add_child(area) return area