34 lines
814 B
GDScript
34 lines
814 B
GDScript
extends Area2D
|
|
class_name InspectableEntity
|
|
|
|
const MODULATE_INSPECTED_COLOR = Color.GRAY
|
|
|
|
@onready var default_modulate : Color = modulate
|
|
@onready var inspectable_signals_setuped : bool = setup_inspectable_signals()
|
|
|
|
func inspect(is_inspected : bool = true):
|
|
modulate = MODULATE_INSPECTED_COLOR if is_inspected else default_modulate
|
|
|
|
func setup_inspectable_signals() -> bool:
|
|
mouse_entered.connect(_on_mouse_entered)
|
|
mouse_exited.connect(_on_mouse_excited)
|
|
return true
|
|
|
|
func _on_mouse_entered():
|
|
Pointer.inspect(self, inspector_info())
|
|
|
|
func _on_mouse_excited():
|
|
Pointer.stop_inspect(self)
|
|
|
|
func pointer_text():
|
|
return ""
|
|
|
|
func inspector_info() -> Inspector.Info:
|
|
return Inspector.Info.new(
|
|
pointer_text()
|
|
)
|
|
|
|
func _notification(what):
|
|
if (what == NOTIFICATION_PREDELETE):
|
|
Pointer.stop_inspect(self)
|