Adding scene teleporter
This commit is contained in:
+50
-25
@@ -13,10 +13,12 @@ var time := 0.0
|
||||
@onready var _player: Node = $Player
|
||||
@onready var _quest_text: RichTextLabel = $PhoneUI/Control/PhoneFrame/QuestText
|
||||
|
||||
const FIRST_QUEST_ID := "first_drive"
|
||||
const FIRST_QUEST := {
|
||||
"id": FIRST_QUEST_ID,
|
||||
"title": "RepoBot's First Task",
|
||||
const FIRST_QUEST_ID := "first_drive"
|
||||
const QUEST_PROMPT_META_PREFIX := "quest_intro_prompt_shown_"
|
||||
const SPAWN_DIALOG_META_KEY := "level_spawn_dialog_shown"
|
||||
const FIRST_QUEST := {
|
||||
"id": FIRST_QUEST_ID,
|
||||
"title": "RepoBot's First Task",
|
||||
"description": "Get familiar with movement and vehicles.",
|
||||
"steps": [
|
||||
{
|
||||
@@ -32,16 +34,17 @@ const FIRST_QUEST := {
|
||||
],
|
||||
}
|
||||
|
||||
func _ready() -> void:
|
||||
_setup_quests()
|
||||
if show_spawn_dialog and DialogSystem and DialogSystem.has_method("show_text"):
|
||||
await get_tree().process_frame
|
||||
DialogSystem.show_text(spawn_dialog_text)
|
||||
if spawn_dialog_auto_close_seconds > 0.0:
|
||||
await get_tree().create_timer(spawn_dialog_auto_close_seconds).timeout
|
||||
if DialogSystem and DialogSystem.has_method("close_if_text"):
|
||||
DialogSystem.close_if_text(spawn_dialog_text)
|
||||
_show_quest_intro_dialog()
|
||||
func _ready() -> void:
|
||||
_setup_quests()
|
||||
if _should_show_spawn_dialog() and DialogSystem and DialogSystem.has_method("show_text"):
|
||||
await get_tree().process_frame
|
||||
DialogSystem.show_text(spawn_dialog_text)
|
||||
_mark_spawn_dialog_shown()
|
||||
if spawn_dialog_auto_close_seconds > 0.0:
|
||||
await get_tree().create_timer(spawn_dialog_auto_close_seconds).timeout
|
||||
if DialogSystem and DialogSystem.has_method("close_if_text"):
|
||||
DialogSystem.close_if_text(spawn_dialog_text)
|
||||
_show_quest_intro_dialog()
|
||||
|
||||
func _process(delta):
|
||||
time = fmod((time + delta), day_length)
|
||||
@@ -94,14 +97,36 @@ func _refresh_quest_ui() -> void:
|
||||
_quest_text.text = "[b]%s[/b]\nStep %d/%d\n%s" % [title, step_index + 1, total_steps, step_text]
|
||||
|
||||
|
||||
func _show_quest_intro_dialog() -> void:
|
||||
if QuestManager == null:
|
||||
return
|
||||
var state: Dictionary = QuestManager.get_active_quest_state()
|
||||
if not bool(state.get("active", false)) or bool(state.get("completed", false)):
|
||||
return
|
||||
var step_text := String(state.get("current_step_text", ""))
|
||||
if step_text.is_empty():
|
||||
return
|
||||
if DialogSystem and DialogSystem.has_method("show_text"):
|
||||
DialogSystem.show_text("RepoBot: New task assigned.\n\n%s" % step_text)
|
||||
func _show_quest_intro_dialog() -> void:
|
||||
if QuestManager == null:
|
||||
return
|
||||
var state: Dictionary = QuestManager.get_active_quest_state()
|
||||
if not bool(state.get("active", false)) or bool(state.get("completed", false)):
|
||||
return
|
||||
var quest_id := String(state.get("quest_id", "")).strip_edges()
|
||||
var step_id := String(state.get("current_step_id", "")).strip_edges()
|
||||
var step_text := String(state.get("current_step_text", ""))
|
||||
if quest_id.is_empty() or step_id.is_empty() or step_text.is_empty():
|
||||
return
|
||||
var prompt_key := "%s%s_%s" % [QUEST_PROMPT_META_PREFIX, quest_id, step_id]
|
||||
if QuestManager.has_meta(prompt_key) and bool(QuestManager.get_meta(prompt_key)):
|
||||
return
|
||||
if DialogSystem and DialogSystem.has_method("show_text"):
|
||||
DialogSystem.show_text("RepoBot: New task assigned.\n\n%s" % step_text)
|
||||
QuestManager.set_meta(prompt_key, true)
|
||||
|
||||
|
||||
func _should_show_spawn_dialog() -> bool:
|
||||
if not show_spawn_dialog:
|
||||
return false
|
||||
if QuestManager == null:
|
||||
return true
|
||||
if not QuestManager.has_meta(SPAWN_DIALOG_META_KEY):
|
||||
return true
|
||||
return not bool(QuestManager.get_meta(SPAWN_DIALOG_META_KEY))
|
||||
|
||||
|
||||
func _mark_spawn_dialog_shown() -> void:
|
||||
if QuestManager == null:
|
||||
return
|
||||
QuestManager.set_meta(SPAWN_DIALOG_META_KEY, true)
|
||||
|
||||
Reference in New Issue
Block a user