diff --git a/GDTask/src/Triggers/AsyncPredeleteTrigger.cs b/GDTask/src/Triggers/AsyncPredeleteTrigger.cs index 1a52d91..ef220b4 100644 --- a/GDTask/src/Triggers/AsyncPredeleteTrigger.cs +++ b/GDTask/src/Triggers/AsyncPredeleteTrigger.cs @@ -61,11 +61,6 @@ public CancellationToken CancellationToken cancellationTokenSource = new CancellationTokenSource(); } - if (!enterTreeCalled) - { - GDTaskPlayerLoopRunner.AddAction(PlayerLoopTiming.Process, new AwakeMonitor(this)); - } - return cancellationTokenSource.Token; } } @@ -104,27 +99,6 @@ public GDTask OnPredeleteAsync() return tcs.Task; } - - private class AwakeMonitor : IPlayerLoopItem - { - private readonly AsyncPredeleteTrigger trigger; - - public AwakeMonitor(AsyncPredeleteTrigger trigger) - { - this.trigger = trigger; - } - - public bool MoveNext() - { - if (trigger.predeleteCalled) return false; - if (!IsInstanceValid(trigger)) - { - trigger.OnPredelete(); - return false; - } - return true; - } - } } } diff --git a/GDTask/src/Triggers/AsyncTriggerBase.cs b/GDTask/src/Triggers/AsyncTriggerBase.cs index a3043af..e6f5704 100644 --- a/GDTask/src/Triggers/AsyncTriggerBase.cs +++ b/GDTask/src/Triggers/AsyncTriggerBase.cs @@ -9,7 +9,7 @@ internal abstract partial class AsyncTriggerBase : Node private TriggerEvent triggerEvent; internal protected bool calledEnterTree; - internal protected bool calledDestroy; + internal protected bool calledPredelete; public override void _EnterTree() { @@ -19,34 +19,24 @@ public override void _EnterTree() public override void _Notification(int what) { if (what == NotificationPredelete) - OnDestroy(); + OnPredelete(); } - private void OnDestroy() + private void OnPredelete() { - if (calledDestroy) return; - calledDestroy = true; + if (calledPredelete) return; + calledPredelete = true; triggerEvent.SetCompleted(); } internal void AddHandler(ITriggerHandler handler) { - if (!calledEnterTree) - { - GDTaskPlayerLoopRunner.AddAction(PlayerLoopTiming.Process, new EnterTreeMonitor(this)); - } - triggerEvent.Add(handler); } internal void RemoveHandler(ITriggerHandler handler) { - if (!calledEnterTree) - { - GDTaskPlayerLoopRunner.AddAction(PlayerLoopTiming.Process, new EnterTreeMonitor(this)); - } - triggerEvent.Remove(handler); } @@ -54,27 +44,6 @@ protected void RaiseEvent(T value) { triggerEvent.SetResult(value); } - - private class EnterTreeMonitor : IPlayerLoopItem - { - private readonly AsyncTriggerBase trigger; - - public EnterTreeMonitor(AsyncTriggerBase trigger) - { - this.trigger = trigger; - } - - public bool MoveNext() - { - if (trigger.calledEnterTree) return false; - if (!IsInstanceValid(trigger)) - { - trigger.OnDestroy(); - return false; - } - return true; - } - } } internal interface IAsyncOneShotTrigger