Lazy actor loading
This commit is contained in:
@@ -30,12 +30,12 @@ namespace OpenRA.Editor
|
||||
|
||||
public void Apply(Surface surface)
|
||||
{
|
||||
if (surface.Map.Actors.Any(a => a.Value.Location() == surface.GetBrushLocation()))
|
||||
if (surface.Map.Actors.Value.Any(a => a.Value.Location() == surface.GetBrushLocation()))
|
||||
return;
|
||||
|
||||
var owner = "Neutral";
|
||||
var id = NextActorName(surface);
|
||||
surface.Map.Actors[id] = new ActorReference(Actor.Info.Name.ToLowerInvariant())
|
||||
surface.Map.Actors.Value[id] = new ActorReference(Actor.Info.Name.ToLowerInvariant())
|
||||
{
|
||||
new LocationInit( surface.GetBrushLocation() ),
|
||||
new OwnerInit( owner)
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Editor
|
||||
for (; ; )
|
||||
{
|
||||
var possible = "Actor{0}".F(id++);
|
||||
if (!surface.Map.Actors.ContainsKey(possible)) return possible;
|
||||
if (!surface.Map.Actors.Value.ContainsKey(possible)) return possible;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,12 +148,12 @@ namespace OpenRA.Editor
|
||||
ReadCncOverlay(file);
|
||||
ReadCncTrees(file);
|
||||
}
|
||||
*/
|
||||
|
||||
LoadActors(file, "STRUCTURES");
|
||||
LoadActors(file, "UNITS");
|
||||
LoadActors(file, "INFANTRY");
|
||||
LoadSmudges(file, "SMUDGE");
|
||||
|
||||
*/
|
||||
foreach (var p in Players)
|
||||
LoadPlayer(file, p, (legacyMapFormat == IniMapFormat.RedAlert));
|
||||
|
||||
@@ -163,6 +163,7 @@ namespace OpenRA.Editor
|
||||
LocationFromMapOffset(int.Parse(kv.Value), MapSize)))
|
||||
.ToArray();
|
||||
|
||||
/*
|
||||
// Add waypoint actors
|
||||
foreach( var kv in wps )
|
||||
{
|
||||
@@ -170,6 +171,7 @@ namespace OpenRA.Editor
|
||||
a.Add(new LocationInit(kv.Second));
|
||||
Map.Actors.Add("spawn" + kv.First, a);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
static int2 LocationFromMapOffset(int offset, int mapSize)
|
||||
@@ -341,7 +343,7 @@ namespace OpenRA.Editor
|
||||
});
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void ReadCncTrees(IniFile file)
|
||||
{
|
||||
IniSection terrain = file.GetSection("TERRAIN", true);
|
||||
@@ -417,7 +419,7 @@ namespace OpenRA.Editor
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
void LoadSmudges(IniFile file, string section)
|
||||
{
|
||||
foreach (var s in file.GetSection(section, true))
|
||||
|
||||
@@ -152,8 +152,8 @@ namespace OpenRA.Editor
|
||||
|
||||
Tool = null;
|
||||
|
||||
var key = Map.Actors.FirstOrDefault(a => a.Value.Location() == BrushLocation);
|
||||
if (key.Key != null) Map.Actors.Remove(key.Key);
|
||||
var key = Map.Actors.Value.FirstOrDefault(a => a.Value.Location() == BrushLocation);
|
||||
if (key.Key != null) Map.Actors.Value.Remove(key.Key);
|
||||
|
||||
if (Map.MapResources.Value[BrushLocation.X, BrushLocation.Y].type != 0)
|
||||
{
|
||||
@@ -338,7 +338,7 @@ namespace OpenRA.Editor
|
||||
Map.Bounds.Width * TileSet.TileSize * Zoom,
|
||||
Map.Bounds.Height * TileSet.TileSize * Zoom);
|
||||
|
||||
foreach (var ar in Map.Actors)
|
||||
foreach (var ar in Map.Actors.Value)
|
||||
DrawActor(e.Graphics, ar.Value.Location(), ActorTemplates[ar.Value.Type],
|
||||
GetPaletteForActor(ar.Value));
|
||||
|
||||
@@ -347,7 +347,7 @@ namespace OpenRA.Editor
|
||||
|
||||
if (Tool == null)
|
||||
{
|
||||
var x = Map.Actors.FirstOrDefault(a => a.Value.Location() == GetBrushLocation());
|
||||
var x = Map.Actors.Value.FirstOrDefault(a => a.Value.Location() == GetBrushLocation());
|
||||
if (x.Key != null)
|
||||
DrawActorBorder(e.Graphics, x.Value.Location(), ActorTemplates[x.Value.Type]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user