Reorganize actor and smudge loading.
The actor and smudge definitions are now stored as raw MiniYamlNodes in the map. It is now the responsibility of the consumers to parse these into real objects.
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user