27 lines
509 B
C#
27 lines
509 B
C#
using Godot;
|
|
|
|
namespace Newlon.Particles;
|
|
|
|
public partial class StandardParticles : Node2D
|
|
{
|
|
private int counter = 0;
|
|
private int counterMax = 0;
|
|
public override void _Ready()
|
|
{
|
|
foreach (Node child in GetChildren())
|
|
{
|
|
if (child is GpuParticles2D emitter)
|
|
{
|
|
emitter.Emitting = true;
|
|
counterMax += 1;
|
|
emitter.Finished += MarkForDestruction;
|
|
}
|
|
}
|
|
}
|
|
public void MarkForDestruction()
|
|
{
|
|
if (Engine.IsEditorHint()) return;
|
|
if (++counter < counterMax) return;
|
|
QueueFree();
|
|
}
|
|
}
|