Exemple #1
0
        private object OnRecycleItem(Recycler recycler, Item item)
        {
            if (_config.Options.BlockedItems == null || !_config.Options.BlockedItems.Any())
            {
                return(null);
            }

            if (item.info.Blueprint != null)
            {
                if (item.info.Blueprint.ingredients.Any(x => _config.Options.BlockedItems.Contains(x?.itemDef?.shortname)))
                {
                    foreach (var itemAmount in item.info.Blueprint.ingredients)
                    {
                        if (!_config.Options.BlockedItems.Contains(itemAmount.itemDef.shortname))
                        {
                            recycler.MoveItemToOutput(ItemManager.Create(itemAmount.itemDef, Mathf.CeilToInt(itemAmount.amount * recycler.recycleEfficiency))); // Give normal items.
                            continue;
                        }

                        foreach (var componentIngredient in itemAmount.itemDef.Blueprint.ingredients) // Directly convert components into sub materials.
                        {
                            Item newItem = ItemManager.Create(componentIngredient.itemDef, Mathf.CeilToInt((componentIngredient.amount * recycler.recycleEfficiency)) * Mathf.CeilToInt(itemAmount.amount * recycler.recycleEfficiency), 0uL);
                            recycler.MoveItemToOutput(newItem);
                        }
                    }

                    item.UseItem();
                    return(true);
                }
            }

            return(null);
        }
Exemple #2
0
        private object OnRecycleItem(Recycler recycler, Item item)
        {
            bool flag      = false;
            int  usedItems = 1;

            if (item.amount > 1)
            {
                usedItems = item.amount;
            }
            if (usedItems > maxItemsPerRecycle)
            {
                usedItems = maxItemsPerRecycle;
            }

            item.UseItem(usedItems);
            foreach (ItemInfo ingredient in ingredientList[item.info.shortname])
            {
                double multi = 1;
                if (multiplyList.ContainsKey("*"))
                {
                    multi = Convert.ToDouble(multiplyList["*"]);
                }
                if (multiplyList.ContainsKey(ingredient.itemName))
                {
                    multi = Convert.ToDouble(multiplyList[ingredient.itemName]);
                }
                int outputamount = Convert.ToInt32(usedItems * Convert.ToDouble(ingredient.itemAmount) * multi);
                if (outputamount < 1)
                {
                    continue;
                }
                if (!recycler.MoveItemToOutput(ItemManager.CreateByName(ingredient.itemName, outputamount)))
                {
                    flag = true;
                }
            }
            if (flag || !recycler.HasRecyclable())
            {
                recycler.StopRecycling();
                for (int i = 5; i <= 11; i++)
                {
                    Item _item = recycler.inventory.GetSlot(i);
                    if (_item == null)
                    {
                        continue;
                    }
                    if (_item.IsValid())
                    {
                        if (outputBlacklistedItems.Contains(_item.info.shortname))
                        {
                            _item.Remove();
                            _item.RemoveFromContainer();
                        }
                    }
                }
            }
            return(true);
        }
Exemple #3
0
        bool SendToOutput(Recycler recycler, string shortname, int amount)
        {
            Item item = ItemManager.CreateByName(shortname, amount);

            if (item != null)
            {
                return(recycler.MoveItemToOutput(item));
            }
            return(false);
        }
        // turn those blueprints into scrap
        void OnRecycleItem(Recycler recycler, Item item)
        {
            if (item.IsBlueprint())
            {
                int amount = 0;

                ItemDefinition target = ItemManager.FindItemDefinition(item.blueprintTarget);
                if (target == null)
                {
                    return;
                }

                int custom = (int)Config["Custom_" + target.shortname];

                // set scrap amount based on custom setting, or rarity
                if (custom > 0)
                {
                    amount = custom;
                }
                else if (target?.rarity == null)
                {
                    amount = 1;
                }
                else if (target.rarity == Rarity.Common)
                {
                    amount = common;
                }
                else if (target.rarity == Rarity.Uncommon)
                {
                    amount = uncommon;
                }
                else if (target.rarity == Rarity.Rare)
                {
                    amount = rare;
                }
                else if (target.rarity == Rarity.VeryRare || target.rarity == Rarity.None)
                {
                    amount = veryrare;
                }


                // reward player with scrap
                if (amount > 0)
                {
                    Item reward = ItemManager.CreateByItemID(scrapID, amount);
                    if (reward != null)
                    {
                        recycler.MoveItemToOutput(reward);
                        item.UseItem(1);
                    }
                }
            }
        }
Exemple #5
0
        private object OnRecycleItem(Recycler recycler, Item item)
        {
            {
                item.UseItem(1);
                switch (item.skin)
                {
                case 1676503124:
                    recycler.MoveItemToOutput(ItemManager.CreateByName("sulfur", +Random.Range(250, 7250)));
                    break;

                default:
                    return(null);
                }
                return(true);
            }
            return(null);
        }
Exemple #6
0
        private object OnRecycleItem(Recycler recycler, Item item)
        {
            if (config.bAP.Contains(item.info.shortname))
            {
                return(null);
            }
            recycler.inventory?.Remove(item);
            foreach (var i in item.info.Blueprint.ingredients)
            {
                i.amount /= 2;
                i.amount *= config.mod;
                i.amount *= item.amount;
                var z = ItemManager.Create(i.itemDef, Convert.ToInt32(i.amount));
                if (z == null)
                {
                    continue;
                }
                recycler.MoveItemToOutput(z);
            }

            return(false);
        }
Exemple #7
0
        private object OnRecycleItem(Recycler recycler, Item item)
        {
            var itemInfo = GetItemInfo(item.info.shortname);

            if (itemInfo == null || blacklistedItems.Contains(item.info.shortname))
            {
                item.Drop(recycler.transform.TransformPoint(new Vector3(-0.3f, 1.7f, 1f)), Vector3.up, new Quaternion());
                return(false);
            }

            bool flag = false;

            int usedItems = item.amount;

            if (!itemInfo.useGlobalMaxItemsPerRecycle)
            {
                if (usedItems > itemInfo.maxItemsPerRecycle)
                {
                    usedItems = itemInfo.maxItemsPerRecycle;
                }
            }
            else
            {
                if (usedItems > maxItemsPerRecycle)
                {
                    usedItems = maxItemsPerRecycle;
                }
            }

            item.UseItem(usedItems);
            foreach (var ingredient in itemInfo.ingredients)
            {
                double multi = 1;
                if (multiplyList.ContainsKey("*"))
                {
                    multi = Convert.ToDouble(multiplyList["*"]);
                }
                if (multiplyList.ContainsKey(ingredient.itemName))
                {
                    multi = Convert.ToDouble(multiplyList[ingredient.itemName]);
                }

                int outputamount = Convert.ToInt32(usedItems * Convert.ToDouble(ingredient.itemAmount) * multi);
                var output       = Interface.CallHook("OnRecycleItemOutput", ingredient.itemName, outputamount);
                if (output != null)
                {
                    outputamount = (int)output;
                }
                if (outputamount < 1)
                {
                    continue;
                }
                if (!recycler.MoveItemToOutput(ItemManager.CreateByName(ingredient.itemName, outputamount)))
                {
                    flag = true;
                }
            }
            if (flag || !recycler.HasRecyclable())
            {
                recycler.StopRecycling();
                for (int i = 5; i <= 11; i++)
                {
                    Item _item = recycler.inventory.GetSlot(i);
                    if (_item == null)
                    {
                        continue;
                    }
                    if (_item.IsValid())
                    {
                        if (outputBlacklistedItems.Contains(_item.info.shortname))
                        {
                            _item.Remove();
                            _item.RemoveFromContainer();
                        }
                    }
                }
            }
            return(true);
        }
Exemple #8
0
        private object OnRecycleItem(Recycler recycler, Item item)
        {
            var bp = ItemManager.FindItemDefinition(item.info.itemid).Blueprint;

            if (blacklistedItems.Contains(item.info.shortname) || bp == null || bp.ingredients?.Count == 0)
            {
                return(false);
            }

            int usedItems = 1;

            if (item.amount > 1)
            {
                usedItems = item.amount;
            }
            if (usedItems > maxItemsPerRecycle)
            {
                usedItems = maxItemsPerRecycle;
            }
            item.UseItem(usedItems);

            foreach (ItemAmount ingredient in bp.ingredients)
            {
                var    shortname = ingredient.itemDef.shortname;
                double multi     = 1;
                if (multiplyList.ContainsKey("*"))
                {
                    multi = Convert.ToDouble(multiplyList["*"]);
                }
                if (multiplyList.ContainsKey(shortname))
                {
                    multi = Convert.ToDouble(multiplyList[shortname]);
                }
                double outputamount = 0;

                if (ingredient.itemDef.itemid == scrapID)
                {
                    outputamount = Convert.ToDouble(usedItems * Convert.ToDouble(bp.scrapFromRecycle) * multi);
                }
                else
                {
                    outputamount = Convert.ToDouble(usedItems * Convert.ToDouble(ingredient.amount / (2 * bp.amountToCreate)) * multi);
                }

                // when the batch is returning less than 1 we'll give the chance to return it.
                // For large batches users will get back the percentage ie 25% pipes out of 10 HE grens ends up being 2 pipes every time, but 1 HE will give 25% chance
                if (outputamount < 1)
                {
                    var rnd = Oxide.Core.Random.Range(100);
                    if (rnd < outputamount * 100)
                    {
                        outputamount = 1;
                    }
                    else
                    {
                        continue;
                    }
                }

                if (!recycler.MoveItemToOutput(ItemManager.CreateByItemID(ingredient.itemDef.itemid, Convert.ToInt32(outputamount))))
                {
                    recycler.StopRecycling();
                }
            }
            if (!recycler.HasRecyclable())
            {
                recycler.StopRecycling();
            }
            return(true);
        }