public void ApplySlotUpdates(InventorySlotMessage sm)
        {
            foreach (InventorySlot slot in sm.SlotUpdates)
            {
                if (slot == null)
                {
                    continue;
                }

                if (Slots.ContainsKey(slot.SlotId))
                {
                    if (slot.Mode)//remove slot
                    {
                        Slots.Remove(slot.SlotId);
                    }
                    else//update slot
                    {
                        Slots[slot.SlotId] = slot;
                    }
                }
                else
                {
                    Slots.Add(slot.SlotId, slot);
                }
            }
        }
        private void SendInventoryUpdates(SimulationEntity playerEntity)
        {
            InventorySlotMessage updates = new InventorySlotMessage();
            List <byte>          slots   = new List <byte>();

            if (playerEntity.Inventory == null)
            {
                return;
            }

            foreach ((byte slotId, IItem item) in playerEntity.Inventory.GetAllItems())
            {
                if (item == null)
                {
                    playerEntity.Inventory.Remove(slotId);
                }
                else
                {
                    updates.SlotUpdates.Add(new InventorySlot
                    {
                        Count      = item.StackSize(),
                        Name       = item.ItemConfigKey,
                        ItemType   = item.Configuration.ItemType,
                        Mode       = false,
                        SlotId     = slotId,
                        TextureKey = item.Configuration.TextureKey
                    });
                }

                slots.Add(slotId);
            }

            foreach (byte slotId in playerEntity.InventorySlotHistory.Where(slotId => !slots.Contains(slotId)))
            {
                updates.SlotUpdates.Add(new InventorySlot
                {
                    Mode   = true,
                    SlotId = slotId
                });
            }

            playerEntity.InventorySlotHistory = slots;

            if (updates.SlotUpdates.Any())
            {
                OnInventoryUpdate?.Invoke(playerEntity.EntityId, updates);
            }
        }