Merge pull request #8017 from pchote/map-definitions

Remove magic ActorReference/SmudgeReference parsing
This commit is contained in:
Chris Forbes
2015-04-30 10:46:27 +12:00
17 changed files with 112 additions and 132 deletions

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
public void WorldLoaded(World world, WorldRenderer wr)
{
var spawns = world.Map.GetSpawnPoints();
var spawns = world.Map.SpawnPoints.Value;
var taken = world.LobbyInfo.Clients.Where(c => c.SpawnPoint != 0 && c.Slot != null)
.Select(c => spawns[c.SpawnPoint - 1]).ToList();
var available = spawns.Except(taken).ToList();

View File

@@ -72,16 +72,27 @@ namespace OpenRA.Mods.Common.Traits
}
// Add map smudges
foreach (var s in w.Map.Smudges.Value.Where(s => smudges.ContainsKey(s.Type)))
foreach (var s in w.Map.SmudgeDefinitions)
{
var name = s.Key;
var vals = name.Split(' ');
var type = vals[0];
if (!smudges.ContainsKey(type))
continue;
var loc = vals[1].Split(',');
var cell = new CPos(Exts.ParseIntegerInvariant(loc[0]), Exts.ParseIntegerInvariant(loc[1]));
var depth = Exts.ParseIntegerInvariant(vals[2]);
var smudge = new Smudge
{
Type = s.Type,
Depth = s.Depth,
Sprite = smudges[s.Type][s.Depth]
Type = type,
Depth = depth,
Sprite = smudges[type][depth]
};
tiles.Add((CPos)s.Location, smudge);
tiles.Add(cell, smudge);
}
}

View File

@@ -25,17 +25,19 @@ namespace OpenRA.Mods.Common.Traits
public void WorldLoaded(World world, WorldRenderer wr)
{
foreach (var actorReference in world.Map.Actors.Value)
foreach (var kv in world.Map.ActorDefinitions)
{
var actorReference = new ActorReference(kv.Value.Value, kv.Value.ToDictionary());
// if there is no real player associated, dont spawn it.
var ownerName = actorReference.Value.InitDict.Get<OwnerInit>().PlayerName;
var ownerName = actorReference.InitDict.Get<OwnerInit>().PlayerName;
if (!world.Players.Any(p => p.InternalName == ownerName))
continue;
var initDict = actorReference.Value.InitDict;
var initDict = actorReference.InitDict;
initDict.Add(new SkipMakeAnimsInit());
var actor = world.CreateActor(actorReference.Value.Type, initDict);
Actors[actorReference.Key] = actor;
var actor = world.CreateActor(actorReference.Type, initDict);
Actors[kv.Key] = actor;
LastMapActorID = actor.ActorID;
}
}