public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem)
        {
            int storageSlotsSynced = 0;

            HashSet <NitroxId> onlinePlayers = new HashSet <NitroxId> {
                packet.PlayerGameObjectId
            };

            onlinePlayers.AddRange(packet.RemotePlayerData.Select(playerData => playerData.PlayerContext.PlayerNitroxId));

            // Removes any batteries which are in inventories from offline players
            List <ItemData> currentlyIgnoredItems = packet.InventoryItems.Where(item => !onlinePlayers.Any(player => player.Equals(item.ContainerId))).ToList();

            packet.StorageSlotItems.RemoveAll(storageItem => currentlyIgnoredItems.Any(ignoredItem => ignoredItem.ItemId.Equals(storageItem.ContainerId)));

            using (packetSender.Suppress <StorageSlotItemAdd>())
            {
                foreach (ItemData itemData in packet.StorageSlotItems)
                {
                    waitScreenItem.SetProgress(storageSlotsSynced, packet.StorageSlotItems.Count);

                    GameObject item = SerializationHelper.GetGameObject(itemData.SerializedData);

                    Log.Debug($"Initial StorageSlot item data for {item.name} giving to container {itemData.ContainerId}");

                    NitroxEntity.SetNewId(item, itemData.ItemId);
                    slots.AddItem(item, itemData.ContainerId, true);

                    storageSlotsSynced++;
                    yield return(null);
                }
            }
        }
예제 #2
0
        public override void Process(StorageSlotItemAdd packet)
        {
            ItemData   itemData = packet.ItemData;
            GameObject item     = SerializationHelper.GetGameObject(itemData.SerializedData);

            NitroxEntity.SetNewId(item, itemData.ItemId);

            storageSlots.AddItem(item, itemData.ContainerId);
        }
 public override void Process(InitialPlayerSync packet)
 {
     using (packetSender.Suppress <StorageSlotItemAdd>())
     {
         foreach (ItemData itemData in packet.StorageSlots)
         {
             GameObject item = SerializationHelper.GetGameObject(itemData.SerializedData);
             NitroxEntity.SetNewId(item, itemData.ItemId);
             slots.AddItem(item, itemData.ContainerId, true);
         }
     }
 }
        public override IEnumerator Process(InitialPlayerSync packet, WaitScreen.ManualWaitItem waitScreenItem)
        {
            int storageSlotsSynced = 0;

            using (packetSender.Suppress <StorageSlotItemAdd>())
            {
                foreach (ItemData itemData in packet.StorageSlots)
                {
                    waitScreenItem.SetProgress(storageSlotsSynced, packet.StorageSlots.Count);

                    GameObject item = SerializationHelper.GetGameObject(itemData.SerializedData);

                    Log.Debug($"Initial StorageSlot item data for {item.name} giving to container {itemData.ContainerId}");

                    NitroxEntity.SetNewId(item, itemData.ItemId);
                    slots.AddItem(item, itemData.ContainerId, true);

                    storageSlotsSynced++;
                    yield return(null);
                }
            }
        }