Beispiel #1
0
    private void DoInterruptionCleanUp()
    {
        bool flag = this.IsPreviousSceneActive();

        object[] args = new object[] { this.m_phase, flag };
        Log.LoadingScreen.Print("LoadingScreen.DoInterruptionCleanUp() - m_phase={0} previousSceneActive={1}", args);
        if (this.m_phase == Phase.WAITING_FOR_BLOCKERS)
        {
            base.StopCoroutine("HackWaitThenStartTransitionEffects");
        }
        if (this.IsFading())
        {
            this.StopFading();
            if (this.IsFadingIn())
            {
                this.m_prevTransitionParams = null;
            }
        }
        if (flag)
        {
            long assetLoadNextStartTimestamp = this.m_assetLoadNextStartTimestamp;
            long endTimestamp = TimeUtils.BinaryStamp();
            this.ClearAssets(assetLoadNextStartTimestamp, endTimestamp);
            this.m_transitionUnfriendlyData.Clear();
            this.m_transitionParams = new TransitionParams();
            this.m_phase            = Phase.WAITING_FOR_SCENE_LOAD;
        }
    }
Beispiel #2
0
 public static void ForceClearAllCaches()
 {
     foreach (KeyValuePair <string, AssetCache> current in AssetCache.cacheTable)
     {
         current.Value.ForceClear();
     }
     AssetCache.s_cacheClearTime = TimeUtils.BinaryStamp();
 }
Beispiel #3
0
 public static void ClearAllCaches(bool clearPersisten = false, bool clearLoading = true)
 {
     foreach (KeyValuePair <string, AssetCache> current in AssetCache.cacheTable)
     {
         current.Value.Clear(clearPersisten, clearLoading);
     }
     AssetCache.s_cacheClearTime = TimeUtils.BinaryStamp();
 }
Beispiel #4
0
 public static void ClearAllCaches(bool clearPersistent = false, bool clearLoading = true)
 {
     foreach (KeyValuePair <AssetFamily, AssetCache> pair in s_cacheTable)
     {
         pair.Value.Clear(clearPersistent, clearLoading);
     }
     s_cacheClearTime = TimeUtils.BinaryStamp();
 }
Beispiel #5
0
 public static void ForceClearAllCaches()
 {
     foreach (KeyValuePair <AssetFamily, AssetCache> pair in s_cacheTable)
     {
         pair.Value.ForceClear();
     }
     s_cacheClearTime = TimeUtils.BinaryStamp();
 }
 public void FreeMemory()
 {
     if (TimeUtils.BinaryStamp() - this.m_lastFreeMemoryTime > 200L)
     {
         Resources.UnloadUnusedAssets();
         GC.Collect();
         this.m_lastFreeMemoryTime = TimeUtils.BinaryStamp();
     }
 }
    private UnityEngine.Object LoadBundle(string family, string bundlePathName, string assetName, bool persistent, AssetLoader.ObjectCallback callback, AssetLoader.OnDownloading onDownloading, object callbackData)
    {
        if (string.IsNullOrEmpty(assetName))
        {
            return(null);
        }
        long  num   = TimeUtils.BinaryStamp();
        Asset asset = Asset.Create(assetName, family, persistent, false, false);

        AssetCache.CachedAsset        cachedAsset = new AssetCache.CachedAsset();
        AssetCache.ObjectCacheRequest objectCacheRequest;
        if (!AssetCache.HasRequest(asset))
        {
            objectCacheRequest = new AssetCache.ObjectCacheRequest();
            AssetCache.AddRequest(asset, objectCacheRequest);
        }
        else
        {
            objectCacheRequest = AssetCache.GetRequest <AssetCache.ObjectCacheRequest>(asset);
        }
        objectCacheRequest.AddRequester(callback, onDownloading, callbackData);
        AssetCache.StartLoading(asset.Family.ToString());
        if (AssetCache.HasItem(asset))
        {
            cachedAsset = AssetCache.Find(asset);
            cachedAsset.LastRequestTimestamp = num;
            asset = cachedAsset.GetAsset();
        }
        else if (this.m_assetBundleDict.ContainsKey(asset.Family) && this.m_assetBundleDict[asset.Family] != null)
        {
            if (!this.m_assetBundleDict[asset.Family].Contains(asset.Name))
            {
                return(null);
            }
            UnityEngine.Object assetObject = this.m_assetBundleDict[family].Load(assetName, AssetBundleInfo.FamilyInfo[family].TypeOf);
            cachedAsset.SetAsset(asset);
            cachedAsset.SetAssetObject(assetObject);
            cachedAsset.CreatedTimestamp     = num;
            cachedAsset.LastRequestTimestamp = num;
            AssetCache.Add(asset, cachedAsset);
        }
        else if (AssetCache.CanLoadBundle(asset.Family))
        {
            this.LoadBundleFromDisk(asset, objectCacheRequest, cachedAsset);
        }
        if (cachedAsset.GetAssetObject() != null)
        {
            objectCacheRequest.OnProgressUpdate(assetName, 1f);
            objectCacheRequest.OnLoadSucceed();
            objectCacheRequest.OnLoadComplete(assetName, cachedAsset.GetAssetObject());
            AssetCache.RemoveRequest(asset);
            AssetCache.StopLoading(assetName);
        }
        return(cachedAsset.GetAssetObject());
    }
Beispiel #8
0
 public CardDef GetCardDef(string cardId)
 {
     for (int i = 0; i < this.m_cardCache.Count; i++)
     {
         CardCacheItem item = this.m_cardCache[i];
         if (item.m_cardId.Equals(cardId))
         {
             item.m_lastRequestTimestamp = TimeUtils.BinaryStamp();
             this.m_cardCache.RemoveAt(i);
             this.m_cardCache.Add(item);
             return(item.m_cardDef);
         }
     }
     return(null);
 }
Beispiel #9
0
 private void AddCard(string cardID, CardDef card)
 {
     if (this.GetCardDef(cardID) != null)
     {
         Log.Rachelle.Print(string.Format("CollectionCardCache.AddCard(): somehow the card def for {0} was already in the cache...", cardID), new object[0]);
     }
     else
     {
         CardCacheItem item = new CardCacheItem {
             m_cardId  = cardID,
             m_cardDef = card
         };
         item.m_lastRequestTimestamp = TimeUtils.BinaryStamp();
         this.m_cardCache.Add(item);
         this.CleanCache();
     }
 }
    private void LoadBundleFromDisk(Asset asset, AssetCache.ObjectCacheRequest request, AssetCache.CachedAsset cache)
    {
        if (asset == null || request == null || cache == null || this.m_assetBundleDict == null)
        {
            UnityEngine.Debug.LogError("LoadBundleFromDisk some null!");
            return;
        }
        string family = asset.Family;
        string path   = Application.persistentDataPath + "/" + AssetBundleInfo.FamilyInfo[family].BundleName;

        if (!File.Exists(path))
        {
            return;
        }
        AssetBundle value = AssetBundle.CreateFromFile(path);

        if (this.m_assetBundleDict.ContainsKey(family))
        {
            this.m_assetBundleDict[family] = value;
        }
        else
        {
            this.m_assetBundleDict.Add(family, value);
        }
        long num = TimeUtils.BinaryStamp();

        string[] requestDictKeys = AssetCache.GetRequestDictKeys(family);
        for (int i = 0; i < requestDictKeys.Length; i++)
        {
            Asset asset2 = Asset.Create(requestDictKeys[i], family, asset.Persistent, false, false);
            UnityEngine.Object assetObject = this.m_assetBundleDict[family].Load(asset2.Name, AssetBundleInfo.FamilyInfo[family].TypeOf);
            cache.SetAsset(asset2);
            cache.SetAssetObject(assetObject);
            cache.CreatedTimestamp     = num;
            cache.LastRequestTimestamp = num;
            AssetCache.Add(asset2, cache);
            if (cache.GetAssetObject() == null)
            {
                request.OnLoadFailed(asset2.Name);
                AssetCache.RemoveRequest(asset2);
                AssetCache.StopLoading(family.ToString());
            }
        }
        request.OnProgressUpdate(family.ToString(), 1f);
    }
Beispiel #11
0
    public static void ClearAllCachesSince(long sinceTimestamp)
    {
        long endTimestamp = TimeUtils.BinaryStamp();

        AssetCache.ClearAllCachesBetween(sinceTimestamp, endTimestamp);
    }
Beispiel #12
0
 static AssetCache()
 {
     AssetCache.cacheTable       = new Dictionary <string, AssetCache>();
     AssetCache.m_assetLoading   = new Dictionary <string, int>();
     AssetCache.s_cacheClearTime = TimeUtils.BinaryStamp();
 }
 public void Init(bool islocal, string url)
 {
     this.m_bindataPath        = url;
     this.m_bundlePath         = url + "Android/";
     this.m_lastFreeMemoryTime = TimeUtils.BinaryStamp();
 }