public void Initialize(DelegateAllRequiredResourceReadyCallback readyCallback) { DisneyMobile.CoreUnitySystems.Logger.LogInfo(this, "Resource manager initialized"); RequiredReadyCallback = readyCallback; LoadResourceCatalog(); if (mEnableAMPS) { DownloadAssetCatalogFromServer(); return; } RequiredReadyCallback(success: true, "NOAMPS"); RequiredReadyCallback = null; }
public void OnDownloadCompleted(bool successful, AppResource ar, string msg) { if (ar.isRequired) { if (!successful) { if (RequiredReadyCallback != null) { RequiredReadyCallback(successful, msg); RequiredReadyCallback = null; } } else if (AllRequiredDownloaded() && RequiredReadyCallback != null) { RequiredReadyCallback(successful, msg); RequiredReadyCallback = null; } } DownloadNextInQueue(); }
private void OnCatalogDownloaded(Dictionary <string, AppResource> newcatalog) { DisneyMobile.CoreUnitySystems.Logger.LogInfo(this, "Catalog loaded from server"); bool flag = false; if (newcatalog != null) { Dictionary <string, AppResource> dictionary = new Dictionary <string, AppResource>(); foreach (KeyValuePair <string, AppResource> item in ResourceCatalog) { AppResource value = item.Value; if (newcatalog.ContainsKey(value.assetName)) { dictionary.Add(value.assetName, value); flag |= value.UpdateWith(newcatalog[value.assetName]); if (value.HasNewer() && value.isRequired) { DisneyMobile.CoreUnitySystems.Logger.LogInfo(this, "Auto download needed for " + value.assetName); value.inDownloadQueue = true; } newcatalog.Remove(value.assetName); } else if (value.createLocalCache) { dictionary.Add(value.assetName, value); if (value.Expired()) { DisneyMobile.CoreUnitySystems.Logger.LogInfo(this, "Expired resource " + value.assetName); value.inDownloadQueue = true; } } else { flag = true; if (value.IsDownloading()) { value.StopDownload(); } value.ReleaseResource(); DisneyMobile.CoreUnitySystems.Logger.LogInfo(this, "Resource removed from catalog " + value.Serialize()); } } foreach (KeyValuePair <string, AppResource> item2 in newcatalog) { AppResource value = item2.Value; flag = true; if (value.isRequired) { value.inDownloadQueue = true; } dictionary.Add(value.assetName, value); DisneyMobile.CoreUnitySystems.Logger.LogInfo(this, "New Resource added to catalog " + item2.Value.Serialize()); } if (ResourceManager.CatalogUpdatedEvent != null) { ResourceManager.CatalogUpdatedEvent(flag); } ResourceCatalog = dictionary; } else { DisneyMobile.CoreUnitySystems.Logger.LogWarning(this, "Catalog download failed"); } DownloadNextInQueue(); if (AllRequiredDownloaded() && RequiredReadyCallback != null) { RequiredReadyCallback(success: true, "NoNeed"); RequiredReadyCallback = null; } if (flag) { SaveResourceCatalog(); } else { DisneyMobile.CoreUnitySystems.Logger.LogInfo(this, "No catalog change"); } }