コード例 #1
0
        public static ResolveAdvice AdviseOn(
            HasStateResolveStatus hasLoadStatus,
            float loadTimeoutSecs      = DEFAULT_LOAD_TIMEOUT_SECS,
            float retryMinIntervalSecs = DEFAULT_RETRY_MIN_INTERVAL_SECS,
            float ttlSecs = DEFAULT_TTL_SECS,
            bool debug    = false)
        {
            ResolveStatus loadStatus = hasLoadStatus.resolveStatus;

            if (loadStatus.hasResolved && (ttlSecs < 0f || loadStatus.updatedAt.AddSeconds(ttlSecs) > DateTimeOffset.Now))
            {
                                #if UNITY_EDITOR || DEBUG_UNSTRIP
                if (debug)
                {
                    Debug.Log("[" + Time.frameCount + "] skipping load attempt (already loaded and not expired)");
                }
                                #endif
                return(ResolveAdvice.CANCEL_LOADED_AND_UNEXPIRED);
            }

            if (loadStatus.isResolveInProgress && loadStatus.resolveStartedAt.AddSeconds(loadTimeoutSecs) > DateTimeOffset.Now)
            {
                                #if UNITY_EDITOR || DEBUG_UNSTRIP
                if (debug)
                {
                    Debug.Log("[" + Time.frameCount + "] skipping load attempt (load in progress started at " + loadStatus.resolveStartedAt + ")");
                }
                                #endif
                return(ResolveAdvice.CANCEL_IN_PROGRESS);
            }

            if (!string.IsNullOrEmpty(loadStatus.loadError) && loadStatus.updatedAt.AddSeconds(retryMinIntervalSecs) > DateTimeOffset.Now)
            {
                                #if UNITY_EDITOR || DEBUG_UNSTRIP
                if (debug)
                {
                    Debug.Log("[" + Time.frameCount + "] skipping load attempt (load in progress started at " + loadStatus.resolveStartedAt + ")");
                }
                                #endif
                return(ResolveAdvice.CANCEL_ERROR_COOL_DOWN);
            }

            return(ResolveAdvice.PROCEED);
        }
コード例 #2
0
        public static ResolveAdvice AdviseOnAndSendErrorIfCoolingDown(
            HasStateResolveStatus hasLoadStatus,
            string errorNotification,
            float loadTimeoutSecs      = DEFAULT_LOAD_TIMEOUT_SECS,
            float retryMinIntervalSecs = DEFAULT_RETRY_MIN_INTERVAL_SECS,
            float ttlSecs = DEFAULT_TTL_SECS,
            bool debug    = false)
        {
            var advice = AdviseOn(hasLoadStatus, loadTimeoutSecs, retryMinIntervalSecs, ttlSecs, debug);

            if (advice == ResolveAdvice.CANCEL_ERROR_COOL_DOWN)
            {
                NotificationBus.Send(errorNotification, new ResolveFailedDTO
                {
                    error = "load has failed for id and is in cooldown period"
                });
            }
            return(advice);
        }
コード例 #3
0
 public static bool HasNotResolved(this HasStateResolveStatus has)
 {
     return(has.resolveStatus.hasResolved == false);
 }
コード例 #4
0
        /// <summary>
        /// Convenience to test whether state has not resolved or a resolve is in progress.
        /// </summary>
        public static bool HasNotResolvedOrInProgress(this HasStateResolveStatus has)
        {
            var status = has.resolveStatus;

            return(status.hasResolved == false || status.isResolveInProgress);
        }