64 lines
1.6 KiB
GDScript
64 lines
1.6 KiB
GDScript
extends Sprite2D
|
|
|
|
# @export var entity_config: EntityConfig:
|
|
# set(value):
|
|
# entity_config = value
|
|
|
|
@export var entity_name: String = ""
|
|
@export var entity_title: String = ""
|
|
@export var texture_cover: Texture2D
|
|
@export var texture_note: Texture2D
|
|
@export_multiline var inspection_note: String = ""
|
|
|
|
@onready var sprite2d = %AnimatedSoundSprite2D as AnimatedSoundSprite2D
|
|
@onready var sign_mark = %Sign as Sign
|
|
@onready var area2d = %Area2D as Area2D
|
|
|
|
var inspecting = false
|
|
|
|
|
|
func _ready() -> void:
|
|
area2d.body_entered.connect(_reset)
|
|
area2d.body_exited.connect(_on_cancel)
|
|
sign_mark.interacted.connect(_on_interacted)
|
|
sign_mark.cancel.connect(_on_cancel)
|
|
# if GlobalConfig.DEBUG:
|
|
# var label = DebugLabel.new()
|
|
# add_child(label)
|
|
# label.name = "DebugLabel"
|
|
|
|
|
|
func _on_interacted() -> void:
|
|
if not texture_cover or not texture_note:
|
|
push_error("entity/inspectable.gd: texture_cover or texture_note is not set")
|
|
return
|
|
if inspecting:
|
|
return
|
|
%Sfx.play()
|
|
# connect inspector quit signal
|
|
var inspector = SceneManager.get_inspector()
|
|
if inspector:
|
|
inspector.quit.connect(_on_quit_inspector)
|
|
if not texture_note:
|
|
texture_note = texture_cover
|
|
inspector.pop_inspection(texture_cover, texture_note, inspection_note)
|
|
inspecting = true
|
|
sign_mark.show_sign = false
|
|
|
|
|
|
func _on_quit_inspector():
|
|
var inspector = SceneManager.get_inspector()
|
|
if inspector:
|
|
# disconnect inspector quit signal
|
|
inspector.quit.disconnect(_on_quit_inspector)
|
|
inspecting = false
|
|
sign_mark.show_sign = true
|
|
|
|
|
|
func _on_cancel(_body = null):
|
|
inspecting = false
|
|
|
|
|
|
func _reset(_body):
|
|
inspecting = false
|