public static Pawn GetPawnToFollow(Pawn forPawn) { if (!forPawn.RaceProps.packAnimal || forPawn.inventory.UnloadEverything || MassUtility.IsOverEncumbered(forPawn)) { return(null); } Lord lord = forPawn.GetLord(); if (lord == null) { return(null); } List <Pawn> ownedPawns = lord.ownedPawns; for (int i = 0; i < ownedPawns.Count; i++) { Pawn pawn = ownedPawns[i]; if (pawn != forPawn && CaravanUtility.IsOwner(pawn, forPawn.Faction) && pawn.CurJob != null && pawn.CurJob.def == JobDefOf.PrepareCaravan_GatherItems && forPawn.CanReach(pawn, PathEndMode.Touch, Danger.Deadly) && ((JobDriver_PrepareCaravan_GatherItems)pawn.jobs.curDriver).Carrier == forPawn) { return(pawn); } } Pawn pawn2 = null; for (int j = 0; j < ownedPawns.Count; j++) { Pawn pawn3 = ownedPawns[j]; if (pawn3 != forPawn && CaravanUtility.IsOwner(pawn3, forPawn.Faction) && pawn3.CurJob != null && pawn3.CurJob.def == JobDefOf.PrepareCaravan_GatherItems && forPawn.CanReach(pawn3, PathEndMode.Touch, Danger.Deadly) && (pawn2 == null || forPawn.Position.DistanceToSquared(pawn3.Position) < forPawn.Position.DistanceToSquared(pawn2.Position))) { pawn2 = pawn3; } } return(pawn2); }
private static void ForceReform(MapParent mapParent) { if (Dialog_FormCaravan.AllSendablePawns(mapParent.Map, reform: true).Any((Pawn x) => x.IsColonist)) { Messages.Message("MessageYouHaveToReformCaravanNow".Translate(), new GlobalTargetInfo(mapParent.Tile), MessageTypeDefOf.NeutralEvent); Current.Game.CurrentMap = mapParent.Map; Dialog_FormCaravan window = new Dialog_FormCaravan(mapParent.Map, reform: true, delegate { if (mapParent.HasMap) { mapParent.Destroy(); } }, mapAboutToBeRemoved: true); Find.WindowStack.Add(window); return; } List <Pawn> tmpPawns = new List <Pawn>(); tmpPawns.AddRange(mapParent.Map.mapPawns.AllPawns.Where((Pawn x) => x.Faction == Faction.OfPlayer || x.HostFaction == Faction.OfPlayer)); if (tmpPawns.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer))) { CaravanExitMapUtility.ExitMapAndCreateCaravan(tmpPawns, Faction.OfPlayer, mapParent.Tile, mapParent.Tile, -1); } tmpPawns.Clear(); mapParent.Destroy(); }
public static void ForceReform(MapParent mapParent) { if (GenHostility.AnyHostileActiveThreatToPlayer(mapParent.Map)) { Messages.Message(Translator.Translate("EnemyOnTheMap"), MessageTypeDefOf.NeutralEvent, false); return; } if (Dialog_FormCaravan.AllSendablePawns(mapParent.Map, reform: true).Any((Pawn x) => x.IsColonist)) { Messages.Message("MessageYouHaveToReformCaravanNow".Translate(), new GlobalTargetInfo(mapParent.Tile), MessageTypeDefOf.NeutralEvent); Current.Game.CurrentMap = mapParent.Map; Dialog_FormCaravan window = new Dialog_FormCaravan(mapParent.Map, reform: true, delegate { if (mapParent.HasMap) { Find.WorldObjects.Remove(mapParent); } }, mapAboutToBeRemoved: true); Find.WindowStack.Add(window); return; } List <Pawn> tmpPawns = new List <Pawn>(); tmpPawns.Clear(); tmpPawns.AddRange(from x in mapParent.Map.mapPawns.AllPawns where x.Faction == Faction.OfPlayer || x.HostFaction == Faction.OfPlayer select x); if (tmpPawns.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer))) { CaravanExitMapUtility.ExitMapAndCreateCaravan(tmpPawns, Faction.OfPlayer, mapParent.Tile, mapParent.Tile, -1); } tmpPawns.Clear(); Find.WorldObjects.Remove(mapParent); }
private bool CheckForErrors(List <Pawn> pawns) { if (!pawns.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed)) { Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), this.caravan, MessageTypeDefOf.RejectInput, false); return(false); } return(true); }
public static bool AnyPotentialCaravanOwner(IEnumerable <IThingHolder> pods, Faction faction) { foreach (IThingHolder thingHolder in pods) { ThingOwner directlyHeldThings = thingHolder.GetDirectlyHeldThings(); for (int i = 0; i < directlyHeldThings.Count; i++) { Pawn pawn = directlyHeldThings[i] as Pawn; if (pawn != null && CaravanUtility.IsOwner(pawn, faction)) { return(true); } } } return(false); }
public override void ForceReform(MapParent mapParent) { if (Dialog_FormCaravan.AllSendablePawns(mapParent.Map, reform: true).Any((Pawn x) => x.IsColonist)) { Messages.Message("MessageYouHaveToReformCaravanNow".Translate(), new GlobalTargetInfo(mapParent.Tile), MessageTypeDefOf.NeutralEvent); Current.Game.CurrentMap = mapParent.Map; Dialog_FormCaravan window = new Dialog_FormCaravan(mapParent.Map, reform: true, delegate { if (RemoveAfterLeave && mapParent.HasMap) { Find.WorldObjects.Remove(mapParent); } }, mapAboutToBeRemoved: true); Find.WindowStack.Add(window); for (int i = window.transferables.Count - 1; i >= 0; i--) { TransferableOneWay t = window.transferables[i]; if (t != null) { if (t.AnyThing != null) { if (t.AnyThing.Faction != null && t.AnyThing.Faction == Faction) { window.transferables.Remove(t); } } } } return; } List <Pawn> tmpPawns = new List <Pawn>(); tmpPawns.Clear(); tmpPawns.AddRange(from x in mapParent.Map.mapPawns.AllPawns where x.Faction == Faction.OfPlayer || x.HostFaction == Faction.OfPlayer select x); if (tmpPawns.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer))) { CaravanExitMapUtility.ExitMapAndCreateCaravan(tmpPawns, Faction.OfPlayer, mapParent.Tile, mapParent.Tile, -1); } tmpPawns.Clear(); if (RemoveAfterLeave) { Find.WorldObjects.Remove(mapParent); } }
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); }
public static bool CanSetSail(List <Pawn> caravan) { int seats = 0; int pawns = 0; int prereq = 0; bool flag = caravan.Any(x => !(x.GetComp <CompShips>() is null)); //Ships or No Ships if (flag) { foreach (Pawn p in caravan) { if (IsShip(p)) { seats += p.GetComp <CompShips>().SeatsAvailable; prereq += p.GetComp <CompShips>().PawnCountToOperate - p.GetComp <CompShips>().AllCrewAboard.Count; } else if (p.IsColonistPlayerControlled && !p.Downed && !p.Dead) { pawns++; } } } bool flag2 = flag ? pawns > seats : false; //Not Enough Room bool flag3 = flag ? pawns < prereq : false; //Not Enough Pawns to Sail if (flag2) { Messages.Message("CaravanMustHaveEnoughSpaceOnShip".Translate(), MessageTypeDefOf.RejectInput, false); } if (!caravan.Any(x => CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed)) { Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), MessageTypeDefOf.RejectInput, false); } if (flag3) { Messages.Message("CaravanMustHaveEnoughPawnsToOperate".Translate(prereq), MessageTypeDefOf.RejectInput, false); } return(!flag2 && !flag3); }
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); }
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(); } } }
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(); } } }
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(); } } }
private static bool <CheckForErrors> m__B(Pawn x) { return(CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed); }
private static bool <DebugTryFormCaravanInstantly> m__7(Pawn x) { return(CaravanUtility.IsOwner(x, Faction.OfPlayer)); }
private static bool <DoBottomButtons> m__5(Pawn x) { return(CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed); }
private static bool <DoBottomButtons> m__2(Pawn pawn) { return(CaravanUtility.IsOwner(pawn, Faction.OfPlayer) && !pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled); }
private bool CheckForErrors(List <Pawn> pawns) { if (this.MustChooseRoute && this.destinationTile < 0) { Messages.Message("MessageMustChooseRouteFirst".Translate(), MessageTypeDefOf.RejectInput, false); return(false); } if (!this.reform && this.startingTile < 0) { Messages.Message("MessageNoValidExitTile".Translate(), MessageTypeDefOf.RejectInput, false); return(false); } if (!pawns.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer) && !x.Downed)) { Messages.Message("CaravanMustHaveAtLeastOneColonist".Translate(), MessageTypeDefOf.RejectInput, false); return(false); } if (!this.reform && this.MassUsage > this.MassCapacity) { this.FlashMass(); Messages.Message("TooBigCaravanMassUsage".Translate(), MessageTypeDefOf.RejectInput, false); return(false); } Pawn pawn = pawns.Find((Pawn x) => !x.IsColonist && !pawns.Any((Pawn y) => y.IsColonist && y.CanReach(x, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn))); if (pawn != null) { Messages.Message("CaravanPawnIsUnreachable".Translate(pawn.LabelShort, pawn).CapitalizeFirst(), pawn, MessageTypeDefOf.RejectInput, false); return(false); } for (int i = 0; i < this.transferables.Count; i++) { if (this.transferables[i].ThingDef.category == ThingCategory.Item) { int countToTransfer = this.transferables[i].CountToTransfer; int num = 0; if (countToTransfer > 0) { for (int j = 0; j < this.transferables[i].things.Count; j++) { Thing t = this.transferables[i].things[j]; if (!t.Spawned || pawns.Any((Pawn x) => x.IsColonist && x.CanReach(t, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn))) { num += t.stackCount; if (num >= countToTransfer) { break; } } } if (num < countToTransfer) { if (countToTransfer == 1) { Messages.Message("CaravanItemIsUnreachableSingle".Translate(this.transferables[i].ThingDef.label), MessageTypeDefOf.RejectInput, false); } else { Messages.Message("CaravanItemIsUnreachableMulti".Translate(countToTransfer, this.transferables[i].ThingDef.label), MessageTypeDefOf.RejectInput, false); } return(false); } } } } return(true); }
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(); } } }
private void CloseMapImmediate() { MapParent mapParent = this.parent as MapParent; if (mapParent != null) { if (Dialog_FormCaravan.AllSendablePawns(mapParent.Map, true).Any((Pawn x) => x.IsColonist || x.IsPrisonerOfColony || x.Faction == Faction.OfPlayer || x.HostFaction == Faction.OfPlayer)) { foreach (Pawn pawn in mapParent.Map.mapPawns.AllPawnsSpawned) { if (pawn.RaceProps.Humanlike) { Lord lord = pawn.GetLord(); if (lord != null) { lord.Notify_PawnLost(pawn, PawnLostCondition.ExitedMap); pawn.ClearMind(false); } } } Messages.Message("MessageYouHaveToReformCaravanNow".Translate(), new GlobalTargetInfo(mapParent.Tile), MessageTypeDefOf.NeutralEvent); Current.Game.CurrentMap = mapParent.Map; Dialog_FormCaravan window = new Dialog_FormCaravan(mapParent.Map, true, delegate() { if (mapParent.HasMap) { Find.WorldObjects.Remove(mapParent); } }, false); List <Pawn> list = mapParent.Map.mapPawns.AllPawnsSpawned.ToList <Pawn>(); for (int i = 0; i < list.Count; i++) { Pawn pawn2 = list[i]; if (!pawn2.HostileTo(Faction.OfPlayer) && (pawn2.Faction == Faction.OfPlayer || pawn2.IsPrisonerOfColony)) { Log.Message(pawn2.Label + " Meets criteria in CaravanUtility."); } else { Log.Message(pawn2.Label + " NOT ALLOWED by in CaravanUtility."); } } Find.WindowStack.Add(window); } else { List <Pawn> list2 = new List <Pawn>(); list2.AddRange(from x in mapParent.Map.mapPawns.AllPawns where x.IsColonist || x.IsPrisonerOfColony || x.Faction == Faction.OfPlayer || x.HostFaction == Faction.OfPlayer select x); if (list2.Any <Pawn>()) { if (list2.Any((Pawn x) => CaravanUtility.IsOwner(x, Faction.OfPlayer))) { //TODO: check if it works CaravanExitMapUtility.ExitMapAndCreateCaravan(list2, Faction.OfPlayer, mapParent.Tile, mapParent.Tile, mapParent.Tile, false); Messages.Message("MessageReformedCaravan".Translate(), MessageTypeDefOf.PositiveEvent); } else { StringBuilder stringBuilder = new StringBuilder(); for (int j = 0; j < list2.Count; j++) { stringBuilder.AppendLine(" " + list2[j].LabelCap); } Find.LetterStack.ReceiveLetter("RD_LetterLabelPawnsLostDueToMapCountdown".Translate(), TranslatorFormattedStringExtensions.Translate("RD_LetterPawnsLostDueToMapCountdown", new NamedArgument[] { stringBuilder.ToString().TrimEndNewlines() }), LetterDefOf.ThreatSmall, new GlobalTargetInfo(mapParent.Tile), null); } list2.Clear(); } Find.WorldObjects.Remove(mapParent); } } }
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(); } } }