rj-action-library/Runtime/Actions/RemoveNode.cs

43 lines
699 B
C#

using Godot;
using System.Threading.Tasks;
namespace Rokojori
{
[Tool][GlobalClass]
public partial class RemoveNode : Action
{
[Export]
public Node target;
[Export]
public bool queue = true;
protected override void _OnTrigger()
{
if ( target == null || Engine.IsEditorHint() )
{
return;
}
if ( ! IsInstanceValid( this ) || ! IsInstanceValid( target ) )
{
return;
}
CallDeferred( "SelfDestroy" );
}
void SelfDestroy()
{
if ( ! IsInstanceValid( target ) )
{
return;
}
target.SelfDestroy( queue );
}
}
}