Cache world INotifySelection traits in Selection.
This commit is contained in:
@@ -21,7 +21,14 @@ namespace OpenRA
|
||||
{
|
||||
public int Hash { get; private set; }
|
||||
public IEnumerable<Actor> Actors { get { return actors; } }
|
||||
|
||||
readonly HashSet<Actor> actors = new HashSet<Actor>();
|
||||
readonly INotifySelection[] worldNotifySelection;
|
||||
|
||||
internal Selection(IEnumerable<INotifySelection> worldNotifySelection)
|
||||
{
|
||||
this.worldNotifySelection = worldNotifySelection.ToArray();
|
||||
}
|
||||
|
||||
void UpdateHash()
|
||||
{
|
||||
@@ -31,14 +38,15 @@ namespace OpenRA
|
||||
Hash += 1;
|
||||
}
|
||||
|
||||
public void Add(World w, Actor a)
|
||||
public void Add(Actor a)
|
||||
{
|
||||
actors.Add(a);
|
||||
UpdateHash();
|
||||
|
||||
foreach (var sel in a.TraitsImplementing<INotifySelected>())
|
||||
sel.Selected(a);
|
||||
foreach (var ns in w.WorldActor.TraitsImplementing<INotifySelection>())
|
||||
|
||||
foreach (var ns in worldNotifySelection)
|
||||
ns.SelectionChanged();
|
||||
}
|
||||
|
||||
@@ -77,7 +85,7 @@ namespace OpenRA
|
||||
foreach (var sel in a.TraitsImplementing<INotifySelected>())
|
||||
sel.Selected(a);
|
||||
|
||||
foreach (var ns in world.WorldActor.TraitsImplementing<INotifySelection>())
|
||||
foreach (var ns in worldNotifySelection)
|
||||
ns.SelectionChanged();
|
||||
|
||||
if (world.IsGameOver)
|
||||
|
||||
Reference in New Issue
Block a user