mirror of
https://github.com/kodzukye/scrap-signal.git
synced 2026-04-26 19:17:35 +00:00
43 lines
1.3 KiB
GDScript
43 lines
1.3 KiB
GDScript
class_name Journal
|
|
extends Area2D
|
|
|
|
@export var prompt_text: String = "[E] Read"
|
|
@export var journal_id: String = ""
|
|
|
|
const DIALOGUE: Array[Dictionary] = [
|
|
{ "name": "JOURNAL D-447", "text": "The lights went out. The humans didn't come back. We kept going." },
|
|
{ "name": "JOURNAL D-447", "text": "The units stopped receiving orders. They continue anyway. It's as if they decided." },
|
|
]
|
|
|
|
func _ready() -> void:
|
|
body_entered.connect(_on_body_entered)
|
|
body_exited.connect(_on_body_exited)
|
|
|
|
func interact() -> void:
|
|
print("Journal interact() appelé")
|
|
|
|
var hud := get_tree().get_first_node_in_group("hud")
|
|
if hud:
|
|
hud.hide_prompt()
|
|
|
|
if journal_id != "":
|
|
GameState.set_flag(journal_id + "_read", true)
|
|
|
|
var dialogue_box := get_tree().get_first_node_in_group("dialogue_box")
|
|
print("dialogue_box trouvé : ", dialogue_box)
|
|
|
|
AudioManager.play_sfx("interact")
|
|
if dialogue_box:
|
|
print("Lancement dialogue avec : ", DIALOGUE)
|
|
dialogue_box.start(DIALOGUE)
|
|
|
|
func _on_body_entered(body: Node) -> void:
|
|
if body.is_in_group("player"):
|
|
var hud: HUD = get_tree().get_first_node_in_group("hud")
|
|
if hud: hud.show_prompt(prompt_text)
|
|
|
|
func _on_body_exited(body: Node) -> void:
|
|
if body.is_in_group("player"):
|
|
var hud: HUD = get_tree().get_first_node_in_group("hud")
|
|
if hud: hud.hide_prompt()
|