extends Node3D

@onready var indirect_light = $"../IndirectLight"
@onready var dakraam = $"../Room/Dakraam"
var dakraam_glas 

func _ready():
	if dakraam:
		dakraam_glas = $"../Room/Dakraam".get_surface_override_material(0)

func _on_lock_input_event(_camera, event, _position, _normal, _shape_idx):
	if event is InputEventMouseButton and event.is_action_pressed("interact"):
		if get_node("../Player").has_key:
			$Deur.visible = false
			$Lock.visible = false
			$Lock/DeurOpen.playing = true
			$"../Gui".clear_items()


func _on_lever_input_event(_camera, event, _position, _normal, _shape_idx):
	if event is InputEventMouseButton and event.is_action_pressed("interact"):
		$Lever/LeverOmhaal.playing = true
		$Lever.rotation.z = $Lever.rotation.z + PI
		indirect_light.visible = !indirect_light.visible
		if indirect_light.visible:
			dakraam.set_surface_override_material(0, dakraam_glas)
		else:
			dakraam.set_surface_override_material(0, null)
