From 5e8ef8b0e5594df31c5710e85d8a501e0065f1e1 Mon Sep 17 00:00:00 2001 From: Anuradha Dissanayake Date: Thu, 4 Apr 2019 21:32:34 +1300 Subject: [PATCH] Allow disabling of "count outside stockpile" --- .../Languages/English/Keyed/IW_LanguageData.xml | 3 +++ .../RecipeWorkerCounter_CountProducts_Detour.cs | 3 ++- src/ImprovedWorkbenches/Main.cs | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/mod-structure/Languages/English/Keyed/IW_LanguageData.xml b/mod-structure/Languages/English/Keyed/IW_LanguageData.xml index dc077bb..c6f6b5b 100644 --- a/mod-structure/Languages/English/Keyed/IW_LanguageData.xml +++ b/mod-structure/Languages/English/Keyed/IW_LanguageData.xml @@ -94,4 +94,7 @@ Show extra UI buttons Show buttons that let you set "target count" and "resume level" values in bill details via the keyboard. Disable if you have a mod or language that causes these buttons to become misplaced. + + Count resources outside stockpiles + A bug in the vanilla game prevents "resource items" (e.g. meals and medicine) from being counted if they are not in stockpiles. Enable this option to fix that, or disable if you are using another mod to do that. diff --git a/src/ImprovedWorkbenches/Detours/RecipeWorkerCounter_CountProducts_Detour.cs b/src/ImprovedWorkbenches/Detours/RecipeWorkerCounter_CountProducts_Detour.cs index 4c8fbdc..5d629e3 100644 --- a/src/ImprovedWorkbenches/Detours/RecipeWorkerCounter_CountProducts_Detour.cs +++ b/src/ImprovedWorkbenches/Detours/RecipeWorkerCounter_CountProducts_Detour.cs @@ -27,7 +27,8 @@ public static void Postfix(ref RecipeWorkerCounter __instance, ref int __result, var productThingDef = bill.recipe.products.First().thingDef; // Count resource items not in stockpiles - if (productThingDef.CountAsResource + if (Main.Instance.ShouldCountOutsideStockpiles() + && productThingDef.CountAsResource && !bill.includeEquipped && (bill.includeTainted || !productThingDef.IsApparel || !productThingDef.apparel.careIfWornByCorpse) && bill.includeFromZone == null diff --git a/src/ImprovedWorkbenches/Main.cs b/src/ImprovedWorkbenches/Main.cs index 13e85e6..9ec684d 100644 --- a/src/ImprovedWorkbenches/Main.cs +++ b/src/ImprovedWorkbenches/Main.cs @@ -50,6 +50,10 @@ public override void DefsLoaded() "dropOnFloorByDefault", "IW.DropOnFloorByDefault".Translate(), "IW.DropOnFloorByDefaultDesc".Translate(), false); + _countOutsideStockpiles = Settings.GetHandle( + "countOutsideStockpiles", "IW.CountOutsideStockpiles".Translate(), + "IW.CountOutsideStockpilesDesc".Translate(), true); + // Integration with other mods IntegrateWithOutfitter(); @@ -133,6 +137,11 @@ public bool ShouldDropOnFloorByDefault() return _dropOnFloorByDefault; } + public bool ShouldCountOutsideStockpiles() + { + return _countOutsideStockpiles; + } + public ExtendedBillDataStorage GetExtendedBillDataStorage() { return _extendedBillDataStorage; @@ -160,6 +169,8 @@ public void OnBillDeleted(Bill_Production bill) private SettingHandle _dropOnFloorByDefault; + private SettingHandle _countOutsideStockpiles; + private ExtendedBillDataStorage _extendedBillDataStorage; // RImFactory support