Bricklayer.Server.Server.PlayerFromRUI C# (CSharp) Метод

PlayerFromRUI() публичный статический Метод

Finds a player from a remote unique identifier
public static PlayerFromRUI ( long remoteUniqueIdentifier, bool ignoreError = false ) : Bricklayer.Server.Entities.Player
remoteUniqueIdentifier long The RMI to find
ignoreError bool If a player is not found, should an error be thrown?
Результат Bricklayer.Server.Entities.Player
        public static Player PlayerFromRUI(long remoteUniqueIdentifier, bool ignoreError = false)
        {
            Player found = null;
            foreach (Map map in Maps)
            {
                foreach (Player player in map.Players)
                {
                    if (player.RemoteUniqueIdentifier == remoteUniqueIdentifier)
                        found = player;
                }
            }
            if (found != null) return found;
            else if (ignoreError) return null;
            else throw new KeyNotFoundException("Could not find player from RemoteUniqueIdentifier: " + remoteUniqueIdentifier);
        }

Usage Example

Пример #1
0
 /// <summary>
 /// Broadcasts a message to all players in a room, EXCEPT for the one specified
 /// </summary>
 /// <param name="gameMessage">IMessage to send</param>
 /// <param name="player">Player NOT to send to</param>
 public void BroadcastExcept(IMessage gameMessage, Player player)
 {
     BroadcastExcept(gameMessage,
                     (NetConnection)NetServer.Connections.Where(x => x.RemoteUniqueIdentifier == player.RemoteUniqueIdentifier &&
                                                                Server.PlayerFromRUI(x.RemoteUniqueIdentifier, true).Map.ID == player.Map.ID)
                     .ElementAt(0));
 }
All Usage Examples Of Bricklayer.Server.Server::PlayerFromRUI