private static void SyncedTakeItems(Outpost outpost, Caravan caravan, Dictionary <ThingDef, int> itemsToTransfer)
        {
            var dummyDialog = new Dialog_TakeItems(outpost, caravan);

            dummyDialog.CalculateAndRecacheTransferables();

            foreach (var transferable in dummyDialog.transferables)
            {
                if (transferable.HasAnyThing && itemsToTransfer.TryGetValue(transferable.ThingDef, out var count))
                {
                    transferable.ForceTo(count);
                }

                while (transferable.HasAnyThing && transferable.CountToTransfer > 0)
                {
                    var thing = transferable.things.Pop();

                    if (thing.stackCount <= transferable.CountToTransfer)
                    {
                        transferable.AdjustBy(-thing.stackCount);
                        caravan.AddPawnOrItem(thing, true);
                    }
                    else
                    {
                        caravan.AddPawnOrItem(thing.SplitOff(transferable.CountToTransfer), true);
                        transferable.AdjustTo(0);
                        transferable.things.Add(thing);
                    }
                }
            }
        }
        // Basically replace the original method with our own, that's basically the same
        // (with the main difference being how we are handling the button)
        private static bool PreDoBottomButtons(Rect rect, Dialog_TakeItems __instance)
        {
            var rect2 = new Rect(rect.width - __instance.BottomButtonSize.x, rect.height - 40f, __instance.BottomButtonSize.x, __instance.BottomButtonSize.y);

            if (Widgets.ButtonText(rect2, "Outposts.Take".Translate()))
            {
                var thingsToTransfer = __instance.transferables
                                       .Where(x => x.HasAnyThing && x.CountToTransfer > 0)
                                       .ToDictionary(x => x.ThingDef, x => x.CountToTransfer);

                SyncedTakeItems(__instance.outpost, __instance.caravan, thingsToTransfer);
                __instance.Close();
            }

            if (Widgets.ButtonText(new Rect(0f, rect2.y, __instance.BottomButtonSize.x, __instance.BottomButtonSize.y), "CancelButton".Translate()))
            {
                __instance.Close();
            }

            if (Widgets.ButtonText(new Rect(rect.width / 2f - __instance.BottomButtonSize.x, rect2.y, __instance.BottomButtonSize.x, __instance.BottomButtonSize.y), "ResetButton".Translate()))
            {
                SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                __instance.CalculateAndRecacheTransferables();
            }

            return(false);
        }