mirror of
https://github.com/marinho/godot-visual-effects.git
synced 2024-12-22 14:37:27 +08:00
Added namespace
This commit is contained in:
parent
cc32f177c9
commit
a38db5e6ed
@ -1,60 +1,62 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public partial class MultiParticles : Node3D
|
namespace GodotVisualEffects
|
||||||
{
|
{
|
||||||
[Export]
|
public partial class MultiParticles : Node3D
|
||||||
public bool Emitting = true;
|
{
|
||||||
|
[Export]
|
||||||
|
public bool Emitting = true;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public bool OneShot = false;
|
public bool OneShot = false;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public Godot.Collections.Array<GpuParticles3D> Particles;
|
public Godot.Collections.Array<GpuParticles3D> Particles;
|
||||||
|
|
||||||
double Lifetime = 0.0f;
|
double Lifetime = 0.0f;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
if (Emitting)
|
if (Emitting)
|
||||||
{
|
{
|
||||||
StartEmitters();
|
StartEmitters();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetLifetime()
|
void GetLifetime()
|
||||||
{
|
{
|
||||||
foreach (var particle in Particles)
|
foreach (var particle in Particles)
|
||||||
{
|
{
|
||||||
if (particle.Lifetime > Lifetime)
|
if (particle.Lifetime > Lifetime)
|
||||||
{
|
{
|
||||||
Lifetime = particle.Lifetime;
|
Lifetime = particle.Lifetime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void StartEmitters()
|
public async void StartEmitters()
|
||||||
{
|
{
|
||||||
GetLifetime();
|
GetLifetime();
|
||||||
|
|
||||||
foreach (var particle in Particles)
|
foreach (var particle in Particles)
|
||||||
particle.Emitting = true;
|
particle.Emitting = true;
|
||||||
|
|
||||||
await ToSignal(GetTree().CreateTimer(Lifetime), SceneTreeTimer.SignalName.Timeout);
|
await ToSignal(GetTree().CreateTimer(Lifetime), SceneTreeTimer.SignalName.Timeout);
|
||||||
DisposeOfEmitters();
|
DisposeOfEmitters();
|
||||||
|
|
||||||
if (!OneShot)
|
if (!OneShot)
|
||||||
{
|
{
|
||||||
StartEmitters();
|
StartEmitters();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisposeOfEmitters()
|
|
||||||
{
|
|
||||||
foreach (var particle in Particles)
|
|
||||||
{
|
|
||||||
particle.Emitting = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void DisposeOfEmitters()
|
||||||
|
{
|
||||||
|
foreach (var particle in Particles)
|
||||||
|
{
|
||||||
|
particle.Emitting = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user