public bool Trigger(object sender, object arg, BlockingTriggerYieldInstruction instruction)
        {
            if (!_useAsBlockingYieldInstruction || instruction == null)
            {
                return(this.Trigger(sender, arg));
            }
            if (!this.CanTrigger)
            {
                return(false);
            }

            var anim = _targetAnimator.GetTarget <ISPAnimationSource>(arg);

            if (anim == null)
            {
                return(false);
            }

            var id = _clipIDs.PickRandom();

            _currentAnimState = anim.GetAnim(id);
            if (_currentAnimState == null)
            {
                //this.Invoke(() => { this.OnAnimCompleteCallback(null); }, 0f);
                if (_triggerCompleteIfNoAnim)
                {
                    this.Invoke(() => { _onAnimComplete.ActivateTrigger(this, arg); }, 0f);
                }
                return(false);
            }

            instruction.BeginBlock();
            _currentAnimState.TimeSupplier = _timeSupplier.TimeSupplier;
            _currentAnimState.Play(_speed, _startTime, QueueMode.PlayNow, _playMode);
            _currentAnimState.Schedule((s) =>
            {
                _currentAnimState = null;
                if (_daisyChainBlockingYieldInstruction)
                {
                    _onAnimComplete.DaisyChainTriggerYielding(this, arg, instruction);
                }
                else
                {
                    _onAnimComplete.ActivateTrigger(this, arg);
                }
                instruction.EndBlock();
            });

            return(true);
        }
        public bool Trigger(object sender, object arg, BlockingTriggerYieldInstruction instruction)
        {
            if (!_useAsBlockingYieldInstruction || instruction == null)
            {
                return(this.Trigger(sender, arg));
            }
            if (!this.CanTrigger)
            {
                return(false);
            }

            var targ = this.ResolveTargetAnimator(arg);

            if (targ == null)
            {
                return(false);
            }

            var anim = this.TryPlay(targ);

            if (anim == null)
            {
                if (_triggerCompleteIfNoAnim)
                {
                    this.Invoke(() => { _onAnimComplete.ActivateTrigger(this, arg); }, 0f);
                }
                return(false);
            }

            instruction.BeginBlock();
            AnimUtil.TrySchedule(anim, (a) =>
            {
                if (_daisyChainBlockingYieldInstruction)
                {
                    _onAnimComplete.DaisyChainTriggerYielding(this, arg, instruction);
                }
                else
                {
                    _onAnimComplete.ActivateTrigger(this, arg);
                }
                instruction.EndBlock();
            });

            return(false);
        }
        public bool Trigger(object sender, object arg, BlockingTriggerYieldInstruction instruction)
        {
            if (!_useAsBlockingYieldInstruction || instruction == null)
            {
                return(this.Trigger(sender, arg));
            }
            if (!this.CanTrigger)
            {
                return(false);
            }

            var targ = this.ResolveTargetAnimator(arg);

            if (targ == null)
            {
                return(false);
            }

            var anim = this.TryPlay(targ);

            if (anim == null)
            {
                if (_triggerCompleteIfNoAnim)
                {
                    this.Invoke(() => { _onAnimComplete.ActivateTrigger(this, arg); }, 0.01f);
                }
                return(false);
            }

            instruction.BeginBlock();
            if (anim is ISPAnim)
            {
                (anim as ISPAnim).Schedule((s) =>
                {
                    if (_daisyChainBlockingYieldInstruction)
                    {
                        _onAnimComplete.DaisyChainTriggerYielding(this, arg, instruction);
                    }
                    else
                    {
                        _onAnimComplete.ActivateTrigger(this, arg);
                    }
                    instruction.EndBlock();
                });
            }
            else if (anim is AnimationState)
            {
                GameLoopEntry.Hook.StartCoroutine((anim as AnimationState).ScheduleLegacy(() =>
                {
                    if (_daisyChainBlockingYieldInstruction)
                    {
                        _onAnimComplete.DaisyChainTriggerYielding(this, arg, instruction);
                    }
                    else
                    {
                        _onAnimComplete.ActivateTrigger(this, arg);
                    }
                    instruction.EndBlock();
                }));
            }

            return(false);
        }