diff --git a/Source/ProjectRimFactory/Industry/UI/ITab_PaperclipDuplicator.cs b/Source/ProjectRimFactory/Industry/UI/ITab_PaperclipDuplicator.cs index 5a74e54..8b4eb98 100644 --- a/Source/ProjectRimFactory/Industry/UI/ITab_PaperclipDuplicator.cs +++ b/Source/ProjectRimFactory/Industry/UI/ITab_PaperclipDuplicator.cs @@ -66,64 +66,71 @@ private void HandleDepositWithdrawRequest() { if (int.TryParse(amountTextArea, out int result)) { - if (deposit) + if(result > -1) { - List selected = new List(); - int current = 0; - foreach (Thing item in SelBuilding.boundStorageUnit.StoredItems.ToList()) + if (deposit) { - if (item.def == PRFDefOf.Paperclip) + List selected = new List(); + int current = 0; + foreach (Thing item in SelBuilding.boundStorageUnit.StoredItems.ToList()) { - int num = Math.Min(result - current, item.stackCount); - selected.Add(new ThingCount(item, num)); - current += num; + if (item.def == PRFDefOf.Paperclip) + { + int num = Math.Min(result - current, item.stackCount); + selected.Add(new ThingCount(item, num)); + current += num; + } + if (current == result) + { + break; + } } if (current == result) { - break; + SelBuilding.DepositPaperclips(result); + for (int i = 0; i < selected.Count; i++) + { + selected[i].Thing.SplitOff(selected[i].Count); + } + Messages.Message("SuccessfullyDepositedPaperclips".Translate(result), MessageTypeDefOf.PositiveEvent); } - } - if (current == result) - { - SelBuilding.DepositPaperclips(result); - for (int i = 0; i < selected.Count; i++) + else { - selected[i].Thing.SplitOff(selected[i].Count); + Messages.Message("PRFNotEnoughPaperclips".Translate(), MessageTypeDefOf.RejectInput); } - Messages.Message("SuccessfullyDepositedPaperclips".Translate(result), MessageTypeDefOf.PositiveEvent); } else { - Messages.Message("PRFNotEnoughPaperclips".Translate(), MessageTypeDefOf.RejectInput); - } - } - else - { - if (result < SelBuilding.PaperclipsActual) - { - List output = new List(); - int current = 0; - while (current < result) + if (result < SelBuilding.PaperclipsActual) { - int num = Math.Min(result - current, PRFDefOf.Paperclip.stackLimit); - Thing paperclip = ThingMaker.MakeThing(PRFDefOf.Paperclip); - paperclip.stackCount = num; - output.Add(paperclip); - current += num; + List output = new List(); + int current = 0; + while (current < result) + { + int num = Math.Min(result - current, PRFDefOf.Paperclip.stackLimit); + Thing paperclip = ThingMaker.MakeThing(PRFDefOf.Paperclip); + paperclip.stackCount = num; + output.Add(paperclip); + current += num; + } + for (int i = 0; i < output.Count; i++) + { + GenPlace.TryPlaceThing(output[i], SelBuilding.Position, SelBuilding.Map, ThingPlaceMode.Direct); + SelBuilding.boundStorageUnit.Notify_ReceivedThing(output[i]); + } + SelBuilding.WithdrawPaperclips(result); + Messages.Message("SuccessfullyWithdrawnPaperclips".Translate(result), MessageTypeDefOf.PositiveEvent); } - for (int i = 0; i < output.Count; i++) + else { - GenPlace.TryPlaceThing(output[i], SelBuilding.Position, SelBuilding.Map, ThingPlaceMode.Direct); - SelBuilding.boundStorageUnit.Notify_ReceivedThing(output[i]); + Messages.Message("PRFNotEnoughPaperclips".Translate(), MessageTypeDefOf.RejectInput); } - SelBuilding.WithdrawPaperclips(result); - Messages.Message("SuccessfullyWithdrawnPaperclips".Translate(result), MessageTypeDefOf.PositiveEvent); - } - else - { - Messages.Message("PRFNotEnoughPaperclips".Translate(), MessageTypeDefOf.RejectInput); } } + else + { + Messages.Message("PRFInputInvalid".Translate(), MessageTypeDefOf.RejectInput); + } } else {