extends StaticBody2D

@export var break_groups: Array[String] = ["ROCK_BREAK"]

func _ready():
	$Area2D.body_entered.connect(_on_body_entered)

func _on_body_entered(body: Node):
	if _can_be_broken_by(body):
		break_self()

func _can_be_broken_by(node: Node) -> bool:
	for group in break_groups:
		if node.is_in_group(group):
			return true
	return false

func break_self():
	# 可以在这插入动画、粒子、音效
	queue_free()
