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); } }
public virtual void AddShip(NPCShip npc, bool suspendNetworking = false) { _model.ShipIDs.Add(npc.Id); lock (SHIPLOCK) { if (!_shipCache.ContainsKey(npc.Id)) { _shipCache.Add(npc.Id, npc);//Somehow, this sometimes throws an exception. Ergo lock. } } SimulatableObjects.TryAdd(npc.Id, npc); if (!suspendNetworking) { var messageData = new MessageReceiveNewShips(); messageData.Ships.Add(npc.GetNetworkData(true, true, false, true)); BroadcastMessage(new NetworkMessageContainer(messageData, MessageTypes.ReceiveNewShips), npc.PlayerID); } }