extends Actor
class_name Enemy

export(bool) var killable := true


func _on_StompDetector_body_entered(body: Node) -> void:
	if !body.is_in_group("player"):
		return
	var incoming_vel_vector: Vector2 = body.velocity.normalized()
	print(rad2deg(abs(incoming_vel_vector.angle_to(Vector2.DOWN.rotated(rotation)))))
	if abs(incoming_vel_vector.angle_to(Vector2.DOWN.rotated(rotation))) > deg2rad(95):
		print("too shallow entry")
		body.die()
		return
	signal_manager.emit_signal("got_stomped")
	#get_node("EnemyBody").disabled = true
	if(killable):
		remove_from_group("harmful")
		die()


func die() -> void:
	queue_free()


func _on_EnemySkin_area_entered(area: Area2D) -> void:
	if area.is_in_group("harmful"):
		#get_node("EnemyBody").disabled = true
		die()


func _on_EnemySkin_body_entered(body: Node) -> void:
	if body.is_in_group("player"):
		body.die()
