class_name Projectile
extends Area2D
##TODO: Probably implement some sort of object pooling option
## so wen're not just deleting itself every timemout or screen exit.

# Declare member variables here. Examples:
# var a = 2
# var b = "text"

export var velocity_pps :float = 1
export var lifespan :float = -1
var direction_normal := Vector2(0,0)

var time_alive :float = 0.0
# Called when the node enters the scene tree for the first time.
func _ready():
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	if lifespan != -1:
		time_alive += delta
		if time_alive > lifespan:
			queue_free()
	rotate(delta * 10)
	position += direction_normal * velocity_pps * delta
	

func _on_body_entered(body):
	var colliding_node = body
	if colliding_node.has_node("Projectile_Receiver"):
		colliding_node.get_node("Projectile_Receiver").register_interactable(self)


func _on_area_entered(area):
	pass # Replace with function body.


func _on_VisibilityNotifier2D_screen_exited():
	queue_free()
