Overhaul player disconnect notifications.

This commit is contained in:
Paul Chote
2021-09-04 15:09:30 +01:00
committed by abcdefg30
parent b8e343bee9
commit 54c08748e0
12 changed files with 99 additions and 60 deletions

View File

@@ -82,6 +82,7 @@ namespace OpenRA
readonly bool inMissionMap;
readonly bool spectating;
readonly IUnlocksRenderPlayer[] unlockRenderPlayer;
readonly INotifyPlayerDisconnected[] notifyDisconnected;
// Each player is identified with a unique bit in the set
// Cache masks for the player's index and ally/enemy player indices for performance.
@@ -226,6 +227,7 @@ namespace OpenRA
stanceColors.Neutrals = ChromeMetrics.Get<Color>("PlayerStanceColorNeutrals");
unlockRenderPlayer = PlayerActor.TraitsImplementing<IUnlocksRenderPlayer>().ToArray();
notifyDisconnected = PlayerActor.TraitsImplementing<INotifyPlayerDisconnected>().ToArray();
}
public override string ToString()
@@ -280,6 +282,12 @@ namespace OpenRA
return stanceColors.Neutrals;
}
internal void PlayerDisconnected(Player p)
{
foreach (var np in notifyDisconnected)
np.PlayerDisconnected(PlayerActor, p);
}
#region Scripting interface
Lazy<ScriptPlayerInterface> luaInterface;