Skip to content

Commit

Permalink
Allow disabling of "count outside stockpile"
Browse files Browse the repository at this point in the history
  • Loading branch information
Falconne committed Apr 4, 2019
1 parent cddbccc commit 5e8ef8b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions mod-structure/Languages/English/Keyed/IW_LanguageData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,7 @@

<IW.ShowExtraUIButtons>Show extra UI buttons</IW.ShowExtraUIButtons>
<IW.ShowExtraUIButtonsDesc>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.</IW.ShowExtraUIButtonsDesc>

<IW.CountOutsideStockpiles>Count resources outside stockpiles</IW.CountOutsideStockpiles>
<IW.CountOutsideStockpilesDesc>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.</IW.CountOutsideStockpilesDesc>
</LanguageData>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/ImprovedWorkbenches/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -133,6 +137,11 @@ public bool ShouldDropOnFloorByDefault()
return _dropOnFloorByDefault;
}

public bool ShouldCountOutsideStockpiles()
{
return _countOutsideStockpiles;
}

public ExtendedBillDataStorage GetExtendedBillDataStorage()
{
return _extendedBillDataStorage;
Expand Down Expand Up @@ -160,6 +169,8 @@ public void OnBillDeleted(Bill_Production bill)

private SettingHandle<bool> _dropOnFloorByDefault;

private SettingHandle<bool> _countOutsideStockpiles;

private ExtendedBillDataStorage _extendedBillDataStorage;

// RImFactory support
Expand Down

0 comments on commit 5e8ef8b

Please sign in to comment.