Merge pull request #10942 from pchote/remove-map-lazyness

Remove map lazyness.
This commit is contained in:
Matthias Mailänder
2016-03-21 20:23:47 +01:00
28 changed files with 195 additions and 256 deletions

View File

@@ -263,6 +263,7 @@ namespace OpenRA.Mods.D2k.UtilityCommands
Size mapSize;
TileSet tileSet;
List<TerrainTemplateInfo> tileSetsFromYaml;
int playerCount;
D2kMapImporter(string filename, string tileset, Ruleset rules)
{
@@ -293,13 +294,12 @@ namespace OpenRA.Mods.D2k.UtilityCommands
public static Map Import(string filename, string mod, string tileset, Ruleset rules)
{
var map = new D2kMapImporter(filename, tileset, rules).map;
var importer = new D2kMapImporter(filename, tileset, rules);
var map = importer.map;
if (map == null)
return null;
map.RequiresMod = mod;
var players = new MapPlayers(map.Rules, map.SpawnPoints.Value.Length);
map.PlayerDefinitions = players.ToMiniYaml();
return map;
}
@@ -324,6 +324,9 @@ namespace OpenRA.Mods.D2k.UtilityCommands
// Each frame is a tile from the Dune 2000 tileset files, with the Frame ID being the index of the tile in the original file
tileSetsFromYaml = tileSet.Templates.Where(t => t.Value.Frames != null
&& t.Value.Images[0].ToLower() == tilesetName.ToLower()).Select(ts => ts.Value).ToList();
var players = new MapPlayers(map.Rules, playerCount);
map.PlayerDefinitions = players.ToMiniYaml();
}
void FillMap()
@@ -336,13 +339,13 @@ namespace OpenRA.Mods.D2k.UtilityCommands
var locationOnMap = GetCurrentTilePositionOnMap();
map.MapTiles.Value[locationOnMap] = tile;
map.Tiles[locationOnMap] = tile;
// Spice
if (tileSpecialInfo == 1)
map.MapResources.Value[locationOnMap] = new ResourceTile(1, 1);
map.Resources[locationOnMap] = new ResourceTile(1, 1);
if (tileSpecialInfo == 2)
map.MapResources.Value[locationOnMap] = new ResourceTile(1, 2);
map.Resources[locationOnMap] = new ResourceTile(1, 2);
// Actors
if (ActorDataByActorCode.ContainsKey(tileSpecialInfo))
@@ -356,7 +359,11 @@ namespace OpenRA.Mods.D2k.UtilityCommands
new LocationInit(locationOnMap),
new OwnerInit(kvp.Second)
};
map.ActorDefinitions.Add(new MiniYamlNode("Actor" + map.ActorDefinitions.Count, a.Save()));
if (kvp.First == "mpspawn")
playerCount++;
}
}
}