Deselect actors when their owner changes.

This commit is contained in:
Paul Chote
2019-01-20 12:37:22 +00:00
parent 0df159e73b
commit a545b2e5fa
2 changed files with 25 additions and 0 deletions

View File

@@ -50,6 +50,29 @@ namespace OpenRA
ns.SelectionChanged();
}
public void Remove(Actor a)
{
if (actors.Remove(a))
{
UpdateHash();
foreach (var ns in worldNotifySelection)
ns.SelectionChanged();
}
}
internal void OnOwnerChanged(Actor a, Player oldOwner, Player newOwner)
{
if (!actors.Contains(a))
return;
// Remove the actor from the original owners selection
// Call UpdateHash directly for everyone else so watchers can account for the owner change if needed
if (oldOwner == a.World.LocalPlayer)
Remove(a);
else
UpdateHash();
}
public bool Contains(Actor a)
{
return actors.Contains(a);