extends StaticBody

var slapsound = preload("res://sounds/SFX/slap.wav")


func _ready():
	$AnimationPlayer.play("idle")
	
	
func _process(delta):
	$RotationHelper.look_at(get_parent().get_node("CircularMan").translation,Vector3(0,1,0))
	$RotationHelper.rotation_degrees.y -= 180
	$RotationHelper.rotation_degrees.x = 0
	$RotationHelper.rotation_degrees.z = 0


func take_damage(amount,type,source):
	if type == ext.DAMAGE_TYPES.MELEE:
		for body in $AoE.get_overlapping_bodies():
			if body.has_method("yeet"):
				if body.has_method("take_damage"):
					body.take_damage(2)
				$AnimationPlayer.play("slap")
				$Slap.stream = slapsound
				$Slap.play()
				body.yeet()


func _on_AnimationPlayer_animation_finished(anim_name):
	if anim_name == "slap":
		$AnimationPlayer.play("idle")
