extends Node3D

signal activated

@export var enabled := true

@onready var interactive: Interactive = %Interactive


func _ready() -> void:
	if enabled:
		enable()
	else:
		disable()


func enable() -> void:
	enabled = true
	interactive.enabled = _has_item()


func disable() -> void:
	enabled = false
	interactive.enabled = false


func _has_item() -> bool:
	return Player.instance and Item.catalog.eyeballs in Player.instance.inventory


func _activate() -> void:
	if enabled and Item.catalog.eyeballs in Player.instance.inventory:
		# TODO play animation/sfx
		activated.emit()
	else:
		# TODO bonk
		pass


func _on_interactive_selected() -> void:
	if enabled:
		interactive.enabled = _has_item()
