From b79d2d67b255a1e0e4486262bf24d5a4e4d85c79 Mon Sep 17 00:00:00 2001 From: Anuradha Dissanayake Date: Wed, 20 Mar 2019 12:55:51 +1300 Subject: [PATCH] When pasting settings between bills, ignore settings not applicable to destination product --- .../CopyPasteLink/BillCopyPaste.cs | 5 --- .../Custom Storage/ExtendedBillDataStorage.cs | 34 ++++++++++++++++--- .../Properties/AssemblyInfo.cs | 4 +-- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/ImprovedWorkbenches/CopyPasteLink/BillCopyPaste.cs b/src/ImprovedWorkbenches/CopyPasteLink/BillCopyPaste.cs index 01cfedb..9c28115 100644 --- a/src/ImprovedWorkbenches/CopyPasteLink/BillCopyPaste.cs +++ b/src/ImprovedWorkbenches/CopyPasteLink/BillCopyPaste.cs @@ -67,11 +67,6 @@ public bool CanPasteInto(Bill_Production targetBill) return _copiedBills.Count == 1 && _copiedBills.First() != targetBill; } - public bool IsMultipleBillsCopied() - { - return _copiedBills.Count > 1; - } - public void DoPasteInto(Building_WorkTable workTable, bool link) { foreach (var sourceBill in _copiedBills) diff --git a/src/ImprovedWorkbenches/Custom Storage/ExtendedBillDataStorage.cs b/src/ImprovedWorkbenches/Custom Storage/ExtendedBillDataStorage.cs index cae0427..f55ff68 100644 --- a/src/ImprovedWorkbenches/Custom Storage/ExtendedBillDataStorage.cs +++ b/src/ImprovedWorkbenches/Custom Storage/ExtendedBillDataStorage.cs @@ -62,7 +62,7 @@ public void MigrateLegacyBillStore() foreach (var billId in _legacyStore.Keys) { - var bill = productionBills.FirstOrDefault(b => billId == (int) loadIdGetter.GetValue(b)); + var bill = productionBills.FirstOrDefault(b => billId == (int)loadIdGetter.GetValue(b)); if (bill == null) { Main.Instance.Logger.Warning($"Cannot find bill for id {billId}, cannot migrate"); @@ -215,12 +215,36 @@ public void MirrorBills(Bill_Production sourceBill, Bill_Production destinationB destinationBill.targetCount = sourceBill.targetCount; destinationBill.pauseWhenSatisfied = sourceBill.pauseWhenSatisfied; destinationBill.unpauseWhenYouHave = sourceBill.unpauseWhenYouHave; - destinationBill.includeEquipped = sourceBill.includeEquipped; - destinationBill.includeTainted = sourceBill.includeTainted; destinationBill.includeFromZone = sourceBill.includeFromZone; destinationBill.hpRange = sourceBill.hpRange; - destinationBill.qualityRange = sourceBill.qualityRange; - destinationBill.limitToAllowedStuff = sourceBill.limitToAllowedStuff; + + var sourceThingDef = sourceBill.recipe.ProducedThingDef; + var producedThingDef = destinationBill.recipe.ProducedThingDef; + if (sourceThingDef != null && producedThingDef != null) + { + if ((sourceThingDef.IsWeapon || sourceThingDef.IsApparel) && + (producedThingDef.IsWeapon || producedThingDef.IsApparel)) + { + destinationBill.includeEquipped = sourceBill.includeEquipped; + } + + if (sourceThingDef.IsApparel && sourceThingDef.apparel.careIfWornByCorpse && + producedThingDef.IsApparel && producedThingDef.apparel.careIfWornByCorpse) + { + destinationBill.includeTainted = sourceBill.includeTainted; + } + + if (sourceThingDef.HasComp(typeof(CompQuality)) && + producedThingDef.HasComp(typeof(CompQuality))) + { + destinationBill.qualityRange = sourceBill.qualityRange; + } + + if (sourceThingDef.MadeFromStuff && producedThingDef.MadeFromStuff) + { + destinationBill.limitToAllowedStuff = sourceBill.limitToAllowedStuff; + } + } } var sourceExtendedData = GetOrCreateExtendedDataFor(sourceBill); diff --git a/src/ImprovedWorkbenches/Properties/AssemblyInfo.cs b/src/ImprovedWorkbenches/Properties/AssemblyInfo.cs index ef445c5..7689169 100644 --- a/src/ImprovedWorkbenches/Properties/AssemblyInfo.cs +++ b/src/ImprovedWorkbenches/Properties/AssemblyInfo.cs @@ -31,8 +31,8 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.4.0")] -[assembly: AssemblyFileVersion("1.0.4.0")] +[assembly: AssemblyVersion("1.0.5.0")] +[assembly: AssemblyFileVersion("1.0.5.0")]