extends Node2D


# Declare member variables here. Examples:
# var a: int = 2
# var b: String = "text"
export var is_armed = false


func _ready() -> void:
	if(!is_armed):
		$Area2D.remove_from_group("harmful")
		$Sprite/AnimationPlayer.play("unarmed")
	else:
		$Area2D.add_to_group("harmful")
		$Sprite/AnimationPlayer.play("armed")

func _on_Area2D_area_exited(area: Area2D) -> void:
	$Timer.start()


func _on_Timer_timeout() -> void:
	is_armed = true
	$Area2D.add_to_group("harmful")
	$Sprite/AnimationPlayer.play("arming")


func _on_AnimationPlayer_animation_finished(anim_name: String) -> void:
	if(anim_name == "arming"):
		$Sprite/AnimationPlayer.play("armed")
