107 lines
3.7 KiB
C#
107 lines
3.7 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
namespace YooAsset
|
|
{
|
|
internal class EditorSimulateModeImpl : IPlayModeServices, IBundleServices
|
|
{
|
|
private PackageManifest _activeManifest;
|
|
private bool _locationToLower;
|
|
|
|
/// <summary>
|
|
/// 异步初始化
|
|
/// </summary>
|
|
public InitializationOperation InitializeAsync(bool locationToLower, string simulateManifestFilePath)
|
|
{
|
|
_locationToLower = locationToLower;
|
|
var operation = new EditorSimulateModeInitializationOperation(this, simulateManifestFilePath);
|
|
OperationSystem.StartOperation(operation);
|
|
return operation;
|
|
}
|
|
|
|
#region IPlayModeServices接口
|
|
public PackageManifest ActiveManifest
|
|
{
|
|
set
|
|
{
|
|
_activeManifest = value;
|
|
_activeManifest.InitAssetPathMapping(_locationToLower);
|
|
}
|
|
get
|
|
{
|
|
return _activeManifest;
|
|
}
|
|
}
|
|
public void FlushManifestVersionFile()
|
|
{
|
|
}
|
|
|
|
UpdatePackageVersionOperation IPlayModeServices.UpdatePackageVersionAsync(bool appendTimeTicks, int timeout)
|
|
{
|
|
var operation = new EditorPlayModeUpdatePackageVersionOperation();
|
|
OperationSystem.StartOperation(operation);
|
|
return operation;
|
|
}
|
|
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
|
{
|
|
var operation = new EditorPlayModeUpdatePackageManifestOperation();
|
|
OperationSystem.StartOperation(operation);
|
|
return operation;
|
|
}
|
|
PreDownloadContentOperation IPlayModeServices.PreDownloadContentAsync(string packageVersion, int timeout)
|
|
{
|
|
var operation = new EditorPlayModePreDownloadContentOperation();
|
|
OperationSystem.StartOperation(operation);
|
|
return operation;
|
|
}
|
|
|
|
ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
|
{
|
|
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
|
}
|
|
ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
|
{
|
|
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
|
}
|
|
ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
|
{
|
|
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
|
}
|
|
|
|
ResourceUnpackerOperation IPlayModeServices.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
|
{
|
|
return ResourceUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
|
|
}
|
|
ResourceUnpackerOperation IPlayModeServices.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
|
|
{
|
|
return ResourceUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
|
|
}
|
|
#endregion
|
|
|
|
#region IBundleServices接口
|
|
BundleInfo IBundleServices.GetBundleInfo(AssetInfo assetInfo)
|
|
{
|
|
if (assetInfo.IsInvalid)
|
|
throw new Exception("Should never get here !");
|
|
|
|
// 注意:如果清单里未找到资源包会抛出异常!
|
|
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
|
BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromEditor, assetInfo.AssetPath);
|
|
return bundleInfo;
|
|
}
|
|
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
string IBundleServices.GetBundleName(int bundleID)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
bool IBundleServices.IsServicesValid()
|
|
{
|
|
return _activeManifest != null;
|
|
}
|
|
#endregion
|
|
}
|
|
} |