class_name BallZone extends Area3D
## A spatial area that has an effect on balls inside it.

@export var water_hazard := false


func _ready() -> void:
	body_entered.connect(_on_body_entered)
	body_exited.connect(_on_body_exited)


func on_ball_entered(ball: GameBall) -> void:
	if water_hazard:
		ball.entered_water.emit()


func on_ball_exited(ball: GameBall) -> void:
	pass


func _on_body_entered(body: Node3D) -> void:
	print("BODY ENTERED ZONE: ", body)
	if body is GameBall:
		on_ball_entered(body as GameBall)


func _on_body_exited(body: Node3D) -> void:
	if body is GameBall:
		on_ball_exited(body as GameBall)
