2026-09-14 18:36:02 +02:00
|
|
|
extends Area3D
|
|
|
|
|
class_name ExitTrigger
|
2026-09-15 12:02:57 +02:00
|
|
|
## Level exit volume. Floating door billboard ONLY for indoor exits (show_door).
|
|
|
|
|
## Outdoor transitions into buildings use ModelProp [E], not this door art.
|
2026-09-14 18:36:02 +02:00
|
|
|
|
|
|
|
|
@export var next_scene_id: String = ""
|
|
|
|
|
@export var use_goto_next: bool = true
|
|
|
|
|
@export var require_flag: String = ""
|
2026-09-15 12:02:57 +02:00
|
|
|
## Indoor only: floating door billboard. Outside houses leave this false.
|
|
|
|
|
@export var show_door: bool = false
|
|
|
|
|
@export var texture_path: String = "res://assets/sprites/placeholders/door.png"
|
|
|
|
|
@export var billboard_height: float = 2.05
|
2026-09-14 18:36:02 +02:00
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
|
body_entered.connect(_on_body_entered)
|
|
|
|
|
collision_layer = 0
|
|
|
|
|
collision_mask = 2 # player layer
|
2026-09-15 12:02:57 +02:00
|
|
|
add_to_group("exit_trigger")
|
|
|
|
|
if show_door:
|
|
|
|
|
_ensure_door_art()
|
|
|
|
|
|
|
|
|
|
func _ensure_door_art() -> void:
|
|
|
|
|
if texture_path == "":
|
|
|
|
|
return
|
|
|
|
|
var bill := get_node_or_null("BillboardSprite")
|
|
|
|
|
if bill == null:
|
|
|
|
|
var packed: PackedScene = load("res://scenes/prefabs/billboard_sprite.tscn")
|
|
|
|
|
if packed == null:
|
|
|
|
|
return
|
|
|
|
|
bill = packed.instantiate()
|
|
|
|
|
bill.name = "BillboardSprite"
|
|
|
|
|
add_child(bill)
|
|
|
|
|
if bill.has_method("set_target_height"):
|
|
|
|
|
bill.set_target_height(billboard_height)
|
|
|
|
|
if bill.has_method("set_texture"):
|
|
|
|
|
var tex: Texture2D = load(texture_path)
|
|
|
|
|
if tex:
|
|
|
|
|
bill.set_texture(tex)
|
2026-09-14 18:36:02 +02:00
|
|
|
|
|
|
|
|
func _on_body_entered(body: Node3D) -> void:
|
|
|
|
|
if not body.is_in_group("player"):
|
|
|
|
|
return
|
|
|
|
|
if require_flag != "" and not GameState.get_flag(require_flag, false):
|
|
|
|
|
var ui := get_node_or_null("/root/UIRoot")
|
|
|
|
|
if ui and ui.has_method("show_dialog"):
|
2026-09-15 12:02:57 +02:00
|
|
|
ui.show_dialog(Locale.tr_key("exit_locked"), 3.0)
|
2026-09-14 18:36:02 +02:00
|
|
|
return
|
|
|
|
|
if use_goto_next and next_scene_id == "":
|
|
|
|
|
GameState.goto_next()
|
|
|
|
|
elif next_scene_id != "":
|
|
|
|
|
GameState.goto_scene(next_scene_id)
|