2025-07-20 11:22:12 +00:00
|
|
|
|
|
|
|
|
using Godot;
|
2025-10-24 11:38:51 +00:00
|
|
|
using System.Threading.Tasks;
|
2025-07-20 11:22:12 +00:00
|
|
|
|
|
|
|
|
namespace Rokojori
|
|
|
|
|
{
|
|
|
|
|
[Tool][GlobalClass]
|
|
|
|
|
public partial class RemoveNode : Action
|
|
|
|
|
{
|
|
|
|
|
[Export]
|
|
|
|
|
public Node target;
|
|
|
|
|
|
2025-07-22 14:08:22 +00:00
|
|
|
[Export]
|
|
|
|
|
public bool queue = true;
|
|
|
|
|
|
2025-10-24 11:38:51 +00:00
|
|
|
|
2025-07-20 11:22:12 +00:00
|
|
|
protected override void _OnTrigger()
|
|
|
|
|
{
|
2025-10-24 11:38:51 +00:00
|
|
|
if ( target == null || Engine.IsEditorHint() )
|
2025-07-20 11:22:12 +00:00
|
|
|
{
|
2025-07-22 14:08:22 +00:00
|
|
|
return;
|
2025-07-20 11:22:12 +00:00
|
|
|
}
|
2025-07-25 15:35:19 +00:00
|
|
|
|
2025-10-24 11:38:51 +00:00
|
|
|
if ( ! IsInstanceValid( this ) || ! IsInstanceValid( target ) )
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CallDeferred( "SelfDestroy" );
|
2025-07-22 14:08:22 +00:00
|
|
|
|
2025-07-20 11:22:12 +00:00
|
|
|
}
|
2025-10-24 11:38:51 +00:00
|
|
|
|
|
|
|
|
void SelfDestroy()
|
|
|
|
|
{
|
|
|
|
|
if ( ! IsInstanceValid( target ) )
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
target.SelfDestroy( queue );
|
|
|
|
|
}
|
2025-07-20 11:22:12 +00:00
|
|
|
}
|
|
|
|
|
}
|