示例#1
0
 public static bool AllColonistsThere(MapParent settlement)
 {
     if (!CaravanUtility.PlayerHasAnyCaravan())
     {
         return(!Find.Maps.Any((Map x) => x.info.parent != settlement && x.mapPawns.FreeColonistsSpawned.Any()));
     }
     return(false);
 }
 private void CheckAllEnemiesDefeated(MapParent mapParent)
 {
     if (mapParent.HasMap && !GenHostility.AnyHostileActiveThreatToPlayer(mapParent.Map))
     {
         GiveRewardsAndSendLetter();
         StopQuest();
     }
 }
        private void Arrived()
        {
            if (this.arrived)
            {
                return;
            }
            this.arrived = true;
            Map map = Current.Game.FindMap(this.destinationTile);

            if (map != null)
            {
                this.SpawnDropPodsInMap(map, null);
            }
            else if (!this.PodsHaveAnyPotentialCaravanOwner)
            {
                Caravan caravan = Find.WorldObjects.PlayerControlledCaravanAt(this.destinationTile);
                if (caravan != null)
                {
                    this.GivePodContentsToCaravan(caravan);
                }
                else
                {
                    for (int i = 0; i < this.pods.Count; i++)
                    {
                        this.pods[i].innerContainer.ClearAndDestroyContentsOrPassToWorld(DestroyMode.Vanish);
                    }
                    this.RemoveAllPods();
                    Find.WorldObjects.Remove(this);
                    Messages.Message("MessageTransportPodsArrivedAndLost".Translate(), new GlobalTargetInfo(this.destinationTile), MessageTypeDefOf.NegativeEvent);
                }
            }
            else
            {
                MapParent mapParent = Find.WorldObjects.MapParentAt(this.destinationTile);
                if (mapParent != null && mapParent.TransportPodsCanLandAndGenerateMap && this.attackOnArrival)
                {
                    LongEventHandler.QueueLongEvent(delegate
                    {
                        Map orGenerateMap       = GetOrGenerateMapUtility.GetOrGenerateMap(mapParent.Tile, mapParent.MapSizeGeneratedByTransportPodsArrival, null);
                        string extraMessagePart = null;
                        if (mapParent.Faction != null && !mapParent.Faction.HostileTo(Faction.OfPlayer))
                        {
                            mapParent.Faction.SetHostileTo(Faction.OfPlayer, true);
                            extraMessagePart = "MessageTransportPodsArrived_BecameHostile".Translate(new object[]
                            {
                                mapParent.Faction.Name
                            }).CapitalizeFirst();
                        }
                        Find.TickManager.CurTimeSpeed = TimeSpeed.Paused;
                        this.SpawnDropPodsInMap(orGenerateMap, extraMessagePart);
                    }, "GeneratingMapForNewEncounter", false, null);
                }
                else
                {
                    this.SpawnCaravanAtDestinationTile();
                }
            }
        }
        public override IEnumerable <Gizmo> GetGizmos()
        {
            MapParent mapParent = parent as MapParent;

            if (mapParent.HasMap && mapParent.Faction == Faction.OfPlayer)
            {
                yield return(SettlementAbandonUtility.AbandonCommand(mapParent));
            }
        }
示例#5
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            MapParent mapParent = (MapParent)parent;

            if (!mapParent.HasMap)
            {
                yield break;
            }
            if (!Reform)
            {
                Command_Action command_Action = new Command_Action();
                command_Action.defaultLabel = "CommandFormCaravan".Translate();
                command_Action.defaultDesc  = "CommandFormCaravanDesc".Translate();
                command_Action.icon         = FormCaravanCommand;
                command_Action.hotKey       = KeyBindingDefOf.Misc2;
                command_Action.tutorTag     = "FormCaravan";
                command_Action.action       = delegate
                {
                    Find.WindowStack.Add(new Dialog_FormCaravan(mapParent.Map));
                };
                yield return(command_Action);
            }
            else if (mapParent.Map.mapPawns.FreeColonistsSpawnedCount != 0)
            {
                Command_Action command_Action2 = new Command_Action();
                command_Action2.defaultLabel = "CommandReformCaravan".Translate();
                command_Action2.defaultDesc  = "CommandReformCaravanDesc".Translate();
                command_Action2.icon         = FormCaravanCommand;
                command_Action2.hotKey       = KeyBindingDefOf.Misc2;
                command_Action2.tutorTag     = "ReformCaravan";
                command_Action2.action       = delegate
                {
                    Find.WindowStack.Add(new Dialog_FormCaravan(mapParent.Map, reform: true));
                };
                if (GenHostility.AnyHostileActiveThreatToPlayer(mapParent.Map, countDormantPawnsAsHostile: true))
                {
                    command_Action2.Disable("CommandReformCaravanFailHostilePawns".Translate());
                }
                yield return(command_Action2);
            }
            if (!Prefs.DevMode)
            {
                yield break;
            }
            Command_Action command_Action3 = new Command_Action();

            command_Action3.defaultLabel = "Dev: Show available exits";
            command_Action3.action       = delegate
            {
                foreach (int item in CaravanExitMapUtility.AvailableExitTilesAt(mapParent.Map))
                {
                    Find.WorldDebugDrawer.FlashTile(item, 0f, null, 10);
                }
            };
            yield return(command_Action3);
        }
        public static float EnterCooldownHoursLeft(this MapParent worldObject)
        {
            EnterCooldownComp component = worldObject.GetComponent <EnterCooldownComp>();

            if (component == null)
            {
                return(0f);
            }
            return(component.DaysLeft * 24f);
        }
示例#7
0
        private static void Abandon(MapParent settlement)
        {
            Find.WorldObjects.Remove(settlement);
            FactionBase factionBase = settlement as FactionBase;

            if (factionBase != null)
            {
                SettlementAbandonUtility.AddAbandonedBase(factionBase);
            }
            Find.GameEnder.CheckOrUpdateGameOver();
        }
示例#8
0
        private static void Abandon(MapParent settlement)
        {
            settlement.Destroy();
            Settlement settlement2 = settlement as Settlement;

            if (settlement2 != null)
            {
                AddAbandonedSettlement(settlement2);
            }
            Find.GameEnder.CheckOrUpdateGameOver();
        }
示例#9
0
        private static void Abandon(MapParent settlement)
        {
            Find.WorldObjects.Remove(settlement);
            Settlement settlement2 = settlement as Settlement;

            if (settlement2 != null)
            {
                AddAbandonedSettlement(settlement2);
            }
            Find.GameEnder.CheckOrUpdateGameOver();
        }
示例#10
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            MapParent mapParent = parent as MapParent;

            if (mapParent.HasMap && mapParent.Faction == Faction.OfPlayer)
            {
                yield return((Gizmo)SettlementAbandonUtility.AbandonCommand(mapParent));

                /*Error: Unable to find new state assignment for yield return*/;
            }
        }
 public static FloatMenuAcceptanceReport CanVisit(Caravan caravan, MapParent escapeShip)
 {
     if (escapeShip == null || !escapeShip.Spawned || escapeShip.GetComponent <EscapeShipComp>() == null)
     {
         return(false);
     }
     if (escapeShip.EnterCooldownBlocksEntering())
     {
         return(FloatMenuAcceptanceReport.WithFailMessage("MessageEnterCooldownBlocksEntering".Translate(escapeShip.EnterCooldownTicksLeft().ToStringTicksToPeriod())));
     }
     return(true);
 }
示例#12
0
 public static bool CanLandInSpecificCell(IEnumerable <IThingHolder> pods, MapParent mapParent)
 {
     if (mapParent == null || !mapParent.Spawned || !mapParent.HasMap)
     {
         return(false);
     }
     if (mapParent.EnterCooldownBlocksEntering())
     {
         return(FloatMenuAcceptanceReport.WithFailMessage("MessageEnterCooldownBlocksEntering".Translate(mapParent.EnterCooldownDaysLeft().ToString("0.#"))));
     }
     return(true);
 }
示例#13
0
 public static FloatMenuAcceptanceReport CanEnter(Caravan caravan, MapParent mapParent)
 {
     if (mapParent == null || !mapParent.Spawned || !mapParent.HasMap)
     {
         return(false);
     }
     if (mapParent.EnterCooldownBlocksEntering())
     {
         return(FloatMenuAcceptanceReport.WithFailMessage("MessageEnterCooldownBlocksEntering".Translate(mapParent.EnterCooldownDaysLeft().ToString("0.#"))));
     }
     return(true);
 }
 public override void CompTick()
 {
     base.CompTick();
     if (this.active)
     {
         MapParent mapParent = this.parent as MapParent;
         if (mapParent != null)
         {
             this.CheckAllEnemiesDefeated(mapParent);
         }
     }
 }
 private void CheckAllEnemiesDefeated(MapParent mapParent)
 {
     if (!mapParent.HasMap)
     {
         return;
     }
     if (GenHostility.AnyHostileActiveThreatToPlayer(mapParent.Map))
     {
         return;
     }
     this.GiveRewardsAndSendLetter();
     this.StopQuest();
 }
        public override IEnumerable <Gizmo> GetGizmos()
        {
            _003CGetGizmos_003Ec__Iterator0 _003CGetGizmos_003Ec__Iterator = (_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0036: stateMachine*/;
            MapParent mapParent = base.parent as MapParent;

            if (!mapParent.HasMap)
            {
                yield break;
            }
            if (!this.Props.reformCaravan)
            {
                yield return((Gizmo) new Command_Action
                {
                    defaultLabel = "CommandFormCaravan".Translate(),
                    defaultDesc = "CommandFormCaravanDesc".Translate(),
                    icon = FormCaravanComp.FormCaravanCommand,
                    hotKey = KeyBindingDefOf.Misc2,
                    tutorTag = "FormCaravan",
                    action = delegate
                    {
                        Find.WindowStack.Add(new Dialog_FormCaravan(mapParent.Map, false, null, true, false));
                    }
                });

                /*Error: Unable to find new state assignment for yield return*/;
            }
            if (mapParent.Map.mapPawns.FreeColonistsSpawnedCount == 0)
            {
                yield break;
            }
            Command_Action reformCaravan = new Command_Action
            {
                defaultLabel = "CommandReformCaravan".Translate(),
                defaultDesc  = "CommandReformCaravanDesc".Translate(),
                icon         = FormCaravanComp.FormCaravanCommand,
                hotKey       = KeyBindingDefOf.Misc2,
                tutorTag     = "ReformCaravan",
                action       = delegate
                {
                    Find.WindowStack.Add(new Dialog_FormCaravan(mapParent.Map, true, null, true, false));
                }
            };

            if (GenHostility.AnyHostileActiveThreatToPlayer(mapParent.Map))
            {
                reformCaravan.Disable("CommandReformCaravanFailHostilePawns".Translate());
            }
            yield return((Gizmo)reformCaravan);

            /*Error: Unable to find new state assignment for yield return*/;
        }
        public static void TryAbandonViaInterface(MapParent settlement)
        {
            Map map = settlement.Map;

            if (map == null)
            {
                SettlementAbandonUtility.Abandon(settlement);
                SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
            }
            else
            {
                StringBuilder      stringBuilder = new StringBuilder();
                IEnumerable <Pawn> source        = map.mapPawns.PawnsInFaction(Faction.OfPlayer);
                if (source.Count <Pawn>() != 0)
                {
                    StringBuilder stringBuilder2 = new StringBuilder();
                    foreach (Pawn current in from x in source
                             orderby x.IsColonist descending
                             select x)
                    {
                        if (stringBuilder2.Length > 0)
                        {
                            stringBuilder2.AppendLine();
                        }
                        stringBuilder2.Append("    " + current.LabelCap);
                    }
                    stringBuilder.Append("ConfirmAbandonHomeWithColonyPawns".Translate(new object[]
                    {
                        stringBuilder2
                    }));
                }
                PawnDiedOrDownedThoughtsUtility.BuildMoodThoughtsListString(map.mapPawns.AllPawns, PawnDiedOrDownedThoughtsKind.Banished, stringBuilder, null, "\n\n" + "ConfirmAbandonHomeNegativeThoughts_Everyone".Translate(), "ConfirmAbandonHomeNegativeThoughts");
                if (stringBuilder.Length == 0)
                {
                    SettlementAbandonUtility.Abandon(settlement);
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                }
                else
                {
                    Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(stringBuilder.ToString(), delegate
                    {
                        SettlementAbandonUtility.Abandon(settlement);
                    }, false, null));
                }
            }
        }
示例#18
0
        public static Command AbandonCommand(MapParent settlement)
        {
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandAbandonHome".Translate();
            command_Action.defaultDesc  = "CommandAbandonHomeDesc".Translate();
            command_Action.icon         = SettlementAbandonUtility.AbandonCommandTex;
            command_Action.action       = delegate
            {
                SettlementAbandonUtility.TryAbandonViaInterface(settlement);
            };
            if (SettlementAbandonUtility.AllColonistsThere(settlement))
            {
                command_Action.Disable("CommandAbandonHomeFailAllColonistsThere".Translate());
            }
            return(command_Action);
        }
        public static void Settle(Map map)
        {
            MapParent  parent     = map.Parent;
            Settlement settlement = SettleUtility.AddNewHome(map.Tile, Faction.OfPlayer);

            map.info.parent = settlement;
            parent?.Destroy();
            Messages.Message("MessageSettledInExistingMap".Translate(), settlement, MessageTypeDefOf.PositiveEvent, historical: false);
            tmpPlayerPawns.Clear();
            tmpPlayerPawns.AddRange(map.mapPawns.AllPawnsSpawned.Where((Pawn x) => x.Faction == Faction.OfPlayer || x.HostFaction == Faction.OfPlayer));
            CaravanEnterMapUtility.DropAllInventory(tmpPlayerPawns);
            tmpPlayerPawns.Clear();
            List <Pawn> prisonersOfColonySpawned = map.mapPawns.PrisonersOfColonySpawned;

            for (int i = 0; i < prisonersOfColonySpawned.Count; i++)
            {
                prisonersOfColonySpawned[i].guest.WaitInsteadOfEscapingForDefaultTicks();
            }
        }
示例#20
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            MapParent mapParent = (MapParent)this.parent;

            if (mapParent.HasMap)
            {
                if (!this.Reform)
                {
                    yield return(new Command_Action
                    {
                        defaultLabel = "CommandFormCaravan".Translate(),
                        defaultDesc = "CommandFormCaravanDesc".Translate(),
                        icon = FormCaravanComp.FormCaravanCommand,
                        hotKey = KeyBindingDefOf.Misc2,
                        tutorTag = "FormCaravan",
                        action = delegate()
                        {
                            Find.WindowStack.Add(new Dialog_FormCaravan(mapParent.Map, false, null, false));
                        }
                    });
                }
                else if (mapParent.Map.mapPawns.FreeColonistsSpawnedCount != 0)
                {
                    Command_Action reformCaravan = new Command_Action();
                    reformCaravan.defaultLabel = "CommandReformCaravan".Translate();
                    reformCaravan.defaultDesc  = "CommandReformCaravanDesc".Translate();
                    reformCaravan.icon         = FormCaravanComp.FormCaravanCommand;
                    reformCaravan.hotKey       = KeyBindingDefOf.Misc2;
                    reformCaravan.tutorTag     = "ReformCaravan";
                    reformCaravan.action       = delegate()
                    {
                        Find.WindowStack.Add(new Dialog_FormCaravan(mapParent.Map, true, null, false));
                    };
                    if (GenHostility.AnyHostileActiveThreatToPlayer(mapParent.Map))
                    {
                        reformCaravan.Disable("CommandReformCaravanFailHostilePawns".Translate());
                    }
                    yield return(reformCaravan);
                }
            }
            yield break;
        }
        public override void CompTick()
        {
            MapParent mapParent = (MapParent)this.parent;

            if (this.ForceExitAndRemoveMapCountdownActive)
            {
                if (mapParent.HasMap)
                {
                    this.ticksLeftToForceExitAndRemoveMap--;
                    if (this.ticksLeftToForceExitAndRemoveMap <= 0)
                    {
                        TimedForcedExit.ForceReform(mapParent);
                    }
                }
                else
                {
                    this.ticksLeftToForceExitAndRemoveMap = -1;
                }
            }
        }
示例#22
0
        public override void CompTick()
        {
            MapParent mapParent = (MapParent)parent;

            if (!ForceExitAndRemoveMapCountdownActive)
            {
                return;
            }
            if (mapParent.HasMap)
            {
                ticksLeftToForceExitAndRemoveMap--;
                if (ticksLeftToForceExitAndRemoveMap <= 0)
                {
                    ForceReform(mapParent);
                }
            }
            else
            {
                ticksLeftToForceExitAndRemoveMap = -1;
            }
        }
        public static FloatMenuAcceptanceReport CanEnter(Caravan caravan, MapParent mapParent)
        {
            FloatMenuAcceptanceReport result;

            if (mapParent == null || !mapParent.Spawned || !mapParent.HasMap)
            {
                result = false;
            }
            else if (mapParent.EnterCooldownBlocksEntering())
            {
                result = FloatMenuAcceptanceReport.WithFailMessage("MessageEnterCooldownBlocksEntering".Translate(new object[]
                {
                    mapParent.EnterCooldownDaysLeft().ToString("0.#")
                }));
            }
            else
            {
                result = true;
            }
            return(result);
        }
        public static FloatMenuAcceptanceReport CanVisit(Caravan caravan, MapParent escapeShip)
        {
            FloatMenuAcceptanceReport result;

            if (escapeShip == null || !escapeShip.Spawned || escapeShip.GetComponent <EscapeShipComp>() == null)
            {
                result = false;
            }
            else if (escapeShip.EnterCooldownBlocksEntering())
            {
                result = FloatMenuAcceptanceReport.WithFailMessage("MessageEnterCooldownBlocksEntering".Translate(new object[]
                {
                    escapeShip.EnterCooldownDaysLeft().ToString("0.#")
                }));
            }
            else
            {
                result = true;
            }
            return(result);
        }
示例#25
0
        public static void TryAbandonViaInterface(MapParent settlement)
        {
            Map map = settlement.Map;

            if (map == null)
            {
                Abandon(settlement);
                SoundDefOf.Tick_High.PlayOneShotOnCamera();
                return;
            }
            StringBuilder stringBuilder = new StringBuilder();
            List <Pawn>   source        = map.mapPawns.PawnsInFaction(Faction.OfPlayer);

            if (source.Count() != 0)
            {
                StringBuilder stringBuilder2 = new StringBuilder();
                foreach (Pawn item in source.OrderByDescending((Pawn x) => x.IsColonist))
                {
                    if (stringBuilder2.Length > 0)
                    {
                        stringBuilder2.AppendLine();
                    }
                    stringBuilder2.Append("    " + item.LabelCap);
                }
                stringBuilder.Append("ConfirmAbandonHomeWithColonyPawns".Translate(stringBuilder2));
            }
            PawnDiedOrDownedThoughtsUtility.BuildMoodThoughtsListString(map.mapPawns.AllPawns, PawnDiedOrDownedThoughtsKind.Banished, stringBuilder, null, "\n\n" + "ConfirmAbandonHomeNegativeThoughts_Everyone".Translate(), "ConfirmAbandonHomeNegativeThoughts");
            if (stringBuilder.Length == 0)
            {
                Abandon(settlement);
                SoundDefOf.Tick_High.PlayOneShotOnCamera();
            }
            else
            {
                Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(stringBuilder.ToString(), delegate
                {
                    Abandon(settlement);
                }));
            }
        }
示例#26
0
        public static void AffectRelationsOnAttacked_NewTmp(MapParent mapParent, ref TaggedString letterText)
        {
            if (mapParent.Faction == null || mapParent.Faction == Faction.OfPlayer)
            {
                return;
            }
            FactionRelationKind playerRelationKind = mapParent.Faction.PlayerRelationKind;

            if (!mapParent.Faction.HostileTo(Faction.OfPlayer))
            {
                mapParent.Faction.TrySetRelationKind(Faction.OfPlayer, FactionRelationKind.Hostile, canSendLetter: false);
            }
            else if (mapParent.Faction.TryAffectGoodwillWith(Faction.OfPlayer, -50, canSendMessage: false, canSendHostilityLetter: false))
            {
                if (!letterText.NullOrEmpty())
                {
                    letterText += "\n\n";
                }
                letterText += "RelationsWith".Translate(mapParent.Faction.Name.ApplyTag(mapParent.Faction)) + ": " + (-50).ToStringWithSign();
            }
            mapParent.Faction.TryAppendRelationKindChangedInfo(ref letterText, playerRelationKind, mapParent.Faction.PlayerRelationKind);
        }
示例#27
0
        public static void Settle(Map map)
        {
            MapParent  parent     = map.Parent;
            Settlement settlement = SettleUtility.AddNewHome(map.Tile, Faction.OfPlayer);

            map.info.parent = settlement;
            if (parent != null)
            {
                Find.WorldObjects.Remove(parent);
            }
            Messages.Message("MessageSettledInExistingMap".Translate(), settlement, MessageTypeDefOf.PositiveEvent, false);
            SettleInExistingMapUtility.tmpPlayerPawns.Clear();
            SettleInExistingMapUtility.tmpPlayerPawns.AddRange(from x in map.mapPawns.AllPawnsSpawned
                                                               where x.Faction == Faction.OfPlayer || x.HostFaction == Faction.OfPlayer
                                                               select x);
            CaravanEnterMapUtility.DropAllInventory(SettleInExistingMapUtility.tmpPlayerPawns);
            SettleInExistingMapUtility.tmpPlayerPawns.Clear();
            List <Pawn> prisonersOfColonySpawned = map.mapPawns.PrisonersOfColonySpawned;

            for (int i = 0; i < prisonersOfColonySpawned.Count; i++)
            {
                prisonersOfColonySpawned[i].guest.WaitInsteadOfEscapingForDefaultTicks();
            }
        }
示例#28
0
        public override void CompTick()
        {
            MapParent mapParent = (MapParent)parent;

            if (mapParent.HasMap)
            {
                List <Pawn> allPawnsSpawned = mapParent.Map.mapPawns.AllPawnsSpawned;
                bool        flag            = mapParent.Map.mapPawns.FreeColonistsSpawnedOrInPlayerEjectablePodsCount != 0;
                bool        flag2           = false;
                for (int i = 0; i < allPawnsSpawned.Count; i++)
                {
                    Pawn pawn = allPawnsSpawned[i];
                    if (pawn.RaceProps.Humanlike && pawn.HostFaction == null && !pawn.Downed && pawn.Faction != null && pawn.Faction.HostileTo(Faction.OfPlayer))
                    {
                        flag2 = true;
                    }
                }
                if (flag2 && !flag)
                {
                    Find.LetterStack.ReceiveLetter("EscapeShipLostLabel".Translate(), "EscapeShipLost".Translate(), LetterDefOf.NegativeEvent);
                    Find.WorldObjects.Remove(parent);
                }
            }
        }
示例#29
0
 public TransportPodsArrivalAction_LandInSpecificCell(MapParent mapParent, IntVec3 cell)
 {
     this.mapParent = mapParent;
     this.cell      = cell;
 }
 public CaravanArrivalAction_VisitEscapeShip(EscapeShipComp escapeShip)
 {
     this.target = (MapParent)escapeShip.parent;
 }