Refactor map-actor loading

This commit is contained in:
Paul Chote
2010-03-03 20:04:07 +13:00
parent ae2bbae16c
commit 97bdb9b63f
8 changed files with 57 additions and 65 deletions

View File

@@ -101,11 +101,8 @@ namespace OpenRA
Timer.Time( "ChromeProv, SeqProv, viewport: {0}" );
skipMakeAnims = true;
foreach (var treeReference in Game.world.Map.Trees)
world.CreateActor(treeReference.Image, new int2(treeReference.Location), null);
Timer.Time( "trees: {0}" );
world.LoadMapActors(Rules.AllRules);
foreach (var actorReference in Game.world.Map.Actors)
world.CreateActor(actorReference.Name, actorReference.Location, world.players.Values.FirstOrDefault(p => p.InternalName == actorReference.Owner) ?? world.players[0]);
skipMakeAnims = false;
Timer.Time( "map actors: {0}" );

View File

@@ -200,22 +200,6 @@ namespace OpenRA
return xy;
}
public static void LoadMapActors(this World world, IniFile mapfile)
{
var toLoad =
mapfile.GetSection("STRUCTURES", true)
.Concat(mapfile.GetSection("UNITS", true));
foreach (var s in toLoad)
{
//num=owner,type,health,location,facing,...
var parts = s.Value.Split( ',' );
var loc = int.Parse(parts[3]);
world.CreateActor(parts[1].ToLowerInvariant(), new int2(loc % 128, loc / 128),
world.players.Values.FirstOrDefault(p => p.InternalName == parts[0]) ?? world.players[0]);
}
}
public static int2 ChooseRandomEdgeCell(this World w)
{
var isX = w.SharedRandom.Next(2) == 0;