@tool
extends Node2D

@export var count = 1: 
    set(value):
        count = value
        redraw()
@export var separation = 200:
    set(value):
        separation = value
        redraw()
@export var particles: PackedScene:
    set(value):
        particles = value
        redraw()

func redraw():
    for n in get_children():
        remove_child(n)
    if particles != null:
        var start_pos = 0.0
        if count % 2 == 1:
            start_pos = -floor(count / 2.0) * separation  
        else:
            start_pos = (-(count / 2.0) + 0.5) * separation
        for i in range(0, count):
            var child = particles.instantiate()
            child.set_position(Vector2(start_pos + i * separation, 0))
            add_child(child)
