Remove lazy loading of binary map data.

This commit is contained in:
Paul Chote
2016-03-12 21:23:32 +00:00
parent 51bfe4accc
commit 65df25b1a4
22 changed files with 141 additions and 183 deletions

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
}
// Take all templates to overlay from the map
foreach (var cell in w.Map.AllCells.Where(cell => bridgeTypes.ContainsKey(w.Map.MapTiles.Value[cell].Type)))
foreach (var cell in w.Map.AllCells.Where(cell => bridgeTypes.ContainsKey(w.Map.Tiles[cell].Type)))
ConvertBridgeToActor(w, cell);
// Link adjacent (long)-bridges so that artwork is updated correctly
@@ -65,8 +65,8 @@ namespace OpenRA.Mods.Common.Traits
return;
// Correlate the tile "image" aka subtile with its position to find the template origin
var tile = w.Map.MapTiles.Value[cell].Type;
var index = w.Map.MapTiles.Value[cell].Index;
var tile = w.Map.Tiles[cell].Type;
var index = w.Map.Tiles[cell].Index;
var template = w.Map.Rules.TileSet.Templates[tile];
var ni = cell.X - index % template.Size.X;
var nj = cell.Y - index / template.Size.X;
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Traits
}).Trait<Bridge>();
var subTiles = new Dictionary<CPos, byte>();
var mapTiles = w.Map.MapTiles.Value;
var mapTiles = w.Map.Tiles;
// For each subtile in the template
for (byte ind = 0; ind < template.Size.X * template.Size.Y; ind++)

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
Resources = self.TraitsImplementing<ResourceType>()
.ToDictionary(r => r.Info.ResourceType, r => r);
Map.MapResources.Value.CellEntryChanged += UpdateCell;
Map.Resources.CellEntryChanged += UpdateCell;
}
public void WorldLoaded(World w, WorldRenderer wr)
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Traits
public void UpdateCell(CPos cell)
{
var uv = cell.ToMPos(Map);
var tile = Map.MapResources.Value[uv];
var tile = Map.Resources[uv];
var t = Tiles[cell];
if (t.Density > 0)
@@ -127,7 +127,7 @@ namespace OpenRA.Mods.Common.Traits
// Set density based on the number of neighboring resources
var adjacent = 0;
var type = Tiles[c].Type;
var resources = Map.MapResources.Value;
var resources = Map.Resources;
for (var u = -1; u < 2; u++)
{
for (var v = -1; v < 2; v++)
@@ -205,7 +205,7 @@ namespace OpenRA.Mods.Common.Traits
foreach (var kv in spriteLayers.Values)
kv.Dispose();
Map.MapResources.Value.CellEntryChanged -= UpdateCell;
Map.Resources.CellEntryChanged -= UpdateCell;
disposed = true;
}

View File

@@ -111,7 +111,7 @@ namespace OpenRA.Mods.Common.Traits
foreach (var cell in w.Map.AllCells)
{
ResourceType t;
if (!resources.TryGetValue(w.Map.MapResources.Value[cell].Type, out t))
if (!resources.TryGetValue(w.Map.Resources[cell].Type, out t))
continue;
if (!AllowResourceAt(t, cell))
@@ -193,7 +193,7 @@ namespace OpenRA.Mods.Common.Traits
if (!rt.Info.AllowOnRamps)
{
var tile = world.Map.MapTiles.Value[cell];
var tile = world.Map.Tiles[cell];
var tileInfo = world.Map.Rules.TileSet.GetTileInfo(tile);
if (tileInfo != null && tileInfo.RampType > 0)
return false;

View File

@@ -57,11 +57,11 @@ namespace OpenRA.Mods.Common.Traits
foreach (var uv in wr.Viewport.AllVisibleCells.CandidateMapCoords)
{
if (!map.MapHeight.Value.Contains(uv))
if (!map.Height.Contains(uv))
continue;
var height = (int)map.MapHeight.Value[uv];
var tile = map.MapTiles.Value[uv];
var height = (int)map.Height[uv];
var tile = map.Tiles[uv];
var ti = tileSet.GetTileInfo(tile);
var ramp = ti != null ? ti.RampType : 0;