Gate phone dialogue on heard discoveries and fix memory display
This commit is contained in:
@@ -36,6 +36,8 @@ var busy_end := 0.0
|
||||
var reply_at := 0.0
|
||||
var replied := false
|
||||
var speech_until := 0.0
|
||||
var pending_line := ""
|
||||
var pending_line_end := 0.0
|
||||
var outcome := ""
|
||||
var heard: Array[String] = []
|
||||
var archive: Array = []
|
||||
@@ -51,6 +53,7 @@ var command_list: Container
|
||||
var transcript: VBoxContainer
|
||||
var transcript_scroll: ScrollContainer
|
||||
var journal: RichTextLabel
|
||||
var memory_content: RichTextLabel
|
||||
var clock_label: Label
|
||||
var status_label: Label
|
||||
var objects_label: Label
|
||||
@@ -172,6 +175,7 @@ func clear_children(parent: Node) -> void:
|
||||
child.queue_free()
|
||||
|
||||
func close_overlay() -> void:
|
||||
memory_content = null
|
||||
menu_screen = ""
|
||||
menu_content = null
|
||||
stage.set_menu_mode(false)
|
||||
@@ -307,7 +311,9 @@ func show_memory() -> void:
|
||||
var text := RichTextLabel.new()
|
||||
text.custom_minimum_size = Vector2(640,410)
|
||||
text.add_theme_font_size_override("normal_font_size",20)
|
||||
text.text = journal.text
|
||||
text.name = "MemoryText"
|
||||
text.text = memory_text()
|
||||
memory_content = text
|
||||
box.add_child(text)
|
||||
box.add_child(button("Вернуться к звонку","close_memory",close_overlay))
|
||||
|
||||
@@ -423,10 +429,10 @@ func show_test_menu() -> void:
|
||||
menu_action(box,"Начать проверку","test_start",func(): dial_call(choices.selected+1,true,knowledge.selected),true)
|
||||
menu_action(box,"Назад","back_menu",show_menu)
|
||||
|
||||
func dial_call(number: int, testing: bool, knowledge: int = 1, animate_in_qa: bool = false) -> void:
|
||||
func dial_call(number: int, testing: bool, knowledge: int = 1, animate_in_qa: bool = false, retained_facts: Variant = null) -> void:
|
||||
if dialing: return
|
||||
if qa_mode and not animate_in_qa:
|
||||
begin_call(number,testing,knowledge)
|
||||
begin_call(number,testing,knowledge,retained_facts)
|
||||
return
|
||||
dial_epoch += 1
|
||||
var epoch := dial_epoch
|
||||
@@ -445,9 +451,9 @@ func dial_call(number: int, testing: bool, knowledge: int = 1, animate_in_qa: bo
|
||||
stage.begin_dial()
|
||||
await get_tree().create_timer(2.4).timeout
|
||||
if epoch != dial_epoch: return
|
||||
begin_call(number,testing,knowledge)
|
||||
begin_call(number,testing,knowledge,retained_facts)
|
||||
|
||||
func begin_call(number: int, testing: bool, knowledge: int = 1) -> void:
|
||||
func begin_call(number: int, testing: bool, knowledge: int = 1, retained_facts: Variant = null) -> void:
|
||||
dial_epoch += 1
|
||||
dialing = false
|
||||
# A test never writes the normal profile, including learned facts.
|
||||
@@ -457,6 +463,7 @@ func begin_call(number: int, testing: bool, knowledge: int = 1) -> void:
|
||||
endings = saved.endings
|
||||
completed = mini(saved.loops, 10)
|
||||
test_mode = testing
|
||||
if retained_facts != null: facts = retained_facts.duplicate()
|
||||
if testing and knowledge == 0: facts = {}
|
||||
if testing and knowledge == 2:
|
||||
facts = {}
|
||||
@@ -479,6 +486,7 @@ func begin_call(number: int, testing: bool, knowledge: int = 1) -> void:
|
||||
screen_fade.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
elapsed = 0
|
||||
speech_until = 0
|
||||
pending_line = ""
|
||||
place = "flat"
|
||||
items = {}
|
||||
done = {}
|
||||
@@ -495,7 +503,7 @@ func begin_call(number: int, testing: bool, knowledge: int = 1) -> void:
|
||||
if chapter == 1:
|
||||
for beat in story.intro: events.append(beat.duplicate())
|
||||
else:
|
||||
var entry: Dictionary = story.chapters[chapter - 1]
|
||||
var entry: Dictionary = opening_for(chapter)
|
||||
var opening_at := voice_length("greeting") + 0.2
|
||||
events.append({"at": opening_at, "line": entry.opening})
|
||||
events.append({"at": opening_at + 0.3 + voice_length(entry.opening), "line": entry.reply})
|
||||
@@ -525,6 +533,9 @@ func advance() -> void:
|
||||
if not fired.has(id) and float(story.timeline[id]) < next_time:
|
||||
next_time = story.timeline[id]
|
||||
kind = id
|
||||
if not pending_line.is_empty() and pending_line_end < next_time:
|
||||
next_time = pending_line_end
|
||||
kind = "heard"
|
||||
if not events.is_empty() and float(events[0].at) < next_time:
|
||||
next_time = events[0].at
|
||||
kind = "dialogue"
|
||||
@@ -539,6 +550,7 @@ func advance() -> void:
|
||||
elapsed = next_time
|
||||
soundscape.advance(elapsed, place)
|
||||
match kind:
|
||||
"heard": complete_line()
|
||||
"impact":
|
||||
fired.impact = elapsed
|
||||
strike()
|
||||
@@ -586,11 +598,42 @@ func advance() -> void:
|
||||
soundscape.advance(elapsed, place)
|
||||
refresh_live()
|
||||
|
||||
func has_facts(required: Array) -> bool:
|
||||
for key in required:
|
||||
if not facts.has(key): return false
|
||||
return true
|
||||
|
||||
func line_allowed(id: String) -> bool:
|
||||
var rule: Dictionary = story.line_rules.get(id,{})
|
||||
if not has_facts(rule.get("facts",[])): return false
|
||||
if rule.has("places") and place not in rule.places: return false
|
||||
for key in rule.get("items",[]):
|
||||
if not items.has(key): return false
|
||||
return true
|
||||
|
||||
func opening_for(number: int) -> Dictionary:
|
||||
var entry: Dictionary = story.chapters[number-1]
|
||||
return entry if has_facts(entry.get("opening_facts",[])) else story.fallback_opening
|
||||
|
||||
func complete_line() -> void:
|
||||
var id := pending_line
|
||||
pending_line = ""
|
||||
var learned := false
|
||||
for key in story.line_rules.get(id,{}).get("learn",[]):
|
||||
if not facts.has(key):
|
||||
facts[key] = true
|
||||
learned = true
|
||||
system_caption("Ты запомнила: " + str(story.facts[key]))
|
||||
if learned:
|
||||
save_progress()
|
||||
refresh()
|
||||
|
||||
func command_allowed(action: Dictionary) -> bool:
|
||||
if not running or chapter == 1 or fired.has("hum") or elapsed >= float(story.timeline.hum) or not busy.is_empty(): return false
|
||||
if action.get("once", false) and done.has(action.id): return false
|
||||
if action.has("places") and place not in action.places: return false
|
||||
if action.get("power", false) and elapsed >= float(story.timeline.power): return false
|
||||
if not line_allowed(action.request): return false
|
||||
for key in action.get("facts", []):
|
||||
if not facts.has(key): return false
|
||||
for key in action.get("unknown", []):
|
||||
@@ -639,10 +682,6 @@ func finish_task() -> void:
|
||||
busy = {}
|
||||
soundscape.cancel_task()
|
||||
done[action.id] = true
|
||||
for key in action.get("learn", []):
|
||||
if not facts.has(key):
|
||||
facts[key] = true
|
||||
system_caption("Ты запомнила: " + str(story.facts[key]))
|
||||
for key in action.get("give", []): items[key] = true
|
||||
if action.has("move"):
|
||||
place = action.move
|
||||
@@ -662,6 +701,7 @@ func strike() -> void:
|
||||
running = false
|
||||
busy = {}
|
||||
events.clear()
|
||||
pending_line = ""
|
||||
voice.stop()
|
||||
soundscape.stop()
|
||||
siren.stop()
|
||||
@@ -748,10 +788,7 @@ func continue_call(retry: bool = false) -> void:
|
||||
var remembered := facts.duplicate()
|
||||
var number := chapter if retry else mini(chapter + 1, 10)
|
||||
var was_test := test_mode
|
||||
await dial_call(number, was_test)
|
||||
if was_test:
|
||||
facts = remembered
|
||||
refresh()
|
||||
await dial_call(number, was_test, 1, false, remembered if was_test else null)
|
||||
|
||||
func show_transcript() -> void:
|
||||
var box := menu_page("transcript")
|
||||
@@ -764,14 +801,19 @@ func show_transcript() -> void:
|
||||
box.add_child(text)
|
||||
box.add_child(button("Назад", "back_ending", show_outcome))
|
||||
|
||||
func memory_text() -> String:
|
||||
var entries: PackedStringArray = []
|
||||
for key in story.facts:
|
||||
if facts.has(key): entries.append("• " + str(story.facts[key]))
|
||||
return "Мама ещё не рассказала ничего, что поможет действовать иначе.\n\nСпрашивай и дослушивай ответы — услышанное появится здесь." if entries.is_empty() else "\n\n".join(entries)
|
||||
|
||||
func refresh() -> void:
|
||||
if not is_instance_valid(journal): return
|
||||
var entry: Dictionary = story.chapters[chapter - 1]
|
||||
title_label.text = entry.title
|
||||
title_label.text = entry.title if has_facts(entry.get("title_facts",[])) else "Снова звонок"
|
||||
phase_label.text = ("ПРОВЕРКА · " if test_mode else "") + "ЗВОНОК %02d / 10" % chapter
|
||||
journal.text = "Пока только её голос." if facts.is_empty() else ""
|
||||
for key in story.facts:
|
||||
if facts.has(key): journal.append_text(str(story.facts[key]) + "\n\n")
|
||||
journal.text = memory_text()
|
||||
if is_instance_valid(memory_content): memory_content.text = memory_text()
|
||||
refresh_commands()
|
||||
refresh_live()
|
||||
|
||||
@@ -791,9 +833,9 @@ func refresh_commands() -> void:
|
||||
return
|
||||
if not busy.is_empty(): return
|
||||
var entry: Dictionary = story.chapters[chapter - 1]
|
||||
if not done.has("question"):
|
||||
if not done.has("question") and line_allowed(entry.question):
|
||||
command_list.add_child(stage.chip("«"+str(story.lines[entry.question].text)+"»","question",func():choose_action("question")))
|
||||
var names := {"look":"У входной двери", "keys_search":"Найти ключи", "keys_fast":"Ключи в куртке", "lamp_search":"Проверить фонарь", "lamp_fast":"Повернуть батарейку", "mail_hint":"Вспомнить письмо", "read_mail":"Прочитать почту", "safe":"Сейф · 0417", "front":"На площадку", "stairs":"Проверить лестницу", "side_try":"Боковая дверь", "side_open":"Ручку вверх и ключ", "inner":"Во внутренний коридор", "back":"Вернуться в квартиру", "neighbor":"Постучать соседке", "phone_test":"Проверить связь", "phone_shelf":"Телефон на полку", "speak_here":"Мам, я здесь", "speak_love":"Я люблю тебя"}
|
||||
var names := {"look":"У входной двери", "keys_search":"Найти ключи", "keys_fast":"Ключи в куртке", "lamp_search":"Поискать фонарь", "lamp_fast":"Повернуть батарейку", "mail_hint":"Спросить о почте", "read_mail":"Прочитать письмо", "safe":"Сейф · 0417", "front":"На площадку", "stairs":"Проверить лестницу", "side_try":"Боковая дверь", "side_open":"Ручку вверх и ключ", "inner":"Подальше от окон", "back":"Вернуться в квартиру", "neighbor":"Постучать соседке", "phone_test":"Проверить связь", "phone_shelf":"Телефон на полку", "speak_here":"Мам, я здесь", "speak_love":"Я люблю тебя"}
|
||||
for action in story.actions:
|
||||
if command_allowed(action):
|
||||
var id: String = action.id
|
||||
@@ -853,12 +895,19 @@ func voice_length(id: String) -> float:
|
||||
|
||||
func say(id: String) -> void:
|
||||
if running and fired.has("hum") and id != "hum": return
|
||||
if not line_allowed(id): return
|
||||
var entry: Dictionary = story.lines[id]
|
||||
heard.append(id)
|
||||
stage.speaker = entry.speaker
|
||||
speech_until = elapsed + voice_length(id) + 0.08
|
||||
pending_line = id if running else ""
|
||||
pending_line_end = speech_until
|
||||
update_choice_state()
|
||||
add_caption(entry.speaker, entry.text)
|
||||
archive[-1]["line"] = id
|
||||
archive[-1]["known"] = facts.keys()
|
||||
archive[-1]["items"] = items.keys()
|
||||
archive[-1]["place"] = place
|
||||
voice.stop()
|
||||
if id == "intro_04": soundscape.turn_tv_down()
|
||||
if id == "intro_06": soundscape.world_cue("footsteps", elapsed + voice_length(id) + 0.1)
|
||||
|
||||
Reference in New Issue
Block a user