extends Node2D

var detecting = true
@export var once = false

func _on_anim_trigger_body_shape_entered(_body_rid, _body, _body_shape_index, _local_shape_index):
	if detecting:
		detecting = false
		
		var tween = get_tree().create_tween()
		tween.set_ease(Tween.EASE_IN)
		tween.set_trans(Tween.TRANS_CUBIC)
		tween.set_parallel(true)
		
		tween.tween_property($SmasherBody, "position", Vector2(0, -66), 0.3)
		tween.tween_property($SmasherBody2, "position", Vector2(0, 66), 0.3)
		
		await tween.finished
		
		if not once:
			tween = get_tree().create_tween()
			tween.set_ease(Tween.EASE_IN)
			tween.set_trans(Tween.TRANS_SINE)
			tween.set_parallel(true)
			
			tween.tween_property($SmasherBody, "position", Vector2(0, -100), 2).set_delay(1)
			tween.tween_property($SmasherBody2, "position", Vector2(0, 100), 2).set_delay(1)
			
			await tween.finished
			
			detecting = true
		else:
			$AnimTrigger.queue_free()
	
