/// <summary> /// //Tells a client where all the active items are in the world to have them spawned in before they can start playing /// </summary> /// <param name="ClientID">NetworkID for target client</param> public static void SendActiveItemList(int ClientID) { CommunicationLog.LogOut(ClientID + " active item list"); //Create a new NetworkPacket object to store the data for this active item list NetworkPacket Packet = new NetworkPacket(); //Grab the list of all the active item pickups currently in the game world List <GameItem> ItemPickups = ItemManager.GetActiveItemList(); //Write the relevant data values into the packet data Packet.WriteType(ServerPacketType.ActiveItemList); Packet.WriteInt(ItemPickups.Count); //Loop through the list of item pickups and write each of their information into the packet data foreach (GameItem ItemPickup in ItemPickups) { Packet.WriteInt(ItemPickup.ItemNumber); Packet.WriteInt(ItemPickup.ItemID); Packet.WriteVector3(VectorTranslate.ConvertVector(ItemPickup.ItemPosition)); } //Add this packet to the target clients outgoing packet queue PacketQueue.QueuePacket(ClientID, Packet); }
/// <summary> /// //Tells a client where all the active entities are in the world to have them spawned in before they can enter the game world /// </summary> /// <param name="ClientID">NetworkID for target client</param> public static void SendActiveEntityList(int ClientID) { CommunicationLog.LogOut(ClientID + " active entity list"); //Create a new NetworkPacket object to store the data for this active entity list NetworkPacket Packet = new NetworkPacket(); //Grab the list of all the entities currently active in the game world List <BaseEntity> ActiveEntities = EntityManager.ActiveEntities; //Write the relevant data values into the packet data Packet.WriteType(ServerPacketType.ActiveEntityList); Packet.WriteInt(ActiveEntities.Count); //Loop through the list of active entities and write each of their information into the packet data foreach (BaseEntity ActiveEntity in ActiveEntities) { Packet.WriteString(ActiveEntity.Type); Packet.WriteString(ActiveEntity.ID); Packet.WriteVector3(VectorTranslate.ConvertVector(ActiveEntity.Location)); Packet.WriteInt(ActiveEntity.HealthPoints); } //Add this packet to the target clients outgoing packet queue PacketQueue.QueuePacket(ClientID, Packet); }