Exemplo n.º 1
0
        private List<ItemInstance> _getAvailableRecipeParts(ItemTemplate recipe)
        {
            var toReturn = new List<ItemInstance>();

            foreach (var i in items)
            {
                if (i == null)
                    continue;

                if (i.getTemplate().getId() == recipe.getId() && !i.getRecipeSearchFlag())
                {
                    toReturn.Add(i);
                    i.setRecipeSearchFlag(true);
                    return toReturn;
                }
            }

            foreach (var itemId in recipe.getRecipeParts())
            {
                var parts = _getAvailableRecipeParts(ItemManager.getInstance().getItemTemplateById(itemId));
                toReturn.AddRange(parts);
            }

            return toReturn;
        }
Exemplo n.º 2
0
        private List <ItemInstance> _getAvailableRecipeParts(ItemTemplate recipe)
        {
            var toReturn = new List <ItemInstance>();

            foreach (var i in items)
            {
                if (i == null)
                {
                    continue;
                }

                if (i.getTemplate().getId() == recipe.getId() && !i.getRecipeSearchFlag())
                {
                    toReturn.Add(i);
                    i.setRecipeSearchFlag(true);
                    return(toReturn);
                }
            }

            foreach (var itemId in recipe.getRecipeParts())
            {
                var parts = _getAvailableRecipeParts(ItemManager.getInstance().getItemTemplateById(itemId));
                toReturn.AddRange(parts);
            }

            return(toReturn);
        }
Exemplo n.º 3
0
        public ItemInstance addItem(ItemTemplate itemTemplate)
        {
            var slot = -1;

            if (itemTemplate.isTrinket())
            {
                if (items[6] == null)
                {
                    items[6] = new ItemInstance(itemTemplate, 6, 1);
                    return(items[6]);
                }
                return(null);
            }

            if (itemTemplate.getMaxStack() > 1)
            {
                for (slot = 0; slot < 6; ++slot)
                {
                    if (items[slot] == null)
                    {
                        continue;
                    }

                    if (items[slot].getTemplate() == itemTemplate)
                    {
                        if (items[slot].getStacks() < itemTemplate.getMaxStack())
                        {
                            items[slot].incrementStacks();
                            return(items[slot]);
                        }
                        else if (items[slot].getStacks() == itemTemplate.getMaxStack())
                        {
                            return(null);
                        }
                    }
                }
            }

            for (slot = 0; slot < 6; ++slot)
            {
                if (items[slot] == null)
                {
                    break;
                }
            }

            if (slot == 6)
            { // Inventory full
                return(null);
            }

            Logger.LogCoreInfo("Adding item " + itemTemplate.getId() + " to slot " + slot);
            items[slot] = new ItemInstance(itemTemplate, (byte)slot, 1);

            return(items[slot]);
        }
Exemplo n.º 4
0
        public ItemInstance addItem(ItemTemplate itemTemplate)
        {
            var slot = -1;

            if (itemTemplate.isTrinket())
            {
                if (items[6] == null)
                {
                    items[6] = new ItemInstance(itemTemplate, 6, 1);
                    return items[6];
                }
                return null;
            }

            if (itemTemplate.getMaxStack() > 1)
            {
                for (slot = 0; slot < 6; ++slot)
                {
                    if (items[slot] == null)
                        continue;

                    if (items[slot].getTemplate() == itemTemplate)
                    {
                        if (items[slot].getStacks() < itemTemplate.getMaxStack())
                        {
                            items[slot].incrementStacks();
                            return items[slot];
                        }
                        else if (items[slot].getStacks() == itemTemplate.getMaxStack())
                        {
                            return null;
                        }
                    }
                }
            }

            for (slot = 0; slot < 6; ++slot)
            {
                if (items[slot] == null)
                    break;
            }

            if (slot == 6)
            { // Inventory full
                return null;
            }

            Logger.LogCoreInfo("Adding item " + itemTemplate.getId() + " to slot " + slot);
            items[slot] = new ItemInstance(itemTemplate, (byte)slot, 1);

            return items[slot];
        }