Example #1
0
        static void ModifyItemStackSizeAndWeight(ObjectDB __instance)
        {
            bool  stackSizeEnabled    = stackSizeEnabledConfig.Value;
            float stackSizeMultiplier = Mathf.Clamp(stackSizeMultiplierConfig.Value, 0, int.MaxValue);

            bool  weightEnabled    = weightEnabledConfig.Value;
            float weightMultiplier = Mathf.Clamp(weightMultiplierConfig.Value, 0, int.MaxValue);

            if (!(stackSizeEnabled || weightEnabled))
            {
                return;
            }

            foreach (ItemDrop.ItemData.ItemType type in (ItemDrop.ItemData.ItemType[])Enum.GetValues(typeof(ItemDrop.ItemData.ItemType)))
            {
                foreach (ItemDrop item in __instance.GetAllItems(type, ""))
                {
                    if (item.m_itemData.m_shared.m_name.StartsWith("$item_"))
                    {
                        ItemTracker tracker = GetItemTracker(item);

                        if (stackSizeEnabled && (tracker.OriginalStackSize > 1))
                        {
                            tracker.SetStackSize(stackSizeMultiplier, item);
                        }

                        if (weightEnabled)
                        {
                            tracker.SetWeight(weightMultiplier, item);
                        }
                    }
                }
            }
        }
Example #2
0
        static void BlastFurnacePatch(ref Smelter __instance)
        {
            if (__instance.m_name != "$piece_blastfurnace")
            {
                //UnityEngine.Debug.Log("Ignored non-blast furnace smelter.");
                return;
            }
            //UnityEngine.Debug.Log("Found a blast furnace! Applying fix.");

            ObjectDB        instance  = ObjectDB.instance;
            List <ItemDrop> materials = instance.GetAllItems(ItemDrop.ItemData.ItemType.Material, "");

            foreach (ItemDrop material in materials)
            {
                if (BFFix.metals.Keys.Contains(material.m_itemData.m_shared.m_name))
                {
                    //UnityEngine.Debug.Log("Adding " + material.m_itemData.m_shared.m_name + " to list of materials.");
                    BFFix.metals[material.m_itemData.m_shared.m_name] = material;
                }
            }

            List <Smelter.ItemConversion> conversions = new List <Smelter.ItemConversion>()
            {
                new Smelter.ItemConversion {
                    m_from = BFFix.metals["$item_copperore"], m_to = BFFix.metals["$item_copper"]
                },
                new Smelter.ItemConversion {
                    m_from = BFFix.metals["$item_tinore"], m_to = BFFix.metals["$item_tin"]
                },
                new Smelter.ItemConversion {
                    m_from = BFFix.metals["$item_ironscrap"], m_to = BFFix.metals["$item_iron"]
                },
                new Smelter.ItemConversion {
                    m_from = BFFix.metals["$item_silverore"], m_to = BFFix.metals["$item_silver"]
                }
            };

            foreach (Smelter.ItemConversion conversion in conversions)
            {
                __instance.m_conversion.Add(conversion);
            }
        }