public bool AddItem(Item item)
    {
        foreach (var itemSlot in itemslots)
        {
            if (itemSlot.Item != null)
            {
                if (itemSlot.Item.Id == item.Id)
                {
                    if (itemSlot.Amount < itemSlot.Item.MaxStack)
                    {
                        itemSlot.Amount++;
                        AddItemEvent?.Invoke(item);
                        ItemQuestEvent?.Invoke(item);
                        return(true);
                    }
                }
            }
        }

        foreach (var itemSlot in itemslots)
        {
            if (itemSlot.Item == null)
            {
                itemSlot.Item   = item;
                itemSlot.Amount = 1;
                AddItemEvent?.Invoke(item);
                ItemQuestEvent?.Invoke(item);
                return(true);
            }
        }

        //        AddItemEvent?.Invoke(item);
        return(false);
    }
    public void AddItem(Item item, int ItemSlotID, int amount)
    {
        var target = itemslots.FirstOrDefault(s => s.Id == ItemSlotID);

        if (target != null)
        {
            target.Item   = item;
            target.Amount = amount;
        }
        ItemQuestEvent?.Invoke(item);
    }
    public bool AddItem(Item item, int amount, out int returnedAmount)
    {
        returnedAmount = 0;
        foreach (var itemSlot in itemslots)
        {
            if (itemSlot.Item != null)
            {
                if (itemSlot.Item.Id == item.Id)
                {
                    if (itemSlot.Amount < itemSlot.Item.MaxStack)
                    {
                        int tempAmount = itemSlot.Item.MaxStack - (itemSlot.Amount + amount);
                        if (tempAmount >= 0)
                        {
                            itemSlot.Amount += amount;
                            ItemQuestEvent?.Invoke(item);
                            return(true);
                        }
                        else
                        {
                            returnedAmount  = (amount + itemSlot.Amount) - itemSlot.Item.MaxStack;
                            itemSlot.Amount = itemSlot.Item.MaxStack;
                            return(AddItem(item, returnedAmount, out returnedAmount));
                        }
                    }
                }
            }
        }

        foreach (var itemSlot in itemslots)
        {
            if (itemSlot.Item == null)
            {
                itemSlot.Item   = item;
                itemSlot.Amount = amount;
                ItemQuestEvent?.Invoke(item);
                returnedAmount = 0;
                return(true);
            }
        }
        returnedAmount = amount;
        //        AddItemEvent?.Invoke(item);
        return(false);
    }
    public List <Item> AddItem(List <Item> items)
    {
        int counter   = 0;
        var TempItems = new List <Item>();

        if (items != null)
        {
            foreach (var item in items)
            {
                if (item != null)
                {
                    foreach (var itemSlot in itemslots)
                    {
                        if (itemSlot.Item != null)
                        {
                            if (itemSlot.Item.Id == item.Id)
                            {
                                if (itemSlot.Amount < itemSlot.Item.MaxStack)
                                {
                                    itemSlot.Amount++;
                                    AddItemEvent?.Invoke(item);
                                    ItemQuestEvent?.Invoke(item);
                                    counter++;
                                    items.Remove(item);
                                    break;
                                }
                            }
                        }
                    }

                    foreach (var itemSlot in itemslots)
                    {
                        if (itemSlot.Item == null)
                        {
                            itemSlot.Item   = item;
                            itemSlot.Amount = 1;
                            AddItemEvent?.Invoke(item);
                            ItemQuestEvent?.Invoke(item);
                            counter++;
                            items.Remove(item);
                            break;
                        }
                    }
                }
            }
        }
        if (items != null && items.Count > 0)
        {
            foreach (var item in items)
            {
                if (item != null)
                {
                    TempItems.Add(item);
                }
            }
            return(TempItems);
        }
        else
        {
            return(null);
        }
    }