Implement IReadOnlyFileSystem on Map.

This commit is contained in:
Paul Chote
2016-02-15 02:59:18 +00:00
parent 6fde09c075
commit d1d3d72edb
2 changed files with 25 additions and 5 deletions

View File

@@ -107,7 +107,7 @@ namespace OpenRA
MissionSelector = 4 MissionSelector = 4
} }
public class Map public class Map : IReadOnlyFileSystem
{ {
public const int SupportedMapFormat = 8; public const int SupportedMapFormat = 8;
@@ -1174,5 +1174,26 @@ namespace OpenRA
{ {
return FindTilesInAnnulus(center, 0, maxRange, allowOutsideBounds); return FindTilesInAnnulus(center, 0, maxRange, allowOutsideBounds);
} }
// Placeholders for future implementation
Stream IReadOnlyFileSystem.Open(string filename)
{
return Game.ModData.DefaultFileSystem.Open(filename);
}
bool IReadOnlyFileSystem.TryGetPackageContaining(string path, out IReadOnlyPackage package, out string filename)
{
return Game.ModData.DefaultFileSystem.TryGetPackageContaining(path, out package, out filename);
}
bool IReadOnlyFileSystem.TryOpen(string filename, out Stream s)
{
return Game.ModData.DefaultFileSystem.TryOpen(filename, out s);
}
bool IReadOnlyFileSystem.Exists(string filename)
{
return Game.ModData.DefaultFileSystem.Exists(filename);
}
} }
} }

View File

@@ -164,12 +164,11 @@ namespace OpenRA
// Operate on a copy of the map to avoid gameplay state leaking into the cache // Operate on a copy of the map to avoid gameplay state leaking into the cache
var map = new Map(MapCache[uid].Path); var map = new Map(MapCache[uid].Path);
var fileSystem = DefaultFileSystem;
LoadTranslations(map); LoadTranslations(map);
// Reinitialize all our assets // Reinitialize all our assets
InitializeLoaders(fileSystem); InitializeLoaders(map);
ModFiles.LoadFromManifest(Manifest); ModFiles.LoadFromManifest(Manifest);
// Mount map package so custom assets can be used. // Mount map package so custom assets can be used.
@@ -183,9 +182,9 @@ namespace OpenRA
// Load music with map assets mounted // Load music with map assets mounted
using (new Support.PerfTimer("Map.Music")) using (new Support.PerfTimer("Map.Music"))
foreach (var entry in map.Rules.Music) foreach (var entry in map.Rules.Music)
entry.Value.Load(fileSystem); entry.Value.Load(map);
VoxelProvider.Initialize(VoxelLoader, fileSystem, Manifest.VoxelSequences, map.VoxelSequenceDefinitions); VoxelProvider.Initialize(VoxelLoader, map, Manifest.VoxelSequences, map.VoxelSequenceDefinitions);
VoxelLoader.Finish(); VoxelLoader.Finish();
return map; return map;