public void AddPlayer(OpenRA.Player runtimePlayer, Session lobbyInfo)
{
if (runtimePlayer == null)
throw new ArgumentNullException("runtimePlayer");
if (lobbyInfo == null)
throw new ArgumentNullException("lobbyInfo");
// We don't care about spectators and map players
if (runtimePlayer.NonCombatant || !runtimePlayer.Playable)
return;
// Find the lobby client that created the runtime player
var client = lobbyInfo.ClientWithIndex(runtimePlayer.ClientIndex);
if (client == null)
return;
var player = new Player
{
ClientIndex = runtimePlayer.ClientIndex,
Name = runtimePlayer.PlayerName,
IsHuman = !runtimePlayer.IsBot,
IsBot = runtimePlayer.IsBot,
FactionName = runtimePlayer.Faction.Name,
FactionId = runtimePlayer.Faction.InternalName,
Color = runtimePlayer.Color,
Team = client.Team,
SpawnPoint = runtimePlayer.SpawnPoint,
IsRandomFaction = runtimePlayer.Faction.InternalName != client.Faction,
IsRandomSpawnPoint = runtimePlayer.SpawnPoint != client.SpawnPoint
};
playersByRuntime.Add(runtimePlayer, player);
Players.Add(player);
}