Пример #1
0
        public override IAssetManager Build(RuntimePlatform platform, AssetBundleConfig config)
        {
            var encode = BuildMapDataTable.Encode;

            var loadDatabase    = new MultiLoadDatabase();
            var saveBuilder     = m_saveBuilder.Build();
            var storageDatabase = new StorageDatabase <StorageFileTable>(builder: saveBuilder);

            storageDatabase.OnSaveVersion = d => true;

            var storageProvider  = m_storageProvider.Build(platform, config, loadDatabase, storageDatabase);
            var downloadProvider = m_downloadProvider.Build(platform, config, loadDatabase, storageDatabase);
            var assetProvider    = m_assetProvider.Build(platform, config, loadDatabase);
            var unloadProvider   = m_unloadProvider.Build(platform, config, loadDatabase);

            var errorHandler = new ErrorHandler();

            // --- コールバック

            //	初期化
            return(new AssetManager(
                       config: config,
                       loadDatabase: loadDatabase,
                       storageDatabase: storageDatabase,
                       downloadProvider: downloadProvider,
                       storageProvider: storageProvider,
                       assetProvider: assetProvider,
                       unloadProvider: unloadProvider,
                       errorHandler: errorHandler
                       ));
        }
Пример #2
0
        /// <summary>
        /// ローカルファイルを開く
        /// </summary>
        protected virtual ILoadProcess CreateLocalFileOpenJob(IRuntimeBundleData data)
        {
            if (JobEngine.HasRequest(data.Identifier))
            {
                //	リクエスト済みのモノは完了まで待つ
                return(WaitLoadProcess.Wait(data, (d) => d.IsOnMemory));
            }
            var location = StorageDatabase.GetSaveLocation(data);

            if (!File.Exists(location.FullPath))
            {
                OnError(ChipstarResult.ClientError($"Open File is Not Found. == {data.Identifier} for {location.ToString()}"));
                return(SkipLoadProcess.Create(data));
            }
            var job = JobCreator.OpenLocalBundle(JobEngine, data.Identifier, location, data.Hash, data.Crc);

            return(new LoadProcess <AssetBundle>(
                       AddJob(job),
                       onCompleted: (content) =>
            {
                data.OnMemory(content);
            },
                       onError: code => OnError(code)
                       ));
        }
Пример #3
0
        /// <summary>
        /// 最新でないファイルの一覧を取得
        /// </summary>
        public IReadOnlyList <IRuntimeBundleData> GetNeedUpdateList()
        {
            //	キャッシュされてない情報一覧
            var notCachedList
                = LoadDatabase
                  .BundleList
                  .Where(c => !StorageDatabase.HasStorage(c))
                  .ToArray();

            //	保存ファイル情報からバンドルデータに変換して取得
            return(notCachedList);
        }
Пример #4
0
        /// <summary>
        /// キャッシュクリア
        /// </summary>
        public IEnumerator AllClear()
        {
            //	とりあえず個別削除
            var list = StorageDatabase.GetCachedList();

            foreach (var bundle in list)
            {
                StorageDatabase.Delete(bundle);
                yield return(null);
            }
            //	残りがあるかもしれないのでクリア
            StorageDatabase.CleanUp();
        }
Пример #5
0
        /// <summary>
        /// ダウンロード
        /// </summary>
        protected virtual ILoadProcess CreateDowloadJob(IAccessLocation location, IRuntimeBundleData data)
        {
            if (JobEngine.HasRequest(data.Identifier))
            {
                //	リクエスト済みのモノは無視
                return(SkipLoadProcess.Create(location));
            }
            var localPath = StorageDatabase.GetSaveLocation(data);
            var job       = JobCreator.FileDL(JobEngine, data.Identifier, location, localPath, data.FileSize);

            return(new LoadProcess <FileInfo>(
                       AddJob(job),
                       onCompleted: (info) =>
            {
                //	バージョンを保存
                StorageDatabase.Save(data);
            },
                       onError: code => OnError(code)
                       ));
        }
Пример #6
0
        /// <summary>
        /// ダウンロード処理
        /// </summary>
        public ILoadProcess CacheOrDownload(string identifier)
        {
            var data = LoadDatabase.GetBundleData(identifier);

            if (data == null)
            {
                OnError(ChipstarResult.ClientError($"Target Bundle Data is Not Found. == {identifier}"));
                return(SkipLoadProcess.Create(identifier));
            }
            if (data.IsOnMemory)
            {
                //	ロード済みは無視
                ChipstarLog.Log_Skip_OnMemory(data.Identifier);
                return(SkipLoadProcess.Create(data.Identifier));
            }
            if (StorageDatabase.HasStorage(data))
            {
                //	キャッシュ済は無視
                ChipstarLog.Log_Cached(data);
                return(SkipLoadProcess.Create(data.Identifier));
            }
            return(CreateDowloadJob(data.Url, data));
        }
Пример #7
0
        public override string ToString()
        {
            var builder = new StringBuilder();
            var list    = StorageDatabase.GetCachedList();

            foreach (var bundle in list)
            {
                var storage   = StorageDatabase.GetSaveLocation(bundle);
                var localHash = bundle.Hash;
                var localCrc  = bundle.Crc;

                builder
                .AppendLine()
                .AppendLine(bundle.Path)
                .AppendLine("[Local]")
                .AppendLine(storage.FullPath)
                .AppendLine(localHash.ToString())
                .AppendLine(localCrc.ToString())
                .AppendLine()
                .AppendLine("=================================================");
            }
            return(builder.ToString());
        }