Skip to content

Commit

Permalink
When pasting settings between bills, ignore settings not applicable t…
Browse files Browse the repository at this point in the history
…o destination product
  • Loading branch information
Falconne committed Mar 19, 2019
1 parent b95d15e commit b79d2d6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
5 changes: 0 additions & 5 deletions src/ImprovedWorkbenches/CopyPasteLink/BillCopyPaste.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
34 changes: 29 additions & 5 deletions src/ImprovedWorkbenches/Custom Storage/ExtendedBillDataStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/ImprovedWorkbenches/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]



0 comments on commit b79d2d6

Please sign in to comment.