public virtual void AddShip(IShip s, bool suspendNetworking = false) { if (s is NPCShip) { AddShip((NPCShip)s, suspendNetworking);//Unexpected! Overloaded call resolves to AddShip(IShip) return; } _model.ShipIDs.Add(s.Id); lock (SHIPLOCK) { if (!_shipCache.ContainsKey(s.Id)) { _shipCache.Add(s.Id, s);//Somehow, this sometimes throws an exception. Ergo lock. } } if (!suspendNetworking) { var messageData = new MessageReceiveNewShips(); messageData.Ships.Add(s.GetNetworkData(true, true, true, true)); BroadcastMessage(new NetworkMessageContainer(messageData, MessageTypes.ReceiveNewShips), s.PlayerID); } }
/// <summary> /// Changes IShip and notifies client. /// </summary> /// <param name="s">Ship of the player</param> /// <param name="shs">Ship to switch to</param> /// <param name="w">Weapon to switch to</param> public void ChangePlayersShip(IShip s, ShipStats shs) { s.ChangeShipType(shs); var data = s.GetNetworkData(false, false, false, true); s.GetPlayer().SendMessage(new NetworkMessageContainer(data, MessageTypes.ChangeShipType)); }
/// <summary> /// Sends playerID /// Sends info for all players in system at time of login /// /// </summary> /// <param name="?"></param> private void SendLoginList(IArea area, HumanPlayer player, ChatManager chatManager) { IShip ship = player.GetActiveShip(); MessageClientLogin data = new MessageClientLogin(); data.Ship = ship.GetNetworkData(true, true, true, true); data.CurrentCash = player.CashOnHand; data.LoginMessage = GetGalacticNews(player); data.AreaName = area.AreaName; data.PlayerInfo = new PlayerInfo(player.Id, player.ActiveShipId); player.SendMessage(new NetworkMessageContainer(data, MessageTypes.ClientLoginSuccess)); var outboundChat = new OutboundChatMessage( player, new ChatlineObject("Welcome to Freecon Galactic, " + player.Username + ".", ChatlineColor.White) ); chatManager.SendChatToPlayer(outboundChat); }