class_name Ball
extends RigidBody2D


const BRICK_LAYER = 2
const INTERRUPT_SPEED = 700


export (Color) var interrupt_color = Color.white


func interrupt_ball() -> void:
	modulate = interrupt_color
	go_down_unstopped()


func go_down_unstopped() -> void:
	linear_velocity.y = INTERRUPT_SPEED
	linear_velocity = linear_velocity.normalized() * INTERRUPT_SPEED
	set_collision_mask_bit(BRICK_LAYER, false)


func _on_Launcher_interrupt_wave() -> void:
	interrupt_ball()


func _on_Ball_body_entered(body: Node) -> void:
	if body.has_method("impact"):
		body.impact(position)


func _on_Ball_body_exited(body: Node) -> void:
	if body.has_method("bounce"):
		body.bounce(position)