## What Am I Looking At (Waila)
|
|
class_name Waila
|
|
extends MarginContainer
|
|
|
|
|
|
#region Singleton
|
|
static var ref: Waila
|
|
|
|
func _init() -> void:
|
|
if not ref:
|
|
ref = self
|
|
else:
|
|
queue_free()
|
|
#endregion
|
|
|
|
|
|
@onready var name_label: Label = $PanelContainer/MarginContainer/VBoxContainer/Name
|
|
@onready var description_label: Label = $PanelContainer/MarginContainer/VBoxContainer/Description
|
|
@onready var position_label: Label = $PanelContainer/MarginContainer/VBoxContainer/Position
|
|
|
|
var _target: Block
|
|
|
|
|
|
func _ready() -> void:
|
|
release_target()
|
|
|
|
|
|
func get_target() -> Block:
|
|
return _target
|
|
|
|
func hook_target(id: String) -> void:
|
|
if not Globals.enable_waila: return
|
|
if not id: return
|
|
|
|
var item: ItemResource = DBItems.data[id]
|
|
name_label.text = item.name + " (" + id + ")"
|
|
description_label.text = item.description
|
|
position_label.text = str(_target.position)
|
|
|
|
visible = true
|
|
|
|
## Not looking at anything, hide Waila
|
|
func release_target() -> void:
|
|
visible = false
|
|
set_target(null)
|
|
|
|
func set_target(target_block: Block) -> void:
|
|
_target = target_block
|