public override void Arrived(Caravan caravan)
        {
            Map map = this.mapParent.Map;

            if (map != null)
            {
                Pawn t = caravan.PawnsListForReading[0];
                CaravanDropInventoryMode dropInventoryMode = (CaravanDropInventoryMode)(map.IsPlayerHome ? 2 : 0);
                bool draftColonists = this.mapParent.Faction != null && this.mapParent.Faction.HostileTo(Faction.OfPlayer);
                CaravanEnterMapUtility.Enter(caravan, map, CaravanEnterMode.Edge, dropInventoryMode, draftColonists, null);
                if (this.mapParent.def == WorldObjectDefOf.Ambush)
                {
                    Find.TickManager.CurTimeSpeed = TimeSpeed.Paused;
                    Find.LetterStack.ReceiveLetter("LetterLabelCaravanEnteredAmbushMap".Translate(), "LetterCaravanEnteredAmbushMap".Translate(caravan.Label).CapitalizeFirst(), LetterDefOf.NeutralEvent, t, null);
                }
                else
                {
                    if (!caravan.IsPlayerControlled && this.mapParent.Faction != Faction.OfPlayer)
                    {
                        return;
                    }
                    Messages.Message("MessageCaravanEnteredWorldObject".Translate(caravan.Label, this.mapParent.Label).CapitalizeFirst(), t, MessageTypeDefOf.TaskCompletion);
                }
            }
        }
Ejemplo n.º 2
0
        private void DoArrivalAction(Caravan caravan)
        {
            Pawn t             = caravan.PawnsListForReading[0];
            Map  orGenerateMap = GetOrGenerateMapUtility.GetOrGenerateMap(this.settlement.Tile, null);

            CaravanEnterMapUtility.Enter(caravan, orGenerateMap, CaravanEnterMode.Edge, CaravanDropInventoryMode.DoNotDrop, true, null);
            Find.TickManager.CurTimeSpeed = TimeSpeed.Paused;
            if (!this.settlement.Faction.HostileTo(Faction.OfPlayer))
            {
                this.settlement.Faction.SetHostileTo(Faction.OfPlayer, true);
                Find.LetterStack.ReceiveLetter("LetterLabelCaravanEnteredEnemyBase".Translate(), "LetterCaravanEnteredEnemyBaseBecameHostile".Translate(new object[]
                {
                    caravan.Label,
                    this.settlement.Label,
                    this.settlement.Faction.Name
                }).CapitalizeFirst(), LetterDefOf.NeutralEvent, t, null);
            }
            else
            {
                Find.LetterStack.ReceiveLetter("LetterLabelCaravanEnteredEnemyBase".Translate(), "LetterCaravanEnteredEnemyBase".Translate(new object[]
                {
                    caravan.Label,
                    this.settlement.Label
                }).CapitalizeFirst(), LetterDefOf.NeutralEvent, t, null);
            }
        }
        private void DoArrivalAction(Caravan caravan)
        {
            Map orGenerateMap = GetOrGenerateMapUtility.GetOrGenerateMap(this.target.Tile, null);

            CaravanEnterMapUtility.Enter(caravan, orGenerateMap, CaravanEnterMode.Edge, CaravanDropInventoryMode.UnloadIndividually, false, null);
            Find.TickManager.CurTimeSpeed = TimeSpeed.Paused;
        }
Ejemplo n.º 4
0
        public override void Arrived(Caravan caravan)
        {
            Map map = this.mapParent.Map;

            if (map == null)
            {
                return;
            }
            Pawn t = caravan.PawnsListForReading[0];
            CaravanDropInventoryMode dropInventoryMode = (!map.IsPlayerHome) ? CaravanDropInventoryMode.DoNotDrop : CaravanDropInventoryMode.UnloadIndividually;
            bool draftColonists = this.mapParent.Faction != null && this.mapParent.Faction.HostileTo(Faction.OfPlayer);

            CaravanEnterMapUtility.Enter(caravan, map, CaravanEnterMode.Edge, dropInventoryMode, draftColonists, null);
            if (this.mapParent.def == WorldObjectDefOf.Ambush)
            {
                Find.LetterStack.ReceiveLetter("LetterLabelCaravanEnteredAmbushMap".Translate(), "LetterCaravanEnteredAmbushMap".Translate(new object[]
                {
                    caravan.Label
                }).CapitalizeFirst(), LetterDefOf.NeutralEvent, t, null, null);
            }
            else if (caravan.IsPlayerControlled || this.mapParent.Faction == Faction.OfPlayer)
            {
                Messages.Message("MessageCaravanEnteredWorldObject".Translate(new object[]
                {
                    caravan.Label,
                    this.mapParent.Label
                }).CapitalizeFirst(), t, MessageTypeDefOf.TaskCompletion, true);
            }
        }
            internal void <> m__1()
            {
                Map  map = this.newHome.Map;
                Pawn t   = this.caravan.PawnsListForReading[0];

                CaravanEnterMapUtility.Enter(this.caravan, map, CaravanEnterMode.Center, CaravanDropInventoryMode.DropInstantly, false, (IntVec3 x) => x.GetRoom(map, RegionType.Set_Passable).CellCount >= 600);
                CameraJumper.TryJump(t);
            }
 private static IntVec3 GetEnterCell(Caravan caravan, Map map, CaravanEnterMode enterMode, Predicate <IntVec3> extraCellValidator)
 {
     if (enterMode == CaravanEnterMode.Edge)
     {
         return(CaravanEnterMapUtility.FindNearEdgeCell(map, extraCellValidator));
     }
     if (enterMode != CaravanEnterMode.Center)
     {
         throw new NotImplementedException("CaravanEnterMode");
     }
     return(CaravanEnterMapUtility.FindCenterCell(map, extraCellValidator));
 }
        private void DoEnter(Caravan caravan, Site site)
        {
            LookTargets lookTargets    = new LookTargets(caravan.PawnsListForReading);
            bool        draftColonists = site.Faction == null || site.Faction.HostileTo(Faction.OfPlayer);
            bool        num            = !site.HasMap;
            Map         orGenerateMap  = GetOrGenerateMapUtility.GetOrGenerateMap(site.Tile, MapSize, null);

            if (num)
            {
                Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
                PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(orGenerateMap.mapPawns.AllPawns, "LetterRelatedPawnsSite".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent, informEvenIfSeenBefore: true);
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append("LetterCaravanEnteredMap".Translate(caravan.Label, site).CapitalizeFirst());
                AppendThreatInfo(stringBuilder, site, orGenerateMap, out var letterDef, out var allLookTargets);
                TaggedString letterText = null;
                SettlementUtility.AffectRelationsOnAttacked_NewTmp(site, ref letterText);
                if (!letterText.NullOrEmpty())
                {
                    if (stringBuilder.Length > 0)
                    {
                        stringBuilder.AppendLine();
                    }
                    stringBuilder.AppendLineTagged(letterText);
                }
                List <HediffDef> list = null;
                foreach (SitePart part in site.parts)
                {
                    if (part.def.arrivedLetterHediffHyperlinks.NullOrEmpty())
                    {
                        continue;
                    }
                    if (list == null)
                    {
                        list = new List <HediffDef>();
                    }
                    foreach (HediffDef arrivedLetterHediffHyperlink in part.def.arrivedLetterHediffHyperlinks)
                    {
                        if (!list.Contains(arrivedLetterHediffHyperlink))
                        {
                            list.Add(arrivedLetterHediffHyperlink);
                        }
                    }
                }
                ChoiceLetter choiceLetter = LetterMaker.MakeLetter("LetterLabelCaravanEnteredMap".Translate(site), stringBuilder.ToString(), letterDef ?? LetterDefOf.NeutralEvent, allLookTargets.IsValid() ? allLookTargets : lookTargets);
                choiceLetter.hyperlinkHediffDefs = list;
                Find.LetterStack.ReceiveLetter(choiceLetter);
            }
            else
            {
                Find.LetterStack.ReceiveLetter("LetterLabelCaravanEnteredMap".Translate(site), "LetterCaravanEnteredMap".Translate(caravan.Label, site).CapitalizeFirst(), LetterDefOf.NeutralEvent, lookTargets);
            }
            CaravanEnterMapUtility.Enter(caravan, orGenerateMap, CaravanEnterMode.Edge, CaravanDropInventoryMode.DoNotDrop, draftColonists);
        }
        public static void Enter(Caravan caravan, Map map, CaravanEnterMode enterMode, CaravanDropInventoryMode dropInventoryMode = CaravanDropInventoryMode.DoNotDrop, bool draftColonists = false, Predicate <IntVec3> extraCellValidator = null)
        {
            if (enterMode == CaravanEnterMode.None)
            {
                Log.Error("Caravan " + caravan + " tried to enter map " + map + " with enter mode " + enterMode);
                enterMode = CaravanEnterMode.Edge;
            }
            IntVec3 enterCell = CaravanEnterMapUtility.GetEnterCell(caravan, map, enterMode, extraCellValidator);
            Func <Pawn, IntVec3> spawnCellGetter = (Pawn p) => CellFinder.RandomSpawnCellForPawnNear(enterCell, map, 4);

            CaravanEnterMapUtility.Enter(caravan, map, spawnCellGetter, dropInventoryMode, draftColonists);
        }
        private static IntVec3 GetEnterCell(Caravan caravan, Map map, CaravanEnterMode enterMode, Predicate <IntVec3> extraCellValidator)
        {
            switch (enterMode)
            {
            case CaravanEnterMode.Edge:
                return(CaravanEnterMapUtility.FindNearEdgeCell(map, extraCellValidator));

            case CaravanEnterMode.Center:
                return(CaravanEnterMapUtility.FindCenterCell(map, extraCellValidator));

            default:
                throw new NotImplementedException("CaravanEnterMode");
            }
        }
Ejemplo n.º 10
0
        public override void Arrived(Caravan caravan)
        {
            Map map = mapParent.Map;

            if (map != null)
            {
                CaravanDropInventoryMode dropInventoryMode = map.IsPlayerHome ? CaravanDropInventoryMode.UnloadIndividually : CaravanDropInventoryMode.DoNotDrop;
                bool draftColonists = mapParent.Faction != null && mapParent.Faction.HostileTo(Faction.OfPlayer);
                if (caravan.IsPlayerControlled || mapParent.Faction == Faction.OfPlayer)
                {
                    Find.LetterStack.ReceiveLetter("LetterLabelCaravanEnteredMap".Translate(mapParent), "LetterCaravanEnteredMap".Translate(caravan.Label, mapParent).CapitalizeFirst(), LetterDefOf.NeutralEvent, caravan.PawnsListForReading);
                }
                CaravanEnterMapUtility.Enter(caravan, map, CaravanEnterMode.Edge, dropInventoryMode, draftColonists);
            }
        }
Ejemplo n.º 11
0
		public static Map SetupCaravanAttackMap(Caravan caravan, List<Pawn> enemies)
		{
			int num = CaravanIncidentUtility.CalculateIncidentMapSize(caravan.PawnsListForReading, enemies);
			Map map = CaravanIncidentUtility.GetOrGenerateMapForIncident(caravan, new IntVec3(num, 1, num), WorldObjectDefOf.Ambush);
			IntVec3 playerStartingSpot;
			IntVec3 root;
			MultipleCaravansCellFinder.FindStartingCellsFor2Groups(map, out playerStartingSpot, out root);
			CaravanEnterMapUtility.Enter(caravan, map, (Pawn x) => CellFinder.RandomSpawnCellForPawnNear(playerStartingSpot, map, 4), CaravanDropInventoryMode.DoNotDrop, true);
			for (int i = 0; i < enemies.Count; i++)
			{
				IntVec3 loc = CellFinder.RandomSpawnCellForPawnNear(root, map, 4);
				GenSpawn.Spawn(enemies[i], loc, map, Rot4.Random, false);
			}
			return map;
		}
Ejemplo n.º 12
0
        private static void AttackNow(Caravan caravan, Settlement settlement)
        {
            bool         num           = !settlement.HasMap;
            Map          orGenerateMap = GetOrGenerateMapUtility.GetOrGenerateMap(settlement.Tile, null);
            TaggedString letterLabel   = "LetterLabelCaravanEnteredEnemyBase".Translate();
            TaggedString letterText    = "LetterCaravanEnteredEnemyBase".Translate(caravan.Label, settlement.Label.ApplyTag(TagType.Settlement, settlement.Faction.GetUniqueLoadID())).CapitalizeFirst();

            AffectRelationsOnAttacked(settlement, ref letterText);
            if (num)
            {
                Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
                PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(orGenerateMap.mapPawns.AllPawns, ref letterLabel, ref letterText, "LetterRelatedPawnsSettlement".Translate(Faction.OfPlayer.def.pawnsPlural), informEvenIfSeenBefore: true);
            }
            Find.LetterStack.ReceiveLetter(letterLabel, letterText, LetterDefOf.NeutralEvent, caravan.PawnsListForReading, settlement.Faction);
            CaravanEnterMapUtility.Enter(caravan, orGenerateMap, CaravanEnterMode.Edge, CaravanDropInventoryMode.DoNotDrop, draftColonists: true);
        }
        private void DoArrivalAction(Caravan caravan)
        {
            bool flag = !this.target.HasMap;

            if (flag)
            {
                this.target.SetFaction(Faction.OfPlayer);
            }
            Map orGenerateMap = GetOrGenerateMapUtility.GetOrGenerateMap(this.target.Tile, null);

            CaravanEnterMapUtility.Enter(caravan, orGenerateMap, CaravanEnterMode.Edge, CaravanDropInventoryMode.UnloadIndividually, false, null);
            if (flag)
            {
                Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
                Find.LetterStack.ReceiveLetter("EscapeShipFoundLabel".Translate(), "EscapeShipFound".Translate(), LetterDefOf.PositiveEvent, new GlobalTargetInfo(this.target.Map.Center, this.target.Map, false), null, null);
            }
        }
Ejemplo n.º 14
0
        private static void AttackNow(Caravan caravan, SettlementBase settlement)
        {
            Pawn   t             = caravan.PawnsListForReading[0];
            bool   flag          = !settlement.HasMap;
            Map    orGenerateMap = GetOrGenerateMapUtility.GetOrGenerateMap(settlement.Tile, null);
            string label         = "LetterLabelCaravanEnteredEnemyBase".Translate();
            string text          = "LetterCaravanEnteredEnemyBase".Translate(caravan.Label, settlement.Label).CapitalizeFirst();

            SettlementUtility.AffectRelationsOnAttacked(settlement, ref text);
            if (flag)
            {
                Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
                PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(orGenerateMap.mapPawns.AllPawns, ref label, ref text, "LetterRelatedPawnsSettlement".Translate(Faction.OfPlayer.def.pawnsPlural), true, true);
            }
            Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.NeutralEvent, t, settlement.Faction, null);
            CaravanEnterMapUtility.Enter(caravan, orGenerateMap, CaravanEnterMode.Edge, CaravanDropInventoryMode.DoNotDrop, true, null);
        }
        public override void Arrived(Caravan caravan)
        {
            Map map = this.mapParent.Map;

            if (map == null)
            {
                return;
            }
            Pawn t = caravan.PawnsListForReading[0];
            CaravanDropInventoryMode dropInventoryMode = (!map.IsPlayerHome) ? CaravanDropInventoryMode.DoNotDrop : CaravanDropInventoryMode.UnloadIndividually;
            bool draftColonists = this.mapParent.Faction != null && this.mapParent.Faction.HostileTo(Faction.OfPlayer);

            CaravanEnterMapUtility.Enter(caravan, map, CaravanEnterMode.Edge, dropInventoryMode, draftColonists, null);
            if (caravan.IsPlayerControlled || this.mapParent.Faction == Faction.OfPlayer)
            {
                Find.LetterStack.ReceiveLetter("LetterLabelCaravanEnteredMap".Translate(this.mapParent), "LetterCaravanEnteredMap".Translate(caravan.Label, this.mapParent).CapitalizeFirst(), LetterDefOf.NeutralEvent, t, null, null);
            }
        }
        public static Map SetupCaravanAttackMap(Caravan caravan, List <Pawn> enemies, bool sendLetterIfRelatedPawns)
        {
            int num = CalculateIncidentMapSize(caravan.PawnsListForReading, enemies);
            Map map = GetOrGenerateMapForIncident(caravan, new IntVec3(num, 1, num), WorldObjectDefOf.Ambush);

            MultipleCaravansCellFinder.FindStartingCellsFor2Groups(map, out var playerStartingSpot, out var second);
            CaravanEnterMapUtility.Enter(caravan, map, (Pawn x) => CellFinder.RandomSpawnCellForPawnNear(playerStartingSpot, map), CaravanDropInventoryMode.DoNotDrop, draftColonists: true);
            for (int i = 0; i < enemies.Count; i++)
            {
                IntVec3 loc = CellFinder.RandomSpawnCellForPawnNear(second, map);
                GenSpawn.Spawn(enemies[i], loc, map, Rot4.Random);
            }
            if (sendLetterIfRelatedPawns)
            {
                PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(enemies, "LetterRelatedPawnsGroupGeneric".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent, informEvenIfSeenBefore: true);
            }
            return(map);
        }
        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();
            }
        }
        public static void Enter(Caravan caravan, Map map, Func <Pawn, IntVec3> spawnCellGetter, CaravanDropInventoryMode dropInventoryMode = CaravanDropInventoryMode.DoNotDrop, bool draftColonists = false)
        {
            CaravanEnterMapUtility.tmpPawns.Clear();
            CaravanEnterMapUtility.tmpPawns.AddRange(caravan.PawnsListForReading);
            for (int i = 0; i < CaravanEnterMapUtility.tmpPawns.Count; i++)
            {
                IntVec3 loc = spawnCellGetter(CaravanEnterMapUtility.tmpPawns[i]);
                GenSpawn.Spawn(CaravanEnterMapUtility.tmpPawns[i], loc, map, Rot4.Random, false);
            }
            switch (dropInventoryMode)
            {
            case CaravanDropInventoryMode.DropInstantly:
                CaravanEnterMapUtility.DropAllInventory(CaravanEnterMapUtility.tmpPawns);
                break;

            case CaravanDropInventoryMode.UnloadIndividually:
                for (int j = 0; j < CaravanEnterMapUtility.tmpPawns.Count; j++)
                {
                    CaravanEnterMapUtility.tmpPawns[j].inventory.UnloadEverything = true;
                }
                break;
            }
            if (draftColonists)
            {
                CaravanEnterMapUtility.DraftColonists(CaravanEnterMapUtility.tmpPawns);
            }
            if (map.IsPlayerHome)
            {
                for (int k = 0; k < CaravanEnterMapUtility.tmpPawns.Count; k++)
                {
                    if (CaravanEnterMapUtility.tmpPawns[k].IsPrisoner)
                    {
                        CaravanEnterMapUtility.tmpPawns[k].guest.WaitInsteadOfEscapingForDefaultTicks();
                    }
                }
            }
            caravan.RemoveAllPawns();
            if (caravan.Spawned)
            {
                Find.WorldObjects.Remove(caravan);
            }
            CaravanEnterMapUtility.tmpPawns.Clear();
        }
Ejemplo n.º 19
0
        private void DoArrivalAction(Caravan caravan)
        {
            bool flag = !target.HasMap;

            if (flag)
            {
                target.SetFaction(Faction.OfPlayer);
            }
            Map  orGenerateMap = GetOrGenerateMapUtility.GetOrGenerateMap(target.Tile, null);
            Pawn t             = caravan.PawnsListForReading[0];

            CaravanEnterMapUtility.Enter(caravan, orGenerateMap, CaravanEnterMode.Edge, CaravanDropInventoryMode.UnloadIndividually);
            if (flag)
            {
                Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
                Find.LetterStack.ReceiveLetter("EscapeShipFoundLabel".Translate(), "EscapeShipFound".Translate(), LetterDefOf.PositiveEvent, new GlobalTargetInfo(target.Map.Center, target.Map));
            }
            else
            {
                Find.LetterStack.ReceiveLetter("LetterLabelCaravanEnteredMap".Translate(target), "LetterCaravanEnteredMap".Translate(caravan.Label, target).CapitalizeFirst(), LetterDefOf.NeutralEvent, t);
            }
        }
        private void DoArrivalAction(Caravan caravan)
        {
            bool num = !target.HasMap;

            if (num)
            {
                target.SetFaction(Faction.OfPlayer);
            }
            Map         orGenerateMap = GetOrGenerateMapUtility.GetOrGenerateMap(target.Tile, null);
            LookTargets lookTargets   = new LookTargets(caravan.PawnsListForReading);

            CaravanEnterMapUtility.Enter(caravan, orGenerateMap, CaravanEnterMode.Edge, CaravanDropInventoryMode.UnloadIndividually);
            if (num)
            {
                Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
                Find.LetterStack.ReceiveLetter("EscapeShipFoundLabel".Translate(), (!Find.Storyteller.difficultyValues.allowBigThreats) ? "EscapeShipFoundPeaceful".Translate() : "EscapeShipFound".Translate(), LetterDefOf.PositiveEvent, new GlobalTargetInfo(target.Map.Center, target.Map));
            }
            else
            {
                Find.LetterStack.ReceiveLetter("LetterLabelCaravanEnteredMap".Translate(target), "LetterCaravanEnteredMap".Translate(caravan.Label, target).CapitalizeFirst(), LetterDefOf.NeutralEvent, lookTargets);
            }
        }
        public static void Settle(Caravan caravan)
        {
            Faction faction = caravan.Faction;

            if (faction != Faction.OfPlayer)
            {
                Log.Error("Cannot settle with non-player faction.", false);
            }
            else
            {
                Settlement newHome = SettleUtility.AddNewHome(caravan.Tile, faction);
                Action     action  = delegate()
                {
                    GetOrGenerateMapUtility.GetOrGenerateMap(caravan.Tile, Find.World.info.initialMapSize, null);
                };
                string textKey          = "GeneratingMap";
                bool   doAsynchronously = true;
                if (SettleInEmptyTileUtility.< > f__mg$cache0 == null)
                {
                    SettleInEmptyTileUtility.< > f__mg$cache0 = new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap);
                }
                LongEventHandler.QueueLongEvent(action, textKey, doAsynchronously, SettleInEmptyTileUtility.< > f__mg$cache0);
                Action action2 = delegate()
                {
                    Map  map = newHome.Map;
                    Pawn t   = caravan.PawnsListForReading[0];
                    CaravanEnterMapUtility.Enter(caravan, map, CaravanEnterMode.Center, CaravanDropInventoryMode.DropInstantly, false, (IntVec3 x) => x.GetRoom(map, RegionType.Set_Passable).CellCount >= 600);
                    CameraJumper.TryJump(t);
                };
                string textKey2          = "SpawningColonists";
                bool   doAsynchronously2 = true;
                if (SettleInEmptyTileUtility.< > f__mg$cache1 == null)
                {
                    SettleInEmptyTileUtility.< > f__mg$cache1 = new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap);
                }
                LongEventHandler.QueueLongEvent(action2, textKey2, doAsynchronously2, SettleInEmptyTileUtility.< > f__mg$cache1);
            }
        }
        public static void Settle(Caravan caravan)
        {
            Faction faction = caravan.Faction;

            if (faction != Faction.OfPlayer)
            {
                Log.Error("Cannot settle with non-player faction.", false);
                return;
            }
            Settlement newHome = SettleUtility.AddNewHome(caravan.Tile, faction);

            LongEventHandler.QueueLongEvent(delegate
            {
                GetOrGenerateMapUtility.GetOrGenerateMap(caravan.Tile, Find.World.info.initialMapSize, null);
            }, "GeneratingMap", true, new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap));
            LongEventHandler.QueueLongEvent(delegate
            {
                Map map = newHome.Map;
                Pawn t  = caravan.PawnsListForReading[0];
                CaravanEnterMapUtility.Enter(caravan, map, CaravanEnterMode.Center, CaravanDropInventoryMode.DropInstantly, false, (IntVec3 x) => x.GetRoom(map, RegionType.Set_Passable).CellCount >= 600);
                CameraJumper.TryJump(t);
            }, "SpawningColonists", true, new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap));
        }
Ejemplo n.º 23
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();
            }
        }