class_name Bubble
extends Area2D

signal bubble_popped

@onready var animation_player: AnimationPlayer = $AnimationPlayer
@onready var sprite_2d: Sprite2D = $Sprite2D

func _on_area_entered(area: Area2D) -> void:
	if area.is_in_group(GameConstants.GROUP_PLAYER):
		animation_player.play("pop")
		await animation_player.animation_finished
		sprite_2d.frame = 1;


func pop_bubble() -> void:
	AudioManager.play_sfx(GameConstants.SFX_POP + str(randi_range(0, 8)))
	bubble_popped.emit()
	monitorable = false
	monitoring = false

func rotate_bubble() -> void:
	sprite_2d.rotate(randi_range(0,360))
