Deselect actors when their owner changes.
This commit is contained in:
@@ -336,6 +336,8 @@ namespace OpenRA
|
|||||||
foreach (var t in TraitsImplementing<INotifyOwnerChanged>())
|
foreach (var t in TraitsImplementing<INotifyOwnerChanged>())
|
||||||
t.OnOwnerChanged(this, oldOwner, newOwner);
|
t.OnOwnerChanged(this, oldOwner, newOwner);
|
||||||
|
|
||||||
|
World.Selection.OnOwnerChanged(this, oldOwner, newOwner);
|
||||||
|
|
||||||
if (wasInWorld)
|
if (wasInWorld)
|
||||||
World.Add(this);
|
World.Add(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,29 @@ namespace OpenRA
|
|||||||
ns.SelectionChanged();
|
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)
|
public bool Contains(Actor a)
|
||||||
{
|
{
|
||||||
return actors.Contains(a);
|
return actors.Contains(a);
|
||||||
|
|||||||
Reference in New Issue
Block a user