public DefaultFileSaveInfo(string filePath, IWorld world, IWorld readOnlyWorld, IAssetService assetService) { FileSystem = new ActualFileSystem(); FilePath = filePath; World = world; ReadOnlyWorld = readOnlyWorld; this.assetService = assetService; }
public DefaultFileLoadInfo(string filePath, IAssetService assetService, IWorldTreeService worldTreeService, LoadWorldPreference worldPreference) { FileSystem = new ActualFileSystem(); FilePath = filePath; this.assetService = assetService; this.worldTreeService = worldTreeService; this.worldPreference = worldPreference; }
private IDictionary <string, IAsset> LoadAssets(ZipArchive archive, SaveLoadMetadata metadata, IReadOnlyDictionary <string, Type> typeAliases, IFileLoadInfo loadInfo) { AssetSaveLoadInfo[] assetInfos; var assetInfoEntry = archive.GetEntry("assetInfos.json") ?? throw new Exception("assetInfo.json not found."); using (var reader = trwFactory.JsonReader(assetInfoEntry.Open())) using (var convertedReader = converterContainer.ConvertAssetInfoReader(reader, metadata.Version, converterContainer.CurrentVersion)) using (var context = saveLoadFactory.AssetsInfoReadContext(convertedReader, typeAliases)) assetInfos = context.Read <AssetSaveLoadInfo[]>(); var assets = new Dictionary <string, IAsset>(); var zipFileSystem = new ZipFileSystem(archive); var actualFileSystem = new ActualFileSystem(); foreach (var assetInfo in assetInfos) { var assetLoadInfo = new AssetLoadInfo { AssetName = assetInfo.AssetName, StorageType = assetInfo.StorageType, ReferencePath = assetInfo.ReferencePath }; switch (assetInfo.StorageType) { case AssetStorageType.CopyLocal: assetLoadInfo.FileSystem = zipFileSystem; assetLoadInfo.LoadPath = assetInfo.LocalCopyPath; break; case AssetStorageType.ReferenceOriginal: assetLoadInfo.FileSystem = actualFileSystem; assetLoadInfo.LoadPath = assetInfo.ReferencePath; break; default: throw new ArgumentOutOfRangeException(); } var asset = loadInfo.OnFoundAsset(assetLoadInfo); assets.Add(asset.Name, asset); } return(assets); }