private static IPromise WaitForRequest <T>(AsyncOperationHandle <T> request, string message)
    {
        var p = Promise.Create();

        CoroutineExtensions.WaitUntil(() => request.IsDone)
        .ThenDo(() => {
            if (!request.IsValid())     // request was auto-collected
            {
                Debug.Log(message);
                p.Resolve();
                return;
            }

            if (request.Status == AsyncOperationStatus.Succeeded)
            {
                Debug.Log(message);
                p.Resolve(request.Result);
            }
            else if (request.Status == AsyncOperationStatus.Failed)
            {
                Debug.LogException(request.OperationException);
                p.Reject(request.OperationException);
            }
        });

        return(p);
    }
Exemplo n.º 2
0
 private IEnumerable <IPromise> GetAnimateOffPromises(bool unscaled)
 {
     return(_animations.SelectEach(
                a => CoroutineExtensions.WaitForSeconds(_longestOff - a.OffDuration, unscaled)
                .Then(() => a.AnimateOff(unscaled))
                ));
 }
Exemplo n.º 3
0
        static bool Prefix(FejdStartup __instance)
        {
            CoroutineExtensions.DelayedMethod(2, () =>
            {
                Log.LogInfo("Hello from Patch.Prefix() , this method is fired after a 2 seconds delay !");
            });

            // if we return false in a Prefix
            // we skip all other potential hooks
            // from other mods hooking this same method !
            return(true);
        }
Exemplo n.º 4
0
        private static void OnFejdStartupAwakeMonoModHookShowcase(On.FejdStartup.orig_Awake orig, FejdStartup self)
        {
            CoroutineExtensions.DelayedMethod(2, () =>
            {
                Log.LogInfo("Hello from a monomod hook, this method is fired after a 2 seconds delay !");
            });

            // calling the original method
            orig(self);

            Log.LogInfo("Hello from a monomod hook, this method is fired after the original method is called : " + self.m_betaText);
        }
Exemplo n.º 5
0
        public IPromise AnimateOff(bool unscaled = false)
        {
            InitCheck();

            _currentState = EAnimateOnOffState.AnimatingOff;

            return(CoroutineExtensions.Tween(
                       Duration,
                       f => SetValue(1f - f),
                       Easing.Reverse(EaseType), unscaled)
                   .ThenWaitForSeconds(Delay, unscaled)
                   .ThenDo(() => _currentState = EAnimateOnOffState.Off));
        }
Exemplo n.º 6
0
        public IPromise AnimateOn(bool unscaled = false)
        {
            InitCheck();

            _currentState = EAnimateOnOffState.AnimatingOn;

            return(CoroutineExtensions.WaitForSeconds(Delay, unscaled)
                   .ThenTween(
                       Duration,
                       SetValue,
                       EaseType, unscaled)
                   .ThenDo(() => _currentState = EAnimateOnOffState.On));
        }
Exemplo n.º 7
0
        public virtual IPromise AnimateOn(bool unscaled = false)
        {
            if (CheckIfAnimating())
            {
                return(Promise.Resolved());
            }

            if (CurrentState == EAnimateOnOffState.On)
            {
                return(Promise.Resolved());
            }

            CurrentState = EAnimateOnOffState.AnimatingOn;

            gameObject.SetActive(true);

            return(CoroutineExtensions.WaitForSeconds(OnDelay, unscaled)
                   .ThenAll(() => GetAnimateOnPromises(unscaled))
                   .ThenDo(() => CurrentState = EAnimateOnOffState.On));
        }
Exemplo n.º 8
0
 public static IPromise WaitUntilState(this Animator animator, string state, int layer = 0)
 {
     return(CoroutineExtensions.WaitUntil(() => animator.GetCurrentAnimatorStateInfo(layer).IsName(state)));
 }
Exemplo n.º 9
0
 public static IPromise WaitForEndOfState(this Animator animator, int layer = 0)
 {
     return(CoroutineExtensions.WaitUntil(() =>
                                          animator.GetCurrentAnimatorStateInfo(layer).normalizedTime >= 0.999f));
 }
Exemplo n.º 10
0
 public static IPromise WaitUntilState(this Animator animator, int state, int layer = 0)
 {
     return(CoroutineExtensions.WaitUntil(() => animator.GetCurrentAnimatorStateInfo(layer).shortNameHash == state));
 }