rokojori_action_library/Runtime/VFX/FlareVFX/FlareVFX.cs

79 lines
1.4 KiB
C#
Raw Normal View History

2026-01-27 06:57:54 +00:00
using Godot;
using System.Collections.Generic;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class FlareVFX:Node3D
{
[Export]
public FlareVFXPreset preset;
[Export]
public Node3D container;
[Export]
public bool debug = false;
public Node3D GetContainer()
{
return container == null ? this : container;
}
List<FlareVFXLayer> _layers = new List<FlareVFXLayer>();
[ExportToolButton( "Update Flare" )]
public Callable updateFlareButton => Callable.From( ()=> UpdateFlare() );
void UpdateFlare()
{
if ( debug )
{
numLayers = _layers.Count;
}
_layers.ForEach( l => l.Update( this ) );
}
[ExportToolButton( "Create Flare" )]
public Callable createFlareButton => Callable.From( ()=> CreateFlare() );
void CreateFlare()
{
GetContainer().DestroyChildren();
_layers = [];
preset.flareLayers.ForEach(
( l )=>
{
if ( l == null )
{
return;
}
_layers.Add( l.Create( this ) );
}
);
UpdateFlare();
}
#if TOOLS
[Export]
public bool editMode = false;
[Export]
public int numLayers = 0;
public override void _Process( double delta )
{
// this.LogInfo( "Hello" );
if ( editMode )
{
UpdateFlare();
}
}
#endif
}
}