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); } } } } }
private static ItemTracker GetItemTracker(ItemDrop item) { bool gotIt = itemTrackers.TryGetValue(item.m_itemData.m_shared.m_name, out ItemTracker tracker); if (gotIt) { return(tracker); } tracker = new ItemTracker(item); itemTrackers.Add(item.m_itemData.m_shared.m_name, tracker); return(tracker); }