コード例 #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
            private bool TryComplete()
            {
                ResolveStatus loadStatus = store.resolveStatus;

                if (loadStatus.hasResolved)
                {
                    this.item = store.stateData;
                    CompleteRequest();
                    return(true);
                }

                if (!string.IsNullOrEmpty(loadStatus.loadError))
                {
                    CompleteWithError(loadStatus.loadError);
                    return(true);
                }

                return(false);
            }