extends RigidBody2D

export var Force = 2000 #impulse
export var Bonus = 3
var last_fired = 0

func _ready():
	connect("body_entered", self, "_on_ball_enter");

func _on_ball_enter(body):
	if not body.has_method("kick_after"):
		return
	var t = OS.get_ticks_msec()
	if t - last_fired < 100: # milliseconds cooldown
		return
	var normal = (body.position - position).normalized()
	body.kick_after(Vector2(0, 0), normal * Force)
	$"/root/global".score += Bonus
	$Aplayer.play()
	last_fired = t