public virtual void CreateGenerator()
        {
            var generator = new BasicItemGenerator();

            generator.SetItems(ItemManager.instance.items, 1.0f);
            generator.onlyOfType = new List <System.Type>(vendorUI.onlyAllowTypes);
            //generator.maxBuyPrice = 50;
            //generator.onlyOfType.Add(typeof(ConsumableInventoryItem));
            //generator.onlyOfType.Add(typeof(UnusableInventoryItem));
            itemGenerator = generator;

            if (generateItems)
            {
                forSale = itemGenerator.Generate(generateItemsCount);
            }
        }
        public virtual void CreateGenerator()
        {
            var generator = new BasicItemGenerator();
            generator.SetItems(ItemManager.instance.items, 1.0f);
            generator.onlyOfType = new List<System.Type>(InventoryManager.instance.vendor.onlyAllowTypes);
            //generator.maxBuyPrice = 50;
            //generator.onlyOfType.Add(typeof(ConsumableInventoryItem));
            //generator.onlyOfType.Add(typeof(UnusableInventoryItem));
            itemGenerator = generator;

            if (generateItems)
            {
                var t = itemGenerator.Generate(minAmount, maxAmount);
                items = new InventoryItemBase[t.Length];
                for (int i = 0; i < items.Length; i++)
                {
                    items[i] = GameObject.Instantiate<InventoryItemBase>(t[i]);
                    items[i].gameObject.SetActive(false);
                    items[i].transform.SetParent(transform);
                }
            }
        }
        public virtual void CreateGenerator()
        {
            var generator = new BasicItemGenerator();

            generator.SetItems(ItemManager.instance.items, 1.0f);
            generator.onlyOfType = new List <System.Type>(InventoryManager.instance.vendor.onlyAllowTypes);
            //generator.maxBuyPrice = 50;
            //generator.onlyOfType.Add(typeof(ConsumableInventoryItem));
            //generator.onlyOfType.Add(typeof(UnusableInventoryItem));
            itemGenerator = generator;

            if (generateItems)
            {
                var t = itemGenerator.Generate(minAmount, maxAmount);
                items = new InventoryItemBase[t.Length];
                for (int i = 0; i < items.Length; i++)
                {
                    items[i] = GameObject.Instantiate <InventoryItemBase>(t[i]);
                    items[i].gameObject.SetActive(false);
                    items[i].transform.SetParent(transform);
                }
            }
        }
        public virtual void CreateGenerator()
        {
            var generator = new BasicItemGenerator();
            generator.SetItems(ItemManager.instance.items, 1.0f);
            generator.onlyOfType = new List<System.Type>(vendorUI.onlyAllowTypes);
            //generator.maxBuyPrice = 50;
            //generator.onlyOfType.Add(typeof(ConsumableInventoryItem));
            //generator.onlyOfType.Add(typeof(UnusableInventoryItem));
            itemGenerator = generator;

            if(generateItems)
                forSale = itemGenerator.Generate(generateItemsCount);
        }
        /// <summary>
        /// Generate an array of items.
        /// InventoryItemGeneratorItem's chance is only affected after all the filters are applied, so the item might still be rejected by type, category, etc.
        /// </summary>
        /// <param name="minAmount"></param>
        /// <param name="maxAmount"></param>
        /// <returns></returns>
        public InventoryItemBase[] Generate(int minAmount, int maxAmount, bool createInstances = false)
        {
            var toReturn = new List<InventoryItemBase>(maxAmount);

            // No groups, fall back to the the basic generator.
            if (filterGroups.Length == 0)
            {
                var basic = new BasicItemGenerator();
                basic.items = items;
                result = basic.Generate(minAmount, maxAmount, createInstances);
                return result;
            }

            foreach (var filterGroup in filterGroups)
            {
                if (toReturn.Count >= maxAmount)
                    break;

                var l = new List<InventoryItemBase>(filterGroup.maxAmount);
                foreach (var filter in filterGroup.filters)
                {
                    foreach (int i in Enumerable.Range(0, items.Count()).OrderBy(x => randomGen.Next()))
                    {
                        if (Random.value > filterGroup.itemsChanceFactor)
                            continue;

                        if (l.Count > filterGroup.minAmount)
                        {
                            float dif = 1.0f / (filterGroup.maxAmount - filterGroup.minAmount); // Example:  10 - 8 = 2 --- 1.0f / 2 = 0.5f // 50% chance of stopping here
                            if (Random.value > dif)
                                break;

                        }

                        if (l.Count >= filterGroup.maxAmount)
                            break;

                        if (items[i].item == null)
                            continue;

                        bool abbiding = filter.IsItemAbidingFilter(items[i].item);
                        if (abbiding)
                        {
                            if (createInstances)
                            {
                                var item = GameObject.Instantiate<InventoryItemBase>(items[i].item);
                                item.currentStackSize = (uint)Random.Range(filterGroup.minStackSize, filterGroup.maxStackSize);
                                item.gameObject.SetActive(false);
                                l.Add(item);
                            }
                            else
                            {
                                l.Add(items[i].item);
                            }
                        }
                    }
                }

                toReturn.AddRange(l);
            }

            result = toReturn.ToArray();
            return result;
        }