コード例 #1
0
ファイル: Dialog_FormCaravan.cs プロジェクト: potsh/RimWorld
        private bool TryFormAndSendCaravan()
        {
            List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(transferables);

            if (!CheckForErrors(pawnsFromTransferables))
            {
                return(false);
            }
            Direction8Way direction8WayFromTo = Find.WorldGrid.GetDirection8WayFromTo(CurrentTile, startingTile);

            if (!TryFindExitSpot(pawnsFromTransferables, reachableForEveryColonist: true, out IntVec3 spot))
            {
                if (!TryFindExitSpot(pawnsFromTransferables, reachableForEveryColonist: false, out spot))
                {
                    Messages.Message("CaravanCouldNotFindExitSpot".Translate(direction8WayFromTo.LabelShort()), MessageTypeDefOf.RejectInput, historical: false);
                    return(false);
                }
                Messages.Message("CaravanCouldNotFindReachableExitSpot".Translate(direction8WayFromTo.LabelShort()), new GlobalTargetInfo(spot, map), MessageTypeDefOf.CautionInput, historical: false);
            }
            if (!TryFindRandomPackingSpot(spot, out IntVec3 packingSpot))
            {
                Messages.Message("CaravanCouldNotFindPackingSpot".Translate(direction8WayFromTo.LabelShort()), new GlobalTargetInfo(spot, map), MessageTypeDefOf.RejectInput, historical: false);
                return(false);
            }
            CaravanFormingUtility.StartFormingCaravan((from x in pawnsFromTransferables
                                                       where !x.Downed
                                                       select x).ToList(), (from x in pawnsFromTransferables
                                                                            where x.Downed
                                                                            select x).ToList(), Faction.OfPlayer, transferables, packingSpot, spot, startingTile, destinationTile);
            Messages.Message("CaravanFormationProcessStarted".Translate(), pawnsFromTransferables[0], MessageTypeDefOf.PositiveEvent, historical: false);
            return(true);
        }
コード例 #2
0
        private bool TryReformCaravan()
        {
            List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(this.transferables);

            if (!this.CheckForErrors(pawnsFromTransferables))
            {
                return(false);
            }
            this.AddItemsFromTransferablesToRandomInventories(pawnsFromTransferables);
            Caravan caravan = CaravanExitMapUtility.ExitMapAndCreateCaravan(pawnsFromTransferables, Faction.OfPlayer, this.CurrentTile, this.CurrentTile, this.destinationTile, false);

            this.map.Parent.CheckRemoveMapNow();
            string text = "MessageReformedCaravan".Translate();

            if (caravan.pather.Moving && caravan.pather.ArrivalAction != null)
            {
                string text2 = text;
                text = string.Concat(new string[]
                {
                    text2,
                    " ",
                    "MessageFormedCaravan_Orders".Translate(),
                    ": ",
                    caravan.pather.ArrivalAction.Label,
                    "."
                });
            }
            Messages.Message(text, caravan, MessageTypeDefOf.TaskCompletion, false);
            return(true);
        }
コード例 #3
0
        private bool TryAccept()
        {
            List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(transferables);

            if (!CheckForErrors(pawnsFromTransferables))
            {
                return(false);
            }
            int transportersGroup = CreateAndAssignNewTransportersGroup();

            AssignTransferablesToRandomTransporters();
            IEnumerable <Pawn> enumerable = from x in pawnsFromTransferables
                                            where x.IsColonist && !x.Downed
                                            select x;

            if (enumerable.Any())
            {
                foreach (Pawn item in enumerable)
                {
                    item.GetLord()?.Notify_PawnLost(item, PawnLostCondition.ForcedToJoinOtherLord);
                }
                LordMaker.MakeNewLord(Faction.OfPlayer, new LordJob_LoadAndEnterTransporters(transportersGroup), map, enumerable);
                foreach (Pawn item2 in enumerable)
                {
                    if (item2.Spawned)
                    {
                        item2.jobs.EndCurrentJob(JobCondition.InterruptForced);
                    }
                }
            }
            Messages.Message("MessageTransportersLoadingProcessStarted".Translate(), transporters[0].parent, MessageTypeDefOf.TaskCompletion, historical: false);
            return(true);
        }
コード例 #4
0
        private bool TryFormAndSendCaravan()
        {
            List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(this.transferables);

            if (!this.CheckForErrors(pawnsFromTransferables))
            {
                return(false);
            }
            Direction8Way direction8WayFromTo = Find.WorldGrid.GetDirection8WayFromTo(this.CurrentTile, this.startingTile);
            IntVec3       intVec;

            if (!this.TryFindExitSpot(pawnsFromTransferables, true, out intVec))
            {
                if (!this.TryFindExitSpot(pawnsFromTransferables, false, out intVec))
                {
                    Messages.Message("CaravanCouldNotFindExitSpot".Translate(direction8WayFromTo.LabelShort()), MessageTypeDefOf.RejectInput, false);
                    return(false);
                }
                Messages.Message("CaravanCouldNotFindReachableExitSpot".Translate(direction8WayFromTo.LabelShort()), new GlobalTargetInfo(intVec, this.map, false), MessageTypeDefOf.CautionInput, false);
            }
            IntVec3 meetingPoint;

            if (!this.TryFindRandomPackingSpot(intVec, out meetingPoint))
            {
                Messages.Message("CaravanCouldNotFindPackingSpot".Translate(direction8WayFromTo.LabelShort()), new GlobalTargetInfo(intVec, this.map, false), MessageTypeDefOf.RejectInput, false);
                return(false);
            }
            CaravanFormingUtility.StartFormingCaravan((from x in pawnsFromTransferables
                                                       where !x.Downed
                                                       select x).ToList <Pawn>(), (from x in pawnsFromTransferables
                                                                                   where x.Downed
                                                                                   select x).ToList <Pawn>(), Faction.OfPlayer, this.transferables, meetingPoint, intVec, this.startingTile, this.destinationTile);
            Messages.Message("CaravanFormationProcessStarted".Translate(), pawnsFromTransferables[0], MessageTypeDefOf.PositiveEvent, false);
            return(true);
        }
コード例 #5
0
        private void DoBottomButtons(Rect rect)
        {
            Rect rect2 = new Rect(rect.width / 2f - BottomButtonSize.x / 2f, rect.height - 55f, BottomButtonSize.x, BottomButtonSize.y);

            if (Widgets.ButtonText(rect2, autoLoot ? "LoadSelected".Translate() : "AcceptButton".Translate()))
            {
                if (CaravanMassUsage > CaravanMassCapacity && CaravanMassCapacity != 0f)
                {
                    if (CheckForErrors(TransferableUtility.GetPawnsFromTransferables(transferables)))
                    {
                        Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("TransportersCaravanWillBeImmobile".Translate(), delegate
                        {
                            if (TryAccept())
                            {
                                if (autoLoot)
                                {
                                    LoadInstantly();
                                }
                                SoundDefOf.Tick_High.PlayOneShotOnCamera();
                                Close(doCloseSound: false);
                            }
                        }));
                    }
                }
                else if (TryAccept())
                {
                    if (autoLoot)
                    {
                        LoadInstantly();
                    }
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    Close(doCloseSound: false);
                }
            }
            if (Widgets.ButtonText(new Rect(rect2.x - 10f - BottomButtonSize.x, rect2.y, BottomButtonSize.x, BottomButtonSize.y), "ResetButton".Translate()))
            {
                SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                CalculateAndRecacheTransferables();
            }
            if (Widgets.ButtonText(new Rect(rect2.xMax + 10f, rect2.y, BottomButtonSize.x, BottomButtonSize.y), "CancelButton".Translate()))
            {
                Close();
            }
            if (Prefs.DevMode)
            {
                float width = 200f;
                float num   = BottomButtonSize.y / 2f;
                if (!LoadingInProgressOrReadyToLaunch && Widgets.ButtonText(new Rect(0f, rect.height - 55f, width, num), "Dev: Load instantly") && DebugTryLoadInstantly())
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    Close(doCloseSound: false);
                }
                if (Widgets.ButtonText(new Rect(0f, rect.height - 55f + num, width, num), "Dev: Select everything"))
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    SetToLoadEverything();
                }
            }
        }
コード例 #6
0
        private void DoBottomButtons(Rect rect)
        {
            Rect rect2 = new Rect(rect.width / 2f - this.BottomButtonSize.x / 2f, rect.height - 55f, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect2, "AcceptButton".Translate(), true, false, true))
            {
                if (this.CaravanMassUsage > this.CaravanMassCapacity && this.CaravanMassCapacity != 0f)
                {
                    if (this.CheckForErrors(TransferableUtility.GetPawnsFromTransferables(this.transferables)))
                    {
                        Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("TransportersCaravanWillBeImmobile".Translate(), delegate
                        {
                            if (this.TryAccept())
                            {
                                SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                                this.Close(false);
                            }
                        }, false, null));
                    }
                }
                else if (this.TryAccept())
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    this.Close(false);
                }
            }
            Rect rect3 = new Rect(rect2.x - 10f - this.BottomButtonSize.x, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect3, "ResetButton".Translate(), true, false, true))
            {
                SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                this.CalculateAndRecacheTransferables();
            }
            Rect rect4 = new Rect(rect2.xMax + 10f, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect4, "CancelButton".Translate(), true, false, true))
            {
                this.Close(true);
            }
            if (Prefs.DevMode)
            {
                float width = 200f;
                float num   = this.BottomButtonSize.y / 2f;
                Rect  rect5 = new Rect(0f, rect.height - 55f, width, num);
                if (Widgets.ButtonText(rect5, "Dev: Load instantly", true, false, true) && this.DebugTryLoadInstantly())
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    this.Close(false);
                }
                Rect rect6 = new Rect(0f, rect.height - 55f + num, width, num);
                if (Widgets.ButtonText(rect6, "Dev: Select everything", true, false, true))
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    this.SetToLoadEverything();
                }
            }
        }
コード例 #7
0
        private bool TryReformCaravan()
        {
            List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(this.transferables);

            if (!this.CheckForErrors(pawnsFromTransferables))
            {
                return(false);
            }
            this.AddItemsFromTransferablesToRandomInventories(pawnsFromTransferables);
            Caravan o = CaravanExitMapUtility.ExitMapAndCreateCaravan(pawnsFromTransferables, Faction.OfPlayer, this.CurrentTile);

            this.map.info.parent.CheckRemoveMapNow();
            Messages.Message("MessageReformedCaravan".Translate(), o, MessageSound.Benefit);
            return(true);
        }
コード例 #8
0
        private bool DebugTryFormCaravanInstantly()
        {
            List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(this.transferables);

            if (!pawnsFromTransferables.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer)))
            {
                Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), MessageSound.RejectInput);
                return(false);
            }
            this.AddItemsFromTransferablesToRandomInventories(pawnsFromTransferables);
            int currentTile = this.startingTile;

            if (currentTile < 0)
            {
                currentTile = this.CurrentTile;
            }
            CaravanFormingUtility.FormAndCreateCaravan(pawnsFromTransferables, Faction.OfPlayer, this.CurrentTile, currentTile);
            return(true);
        }
コード例 #9
0
        private bool TryReformCaravan()
        {
            List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(transferables);

            if (!CheckForErrors(pawnsFromTransferables))
            {
                return(false);
            }
            AddItemsFromTransferablesToRandomInventories(pawnsFromTransferables);
            Caravan caravan = CaravanExitMapUtility.ExitMapAndCreateCaravan(pawnsFromTransferables, Faction.OfPlayer, CurrentTile, CurrentTile, destinationTile, sendMessage: false);

            map.Parent.CheckRemoveMapNow();
            TaggedString taggedString = "MessageReformedCaravan".Translate();

            if (caravan.pather.Moving && caravan.pather.ArrivalAction != null)
            {
                taggedString += " " + "MessageFormedCaravan_Orders".Translate() + ": " + caravan.pather.ArrivalAction.Label + ".";
            }
            Messages.Message(taggedString, caravan, MessageTypeDefOf.TaskCompletion, historical: false);
            return(true);
        }
コード例 #10
0
        private bool TryAccept()
        {
            List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(this.transferables);
            bool        result;

            if (!this.CheckForErrors(pawnsFromTransferables))
            {
                result = false;
            }
            else
            {
                int transportersGroup = this.CreateAndAssignNewTransportersGroup();
                this.AssignTransferablesToRandomTransporters();
                IEnumerable <Pawn> enumerable = from x in pawnsFromTransferables
                                                where x.IsColonist && !x.Downed
                                                select x;
                if (enumerable.Any <Pawn>())
                {
                    foreach (Pawn pawn in enumerable)
                    {
                        Lord lord = pawn.GetLord();
                        if (lord != null)
                        {
                            lord.Notify_PawnLost(pawn, PawnLostCondition.ForcedToJoinOtherLord);
                        }
                    }
                    LordMaker.MakeNewLord(Faction.OfPlayer, new LordJob_LoadAndEnterTransporters(transportersGroup), this.map, enumerable);
                    foreach (Pawn pawn2 in enumerable)
                    {
                        if (pawn2.Spawned)
                        {
                            pawn2.jobs.EndCurrentJob(JobCondition.InterruptForced, true);
                        }
                    }
                }
                Messages.Message("MessageTransportersLoadingProcessStarted".Translate(), this.transporters[0].parent, MessageTypeDefOf.TaskCompletion, false);
                result = true;
            }
            return(result);
        }
コード例 #11
0
        private bool TryFormAndSendCaravan()
        {
            List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(this.transferables);

            if (!this.CheckForErrors(pawnsFromTransferables))
            {
                return(false);
            }
            Direction8Way direction8WayFromTo = Find.WorldGrid.GetDirection8WayFromTo(this.CurrentTile, this.startingTile);
            IntVec3       intVec;

            if (!this.TryFindExitSpot(pawnsFromTransferables, true, out intVec))
            {
                if (!this.TryFindExitSpot(pawnsFromTransferables, false, out intVec))
                {
                    Messages.Message("CaravanCouldNotFindExitSpot".Translate(new object[]
                    {
                        direction8WayFromTo.LabelShort()
                    }), MessageSound.RejectInput);
                    return(false);
                }
                Messages.Message("CaravanCouldNotFindReachableExitSpot".Translate(new object[]
                {
                    direction8WayFromTo.LabelShort()
                }), new GlobalTargetInfo(intVec, this.map, false), MessageSound.Negative);
            }
            IntVec3 meetingPoint;

            if (!this.TryFindRandomPackingSpot(intVec, out meetingPoint))
            {
                Messages.Message("CaravanCouldNotFindPackingSpot".Translate(new object[]
                {
                    direction8WayFromTo.LabelShort()
                }), new GlobalTargetInfo(intVec, this.map, false), MessageSound.RejectInput);
                return(false);
            }
            CaravanFormingUtility.StartFormingCaravan(pawnsFromTransferables, Faction.OfPlayer, this.transferables, meetingPoint, intVec, this.startingTile);
            Messages.Message("CaravanFormationProcessStarted".Translate(), pawnsFromTransferables[0], MessageSound.Benefit);
            return(true);
        }
コード例 #12
0
        private bool DebugTryFormCaravanInstantly()
        {
            List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(this.transferables);

            if (!pawnsFromTransferables.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer)))
            {
                Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), MessageTypeDefOf.RejectInput, false);
                return(false);
            }
            this.AddItemsFromTransferablesToRandomInventories(pawnsFromTransferables);
            int num = this.startingTile;

            if (num < 0)
            {
                num = CaravanExitMapUtility.RandomBestExitTileFrom(this.map);
            }
            if (num < 0)
            {
                num = this.CurrentTile;
            }
            CaravanFormingUtility.FormAndCreateCaravan(pawnsFromTransferables, Faction.OfPlayer, this.CurrentTile, num, this.destinationTile);
            return(true);
        }
コード例 #13
0
        private bool TryAccept()
        {
            List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(transferables);

            if (!CheckForErrors(pawnsFromTransferables))
            {
                return(false);
            }
            if (LoadingInProgressOrReadyToLaunch)
            {
                AssignTransferablesToRandomTransporters();
                TransporterUtility.MakeLordsAsAppropriate(pawnsFromTransferables, transporters, map);
                List <Pawn> allPawnsSpawned = map.mapPawns.AllPawnsSpawned;
                for (int i = 0; i < allPawnsSpawned.Count; i++)
                {
                    if (allPawnsSpawned[i].CurJobDef == JobDefOf.HaulToTransporter && transporters.Contains(((JobDriver_HaulToTransporter)allPawnsSpawned[i].jobs.curDriver).Transporter))
                    {
                        allPawnsSpawned[i].jobs.EndCurrentJob(JobCondition.InterruptForced);
                    }
                }
            }
            else
            {
                TransporterUtility.InitiateLoading(transporters);
                AssignTransferablesToRandomTransporters();
                TransporterUtility.MakeLordsAsAppropriate(pawnsFromTransferables, transporters, map);
                if (transporters[0].Props.max1PerGroup)
                {
                    Messages.Message("MessageTransporterSingleLoadingProcessStarted".Translate(), transporters[0].parent, MessageTypeDefOf.TaskCompletion, historical: false);
                }
                else
                {
                    Messages.Message("MessageTransportersLoadingProcessStarted".Translate(), transporters[0].parent, MessageTypeDefOf.TaskCompletion, historical: false);
                }
            }
            return(true);
        }
コード例 #14
0
        private void DoBottomButtons(Rect rect)
        {
            Rect rect2 = new Rect(rect.width / 2f - this.BottomButtonSize.x / 2f, rect.height - 55f - 17f, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect2, "AcceptButton".Translate(), true, false, true))
            {
                if (this.reform)
                {
                    if (this.TryReformCaravan())
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                        this.Close(false);
                    }
                }
                else
                {
                    List <string>       list            = new List <string>();
                    Pair <float, float> daysWorthOfFood = this.DaysWorthOfFood;
                    if (daysWorthOfFood.First < 5f)
                    {
                        list.Add((daysWorthOfFood.First >= 0.1f) ? "DaysWorthOfFoodWarningDialog".Translate(daysWorthOfFood.First.ToString("0.#")) : "DaysWorthOfFoodWarningDialog_NoFood".Translate());
                    }
                    else if (this.MostFoodWillRotSoon)
                    {
                        list.Add("CaravanFoodWillRotSoonWarningDialog".Translate());
                    }
                    if (!TransferableUtility.GetPawnsFromTransferables(this.transferables).Any((Pawn pawn) => CaravanUtility.IsOwner(pawn, Faction.OfPlayer) && !pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled))
                    {
                        list.Add("CaravanIncapableOfSocial".Translate());
                    }
                    if (list.Count > 0)
                    {
                        if (this.CheckForErrors(TransferableUtility.GetPawnsFromTransferables(this.transferables)))
                        {
                            string text = string.Concat((from str in list
                                                         select str + "\n\n").ToArray <string>()) + "CaravanAreYouSure".Translate();
                            Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(text, delegate
                            {
                                if (this.TryFormAndSendCaravan())
                                {
                                    this.Close(false);
                                }
                            }, false, null));
                        }
                    }
                    else if (this.TryFormAndSendCaravan())
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                        this.Close(false);
                    }
                }
            }
            Rect rect3 = new Rect(rect2.x - 10f - this.BottomButtonSize.x, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect3, "ResetButton".Translate(), true, false, true))
            {
                SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                this.CalculateAndRecacheTransferables();
            }
            if (this.ShowCancelButton)
            {
                Rect rect4 = new Rect(rect2.xMax + 10f, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);
                if (Widgets.ButtonText(rect4, "CancelButton".Translate(), true, false, true))
                {
                    this.Close(true);
                }
            }
            if (this.canChooseRoute)
            {
                Rect rect5 = new Rect(rect.width - this.BottomButtonSize.x, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);
                if (Widgets.ButtonText(rect5, "ChooseRouteButton".Translate(), true, false, true))
                {
                    List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(this.transferables);
                    if (!pawnsFromTransferables.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed))
                    {
                        Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), MessageTypeDefOf.RejectInput, false);
                    }
                    else
                    {
                        Find.WorldRoutePlanner.Start(this);
                    }
                }
                if (this.destinationTile != -1)
                {
                    Rect rect6 = rect5;
                    rect6.y     += rect5.height + 4f;
                    rect6.height = 200f;
                    rect6.xMin  -= 200f;
                    Text.Anchor  = TextAnchor.UpperRight;
                    Widgets.Label(rect6, "CaravanEstimatedDaysToDestination".Translate(((float)this.TicksToArrive / 60000f).ToString("0.#")));
                    Text.Anchor = TextAnchor.UpperLeft;
                }
            }
            if (Prefs.DevMode)
            {
                float width = 200f;
                float num   = this.BottomButtonSize.y / 2f;
                Rect  rect7 = new Rect(0f, rect.height - 55f - 17f, width, num);
                if (Widgets.ButtonText(rect7, "Dev: Send instantly", true, false, true) && this.DebugTryFormCaravanInstantly())
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    this.Close(false);
                }
                Rect rect8 = new Rect(0f, rect.height - 55f - 17f + num, width, num);
                if (Widgets.ButtonText(rect8, "Dev: Select everything", true, false, true))
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    this.SetToSendEverything();
                }
            }
        }
コード例 #15
0
        private void DoBottomButtons(Rect rect)
        {
            float   num = rect.width / 2f;
            Vector2 bottomButtonSize = BottomButtonSize;
            float   x = num - bottomButtonSize.x / 2f;
            float   y = rect.height - 55f;
            Vector2 bottomButtonSize2 = BottomButtonSize;
            float   x2 = bottomButtonSize2.x;
            Vector2 bottomButtonSize3 = BottomButtonSize;
            Rect    rect2             = new Rect(x, y, x2, bottomButtonSize3.y);

            if (Widgets.ButtonText(rect2, "AcceptButton".Translate()))
            {
                if (CaravanMassUsage > CaravanMassCapacity && CaravanMassCapacity != 0f)
                {
                    if (CheckForErrors(TransferableUtility.GetPawnsFromTransferables(transferables)))
                    {
                        Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("TransportersCaravanWillBeImmobile".Translate(), delegate
                        {
                            if (TryAccept())
                            {
                                SoundDefOf.Tick_High.PlayOneShotOnCamera();
                                Close(doCloseSound: false);
                            }
                        }));
                    }
                }
                else if (TryAccept())
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    Close(doCloseSound: false);
                }
            }
            float   num2 = rect2.x - 10f;
            Vector2 bottomButtonSize4 = BottomButtonSize;
            float   x3 = num2 - bottomButtonSize4.x;
            float   y2 = rect2.y;
            Vector2 bottomButtonSize5 = BottomButtonSize;
            float   x4 = bottomButtonSize5.x;
            Vector2 bottomButtonSize6 = BottomButtonSize;
            Rect    rect3             = new Rect(x3, y2, x4, bottomButtonSize6.y);

            if (Widgets.ButtonText(rect3, "ResetButton".Translate()))
            {
                SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                CalculateAndRecacheTransferables();
            }
            float   x5 = rect2.xMax + 10f;
            float   y3 = rect2.y;
            Vector2 bottomButtonSize7 = BottomButtonSize;
            float   x6 = bottomButtonSize7.x;
            Vector2 bottomButtonSize8 = BottomButtonSize;
            Rect    rect4             = new Rect(x5, y3, x6, bottomButtonSize8.y);

            if (Widgets.ButtonText(rect4, "CancelButton".Translate()))
            {
                Close();
            }
            if (Prefs.DevMode)
            {
                float   width             = 200f;
                Vector2 bottomButtonSize9 = BottomButtonSize;
                float   num3  = bottomButtonSize9.y / 2f;
                Rect    rect5 = new Rect(0f, rect.height - 55f, width, num3);
                if (Widgets.ButtonText(rect5, "Dev: Load instantly") && DebugTryLoadInstantly())
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    Close(doCloseSound: false);
                }
                Rect rect6 = new Rect(0f, rect.height - 55f + num3, width, num3);
                if (Widgets.ButtonText(rect6, "Dev: Select everything"))
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    SetToLoadEverything();
                }
            }
        }
コード例 #16
0
        private void DoBottomButtons(Rect rect)
        {
            Rect rect2 = new Rect(rect.width / 2f - this.BottomButtonSize.x / 2f, rect.height - 55f, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect2, "AcceptButton".Translate(), true, false, true))
            {
                if (this.reform)
                {
                    if (this.TryReformCaravan())
                    {
                        SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                        this.Close(false);
                    }
                }
                else
                {
                    string text = null;
                    Pair <float, float> daysWorthOfFood = this.DaysWorthOfFood;
                    if (daysWorthOfFood.First < 5f)
                    {
                        text = ((daysWorthOfFood.First >= 0.1f) ? "DaysWorthOfFoodWarningDialog".Translate(new object[]
                        {
                            daysWorthOfFood.First.ToString("0.#")
                        }) : "DaysWorthOfFoodWarningDialog_NoFood".Translate());
                    }
                    else if (this.MostFoodWillRotSoon)
                    {
                        text = "CaravanFoodWillRotSoonWarningDialog".Translate();
                    }
                    if (!text.NullOrEmpty())
                    {
                        if (this.CheckForErrors(TransferableUtility.GetPawnsFromTransferables(this.transferables)))
                        {
                            Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(text, delegate
                            {
                                if (this.TryFormAndSendCaravan())
                                {
                                    this.Close(false);
                                }
                            }, false, null));
                        }
                    }
                    else if (this.TryFormAndSendCaravan())
                    {
                        SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                        this.Close(false);
                    }
                }
            }
            Rect rect3 = new Rect(rect2.x - 10f - this.BottomButtonSize.x, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect3, "ResetButton".Translate(), true, false, true))
            {
                SoundDefOf.TickLow.PlayOneShotOnCamera(null);
                this.CalculateAndRecacheTransferables();
            }
            Rect rect4 = new Rect(rect2.xMax + 10f, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect4, "CancelButton".Translate(), true, false, true))
            {
                this.Close(true);
            }
            if (this.showEstTimeToDestinationButton)
            {
                Rect rect5 = new Rect(rect.width - this.BottomButtonSize.x, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);
                if (Widgets.ButtonText(rect5, "EstimatedTimeToDestinationButton".Translate(), true, false, true))
                {
                    List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(this.transferables);
                    if (!pawnsFromTransferables.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed))
                    {
                        Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), MessageSound.RejectInput);
                    }
                    else
                    {
                        Find.WorldRoutePlanner.Start(this);
                    }
                }
            }
            if (Prefs.DevMode)
            {
                float width = 200f;
                float num   = this.BottomButtonSize.y / 2f;
                Rect  rect6 = new Rect(0f, rect.height - 55f, width, num);
                if (Widgets.ButtonText(rect6, "Dev: Send instantly", true, false, true) && this.DebugTryFormCaravanInstantly())
                {
                    SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                    this.Close(false);
                }
                Rect rect7 = new Rect(0f, rect.height - 55f + num, width, num);
                if (Widgets.ButtonText(rect7, "Dev: Select everything", true, false, true))
                {
                    SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                    this.SetToSendEverything();
                }
            }
        }
コード例 #17
0
        private void DoBottomButtons(Rect rect)
        {
            Rect rect2 = new Rect(rect.width - BottomButtonSize.x, rect.height - 55f - 17f, BottomButtonSize.x, BottomButtonSize.y);

            if (Widgets.ButtonText(rect2, "Send".Translate()))
            {
                if (reform)
                {
                    if (TryReformCaravan())
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera();
                        Close(doCloseSound: false);
                    }
                }
                else
                {
                    List <string>       list            = new List <string>();
                    Pair <float, float> daysWorthOfFood = DaysWorthOfFood;
                    if (daysWorthOfFood.First < 5f)
                    {
                        list.Add((daysWorthOfFood.First < 0.1f) ? "DaysWorthOfFoodWarningDialog_NoFood".Translate() : "DaysWorthOfFoodWarningDialog".Translate(daysWorthOfFood.First.ToString("0.#")));
                    }
                    else if (MostFoodWillRotSoon)
                    {
                        list.Add("CaravanFoodWillRotSoonWarningDialog".Translate());
                    }
                    if (!TransferableUtility.GetPawnsFromTransferables(transferables).Any((Pawn pawn) => CaravanUtility.IsOwner(pawn, Faction.OfPlayer) && !pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled))
                    {
                        list.Add("CaravanIncapableOfSocial".Translate());
                    }
                    if (list.Count > 0)
                    {
                        if (CheckForErrors(TransferableUtility.GetPawnsFromTransferables(transferables)))
                        {
                            string str2 = string.Concat(list.Select((string str) => str + "\n\n").ToArray()) + "CaravanAreYouSure".Translate();
                            Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(str2, delegate
                            {
                                if (TryFormAndSendCaravan())
                                {
                                    Close(doCloseSound: false);
                                }
                            }));
                        }
                    }
                    else if (TryFormAndSendCaravan())
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera();
                        Close(doCloseSound: false);
                    }
                }
            }
            if (ShowCancelButton && Widgets.ButtonText(new Rect(0f, rect2.y, BottomButtonSize.x, BottomButtonSize.y), "CancelButton".Translate()))
            {
                Close();
            }
            if (Widgets.ButtonText(new Rect(rect.width / 2f - BottomButtonSize.x - 8.5f, rect2.y, BottomButtonSize.x, BottomButtonSize.y), "ResetButton".Translate()))
            {
                SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                CalculateAndRecacheTransferables();
            }
            if (canChooseRoute)
            {
                if (Widgets.ButtonText(new Rect(rect.width / 2f + 8.5f, rect2.y, BottomButtonSize.x, BottomButtonSize.y), "ChangeRouteButton".Translate()))
                {
                    soundClose.PlayOneShotOnCamera();
                    Find.WorldRoutePlanner.Start(this);
                }
                if (destinationTile != -1)
                {
                    Rect rect3 = rect2;
                    rect3.y     += rect2.height + 4f;
                    rect3.height = 200f;
                    rect3.xMin  -= 200f;
                    Text.Anchor  = TextAnchor.UpperRight;
                    Widgets.Label(rect3, "CaravanEstimatedDaysToDestination".Translate(((float)TicksToArrive / 60000f).ToString("0.#")));
                    Text.Anchor = TextAnchor.UpperLeft;
                }
            }
            if (Prefs.DevMode)
            {
                float width  = 200f;
                float height = BottomButtonSize.y / 2f;
                if (Widgets.ButtonText(new Rect(0f, rect2.yMax + 4f, width, height), "Dev: Send instantly") && DebugTryFormCaravanInstantly())
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    Close(doCloseSound: false);
                }
                if (Widgets.ButtonText(new Rect(204f, rect2.yMax + 4f, width, height), "Dev: Select everything"))
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    SetToSendEverything();
                }
            }
        }
コード例 #18
0
        private void SelectApproximateBestFoodAndMedicine()
        {
            IEnumerable <TransferableOneWay> enumerable  = transferables.Where((TransferableOneWay x) => x.ThingDef.category != ThingCategory.Pawn && !x.ThingDef.thingCategories.NullOrEmpty() && x.ThingDef.thingCategories.Contains(ThingCategoryDefOf.Medicine));
            IEnumerable <TransferableOneWay> enumerable2 = transferables.Where((TransferableOneWay x) => x.ThingDef.IsIngestible && !x.ThingDef.IsDrug && !x.ThingDef.IsCorpse);

            tmpBeds.Clear();
            for (int i = 0; i < transferables.Count; i++)
            {
                for (int j = 0; j < transferables[i].things.Count; j++)
                {
                    Thing thing = transferables[i].things[j];
                    for (int k = 0; k < thing.stackCount; k++)
                    {
                        Building_Bed building_Bed;
                        if ((building_Bed = thing.GetInnerIfMinified() as Building_Bed) != null && building_Bed.def.building.bed_caravansCanUse)
                        {
                            for (int l = 0; l < building_Bed.SleepingSlotsCount; l++)
                            {
                                tmpBeds.Add(transferables[i]);
                            }
                        }
                    }
                }
            }
            tmpBeds.SortByDescending((TransferableOneWay x) => x.AnyThing.GetStatValue(StatDefOf.BedRestEffectiveness));
            foreach (TransferableOneWay item in enumerable)
            {
                item.AdjustTo(0);
            }
            foreach (TransferableOneWay item2 in enumerable2)
            {
                item2.AdjustTo(0);
            }
            foreach (TransferableOneWay tmpBed in tmpBeds)
            {
                tmpBed.AdjustTo(0);
            }
            List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(transferables);

            if (!pawnsFromTransferables.Any())
            {
                return;
            }
            foreach (Pawn item3 in pawnsFromTransferables)
            {
                TransferableOneWay transferableOneWay = BestBedFor(item3);
                if (transferableOneWay != null)
                {
                    tmpBeds.Remove(transferableOneWay);
                    if (transferableOneWay.CanAdjustBy(1).Accepted)
                    {
                        AddOneIfMassAllows(transferableOneWay);
                    }
                }
                if (item3.AnimalOrWildMan() || item3.guest.IsPrisoner)
                {
                    continue;
                }
                for (int m = 0; m < 2; m++)
                {
                    Transferable transferable = BestMedicineItemFor(item3, enumerable);
                    if (transferable != null)
                    {
                        AddOneIfMassAllows(transferable);
                    }
                }
            }
            if (destinationTile == -1 || !DaysWorthOfFoodCalculator.AnyFoodEatingPawn(pawnsFromTransferables) || !enumerable2.Any())
            {
                return;
            }
            try
            {
                using WorldPath path = Find.WorldPathFinder.FindPath(CurrentTile, destinationTile, null);
                int ticksPerMove = CaravanTicksPerMoveUtility.GetTicksPerMove(new CaravanTicksPerMoveUtility.CaravanInfo(this));
                CaravanArrivalTimeEstimator.EstimatedTicksToArriveToEvery(CurrentTile, destinationTile, path, 0f, ticksPerMove, Find.TickManager.TicksAbs, tmpTicksToArrive);
                float num = (float)tmpTicksToArrive.Last().Second / 60000f + 4f;
                float num2;
                bool  flag;
                do
                {
                    num2 = DaysWorthOfFoodCalculator.ApproxDaysWorthOfFood(transferables, CurrentTile, IgnoreInventoryMode, Faction.OfPlayer, path, 0f, ticksPerMove);
                    if (num2 >= num)
                    {
                        break;
                    }
                    flag = false;
                    foreach (Pawn item4 in pawnsFromTransferables)
                    {
                        Transferable transferable2 = BestFoodItemFor(item4, enumerable2, tmpTicksToArrive);
                        if (transferable2 != null && AddOneIfMassAllows(transferable2))
                        {
                            flag = true;
                        }
                    }
                }while (flag && num2 < num && MassUsage < MassCapacity);
            }
            finally
            {
                tmpTicksToArrive.Clear();
                daysWorthOfFoodDirty = true;
                massUsageDirty       = true;
            }
        }
コード例 #19
0
ファイル: Dialog_FormCaravan.cs プロジェクト: potsh/RimWorld
        private void DoBottomButtons(Rect rect)
        {
            float   num = rect.width / 2f;
            Vector2 bottomButtonSize = BottomButtonSize;
            float   x2 = num - bottomButtonSize.x / 2f;
            float   y  = rect.height - 55f - 17f;
            Vector2 bottomButtonSize2 = BottomButtonSize;
            float   x3 = bottomButtonSize2.x;
            Vector2 bottomButtonSize3 = BottomButtonSize;
            Rect    rect2             = new Rect(x2, y, x3, bottomButtonSize3.y);

            if (Widgets.ButtonText(rect2, "AcceptButton".Translate()))
            {
                if (reform)
                {
                    if (TryReformCaravan())
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera();
                        Close(doCloseSound: false);
                    }
                }
                else
                {
                    List <string>       list            = new List <string>();
                    Pair <float, float> daysWorthOfFood = DaysWorthOfFood;
                    if (daysWorthOfFood.First < 5f)
                    {
                        list.Add((!(daysWorthOfFood.First < 0.1f)) ? "DaysWorthOfFoodWarningDialog".Translate(daysWorthOfFood.First.ToString("0.#")) : "DaysWorthOfFoodWarningDialog_NoFood".Translate());
                    }
                    else if (MostFoodWillRotSoon)
                    {
                        list.Add("CaravanFoodWillRotSoonWarningDialog".Translate());
                    }
                    if (!TransferableUtility.GetPawnsFromTransferables(transferables).Any((Pawn pawn) => CaravanUtility.IsOwner(pawn, Faction.OfPlayer) && !pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled))
                    {
                        list.Add("CaravanIncapableOfSocial".Translate());
                    }
                    if (list.Count > 0)
                    {
                        if (CheckForErrors(TransferableUtility.GetPawnsFromTransferables(transferables)))
                        {
                            string text = string.Concat((from str in list
                                                         select str + "\n\n").ToArray()) + "CaravanAreYouSure".Translate();
                            Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(text, delegate
                            {
                                if (TryFormAndSendCaravan())
                                {
                                    Close(doCloseSound: false);
                                }
                            }));
                        }
                    }
                    else if (TryFormAndSendCaravan())
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera();
                        Close(doCloseSound: false);
                    }
                }
            }
            float   num2 = rect2.x - 10f;
            Vector2 bottomButtonSize4 = BottomButtonSize;
            float   x4 = num2 - bottomButtonSize4.x;
            float   y2 = rect2.y;
            Vector2 bottomButtonSize5 = BottomButtonSize;
            float   x5 = bottomButtonSize5.x;
            Vector2 bottomButtonSize6 = BottomButtonSize;
            Rect    rect3             = new Rect(x4, y2, x5, bottomButtonSize6.y);

            if (Widgets.ButtonText(rect3, "ResetButton".Translate()))
            {
                SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                CalculateAndRecacheTransferables();
            }
            if (ShowCancelButton)
            {
                float   x6 = rect2.xMax + 10f;
                float   y3 = rect2.y;
                Vector2 bottomButtonSize7 = BottomButtonSize;
                float   x7 = bottomButtonSize7.x;
                Vector2 bottomButtonSize8 = BottomButtonSize;
                Rect    rect4             = new Rect(x6, y3, x7, bottomButtonSize8.y);
                if (Widgets.ButtonText(rect4, "CancelButton".Translate()))
                {
                    Close();
                }
            }
            if (canChooseRoute)
            {
                float   width             = rect.width;
                Vector2 bottomButtonSize9 = BottomButtonSize;
                float   x8 = width - bottomButtonSize9.x;
                float   y4 = rect2.y;
                Vector2 bottomButtonSize10 = BottomButtonSize;
                float   x9 = bottomButtonSize10.x;
                Vector2 bottomButtonSize11 = BottomButtonSize;
                Rect    rect5 = new Rect(x8, y4, x9, bottomButtonSize11.y);
                if (Widgets.ButtonText(rect5, "ChooseRouteButton".Translate()))
                {
                    List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(transferables);
                    if (!pawnsFromTransferables.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed))
                    {
                        Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), MessageTypeDefOf.RejectInput, historical: false);
                    }
                    else
                    {
                        Find.WorldRoutePlanner.Start(this);
                    }
                }
                if (destinationTile != -1)
                {
                    Rect rect6 = rect5;
                    rect6.y     += rect5.height + 4f;
                    rect6.height = 200f;
                    rect6.xMin  -= 200f;
                    Text.Anchor  = TextAnchor.UpperRight;
                    Widgets.Label(rect6, "CaravanEstimatedDaysToDestination".Translate(((float)TicksToArrive / 60000f).ToString("0.#")));
                    Text.Anchor = TextAnchor.UpperLeft;
                }
            }
            if (Prefs.DevMode)
            {
                float   width2             = 200f;
                Vector2 bottomButtonSize12 = BottomButtonSize;
                float   num3  = bottomButtonSize12.y / 2f;
                Rect    rect7 = new Rect(0f, rect.height - 55f - 17f, width2, num3);
                if (Widgets.ButtonText(rect7, "Dev: Send instantly") && DebugTryFormCaravanInstantly())
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    Close(doCloseSound: false);
                }
                Rect rect8 = new Rect(0f, rect.height - 55f - 17f + num3, width2, num3);
                if (Widgets.ButtonText(rect8, "Dev: Select everything"))
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    SetToSendEverything();
                }
            }
        }
コード例 #20
0
        private void DoBottomButtons(Rect rect)
        {
            double  num = rect.width / 2.0;
            Vector2 bottomButtonSize = this.BottomButtonSize;
            double  x2 = num - bottomButtonSize.x / 2.0;
            double  y  = rect.height - 55.0;
            Vector2 bottomButtonSize2 = this.BottomButtonSize;
            float   x3 = bottomButtonSize2.x;
            Vector2 bottomButtonSize3 = this.BottomButtonSize;
            Rect    rect2             = new Rect((float)x2, (float)y, x3, bottomButtonSize3.y);

            if (Widgets.ButtonText(rect2, "AcceptButton".Translate(), true, false, true))
            {
                if (this.reform)
                {
                    if (this.TryReformCaravan())
                    {
                        SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                        this.Close(false);
                    }
                }
                else
                {
                    List <string>       list            = new List <string>();
                    Pair <float, float> daysWorthOfFood = this.DaysWorthOfFood;
                    if (daysWorthOfFood.First < 5.0)
                    {
                        list.Add((!(daysWorthOfFood.First < 0.10000000149011612)) ? "DaysWorthOfFoodWarningDialog".Translate(daysWorthOfFood.First.ToString("0.#")) : "DaysWorthOfFoodWarningDialog_NoFood".Translate());
                    }
                    else if (this.MostFoodWillRotSoon)
                    {
                        list.Add("CaravanFoodWillRotSoonWarningDialog".Translate());
                    }
                    if (!TransferableUtility.GetPawnsFromTransferables(this.transferables).Any((Pawn pawn) => CaravanUtility.IsOwner(pawn, Faction.OfPlayer) && !pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled))
                    {
                        list.Add("CaravanIncapableOfSocial".Translate());
                    }
                    if (list.Count > 0)
                    {
                        if (this.CheckForErrors(TransferableUtility.GetPawnsFromTransferables(this.transferables)))
                        {
                            string text = string.Concat((from str in list
                                                         select str + "\n\n").ToArray()) + "CaravanAreYouSure".Translate();
                            Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(text, delegate
                            {
                                if (this.TryFormAndSendCaravan())
                                {
                                    this.Close(false);
                                }
                            }, false, null));
                        }
                    }
                    else if (this.TryFormAndSendCaravan())
                    {
                        SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                        this.Close(false);
                    }
                }
            }
            double  num2 = rect2.x - 10.0;
            Vector2 bottomButtonSize4 = this.BottomButtonSize;
            double  x4 = num2 - bottomButtonSize4.x;
            float   y2 = rect2.y;
            Vector2 bottomButtonSize5 = this.BottomButtonSize;
            float   x5 = bottomButtonSize5.x;
            Vector2 bottomButtonSize6 = this.BottomButtonSize;
            Rect    rect3             = new Rect((float)x4, y2, x5, bottomButtonSize6.y);

            if (Widgets.ButtonText(rect3, "ResetButton".Translate(), true, false, true))
            {
                SoundDefOf.TickLow.PlayOneShotOnCamera(null);
                this.CalculateAndRecacheTransferables();
            }
            double  x6 = rect2.xMax + 10.0;
            float   y3 = rect2.y;
            Vector2 bottomButtonSize7 = this.BottomButtonSize;
            float   x7 = bottomButtonSize7.x;
            Vector2 bottomButtonSize8 = this.BottomButtonSize;
            Rect    rect4             = new Rect((float)x6, y3, x7, bottomButtonSize8.y);

            if (Widgets.ButtonText(rect4, (!this.cancellingWillAbandon) ? "CancelButton".Translate() : "AbandonButton".Translate(), true, false, true))
            {
                this.Close(true);
            }
            if (this.showEstTimeToDestinationButton)
            {
                float   width             = rect.width;
                Vector2 bottomButtonSize9 = this.BottomButtonSize;
                float   x8 = width - bottomButtonSize9.x;
                float   y4 = rect2.y;
                Vector2 bottomButtonSize10 = this.BottomButtonSize;
                float   x9 = bottomButtonSize10.x;
                Vector2 bottomButtonSize11 = this.BottomButtonSize;
                Rect    rect5 = new Rect(x8, y4, x9, bottomButtonSize11.y);
                if (Widgets.ButtonText(rect5, "EstimatedTimeToDestinationButton".Translate(), true, false, true))
                {
                    List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(this.transferables);
                    if (!pawnsFromTransferables.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed))
                    {
                        Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), MessageTypeDefOf.RejectInput);
                    }
                    else
                    {
                        Find.WorldRoutePlanner.Start(this);
                    }
                }
            }
            if (Prefs.DevMode)
            {
                float   width2             = 200f;
                Vector2 bottomButtonSize12 = this.BottomButtonSize;
                float   num3  = (float)(bottomButtonSize12.y / 2.0);
                Rect    rect6 = new Rect(0f, (float)(rect.height - 55.0), width2, num3);
                if (Widgets.ButtonText(rect6, "Dev: Send instantly", true, false, true) && this.DebugTryFormCaravanInstantly())
                {
                    SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                    this.Close(false);
                }
                Rect rect7 = new Rect(0f, (float)(rect.height - 55.0 + num3), width2, num3);
                if (Widgets.ButtonText(rect7, "Dev: Select everything", true, false, true))
                {
                    SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                    this.SetToSendEverything();
                }
            }
        }