using Godot; using System.Threading.Tasks; namespace Rokojori { [Tool][GlobalClass] public partial class RemoveNode : Action { [Export] public Node target; [Export] public bool queue = true; [Export] public bool disableAllNodes = 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; } if ( disableAllNodes ) { target.ForEach( n => NodeState.Disable( n ) ); NodeState.Disable( target ); } target.SelfDestroy( queue ); } } }