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 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));
        }
Beispiel #4
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();
            }
        }