/// <summary> /// Broadcasts a message to all players in a room /// </summary> /// <param name="map">Map/Room to send to</param> /// <param name="gameMessage">IMessage to send</param> public void Broadcast(Map map, IMessage gameMessage) { NetOutgoingMessage message = EncodeMessage(gameMessage); //Search for recipients List<NetConnection> recipients = NetServer.Connections.Where( x => Server.PlayerFromRUI(x.RemoteUniqueIdentifier, true) != null && Server.PlayerFromRUI(x.RemoteUniqueIdentifier, true).Map == map) .ToList<NetConnection>(); if (recipients.Count > 0) //Send to recipients found NetServer.SendMessage(message,recipients, NetDeliveryMethod.ReliableOrdered,0); }
public EntityState SimulationState; //Current internal state (What the game sees) #endregion Fields #region Constructors /// <summary> /// Creates a new base of a player /// </summary> public Player(Map map, Vector2 position, string name, int id) { Map = map; Smiley = SmileyType.Default; Mode = PlayerMode.Normal; Tint = Color.White; SimulationState = new EntityState(); DisplayState = new EntityState(); PreviousState = new EntityState(); SimulationState.Position = PreviousState.Position = DisplayState.Position = position; if (id > byte.MaxValue) throw new ArgumentOutOfRangeException("id", id, "The player ID must be within range of a single byte."); ID = (byte)id; Username = name; Index = map.Players.Count; }
public InitMessage(NetIncomingMessage im, Map map) { this.map = map; this.Decode(im); }
public InitMessage(Map map) { this.map = map; }
public Player(Map map, Vector2 position, string name, long remoteUniqueIdentifier, int id) : base(map, position, name, id) { RemoteUniqueIdentifier = remoteUniqueIdentifier; }