class_name TrapLever
extends Interactable

@onready var tmp_sprite: Sprite2D = $TmpSprite

func switch_state():
	if active: #can only be activated once!
		return
	else:
		# switch state
		active = !active
		# visual change
		_update_sprite()
		# sfx
		AudioManager.create_audio(SoundEffect.SOUND_EFFECT_TYPE.LEVER_CHANGE_STATE)
	# notify lever_system
	get_parent().notify_system(active)
		
func _save_state():
	super()

func _load_saved_state():
	super()
	get_parent().notify_system(active)
	
func _update_sprite():
	if active:
		tmp_sprite.rotation = 45
	else:
		tmp_sprite.rotation = -0.3
