Some checks failed
Deploy Promiscuity Auth API / deploy (push) Successful in 1m59s
Deploy Promiscuity Character API / deploy (push) Successful in 1m16s
Deploy Promiscuity Inventory API / deploy (push) Has been cancelled
Deploy Promiscuity Locations API / deploy (push) Has been cancelled
Deploy Promiscuity Mail API / deploy (push) Has been cancelled
Deploy Promiscuity World API / deploy (push) Has been cancelled
Deploy Promiscuity Crafting API / deploy (push) Has been cancelled
k8s smoke test / test (push) Has been cancelled
57 lines
1.6 KiB
GDScript
57 lines
1.6 KiB
GDScript
extends Area3D
|
|
|
|
@export_file("*.tscn") var target_scene_path := "res://scenes/Levels/transportation_level.tscn"
|
|
@export var target_group: StringName = &"player"
|
|
@export var one_shot := true
|
|
@export var target_spawn_name: StringName = &""
|
|
@export var quest_event_name: StringName = &""
|
|
@export var quest_id_filter: String = ""
|
|
|
|
var _is_transitioning := false
|
|
|
|
|
|
func _ready() -> void:
|
|
body_entered.connect(_on_body_entered)
|
|
|
|
|
|
func _on_body_entered(body: Node) -> void:
|
|
if _is_transitioning:
|
|
return
|
|
if target_group != StringName() and not body.is_in_group(target_group):
|
|
return
|
|
if target_scene_path.strip_edges() == "":
|
|
push_warning("Teleporter target scene is empty.")
|
|
return
|
|
if not ResourceLoader.exists(target_scene_path):
|
|
push_warning("Teleporter target scene does not exist: %s" % target_scene_path)
|
|
return
|
|
_emit_quest_event(body)
|
|
if TeleportState != null:
|
|
TeleportState.request_spawn(target_spawn_name)
|
|
|
|
_is_transitioning = true
|
|
if one_shot:
|
|
set_deferred("monitoring", false)
|
|
call_deferred("_deferred_change_scene")
|
|
|
|
|
|
func _emit_quest_event(body: Node) -> void:
|
|
if quest_event_name == StringName() or QuestManager == null:
|
|
return
|
|
if quest_id_filter.strip_edges() != "" and QuestManager.get_active_quest_id() != StringName(quest_id_filter):
|
|
return
|
|
QuestManager.emit_event(quest_event_name, {
|
|
"body": body,
|
|
"source": self,
|
|
})
|
|
|
|
|
|
func _deferred_change_scene() -> void:
|
|
var err := get_tree().change_scene_to_file(target_scene_path)
|
|
if err == OK:
|
|
return
|
|
push_warning("Failed to change scene to '%s' (%s)." % [target_scene_path, err])
|
|
_is_transitioning = false
|
|
if one_shot:
|
|
set_deferred("monitoring", true)
|