Beispiel #1
0
        public static void ExitMapAndJoinOrCreateCaravan(Pawn pawn, Rot4 exitDir)
        {
            Caravan caravan = CaravanExitMapUtility.FindCaravanToJoinFor(pawn);

            if (caravan != null)
            {
                CaravanExitMapUtility.AddCaravanExitTaleIfShould(pawn);
                pawn.DeSpawn(DestroyMode.Vanish);
                caravan.AddPawn(pawn, true);
                pawn.ExitMap(false, exitDir);
            }
            else if (pawn.IsColonist)
            {
                Map     map           = pawn.Map;
                int     directionTile = CaravanExitMapUtility.FindRandomStartingTileBasedOnExitDir(map.Tile, exitDir);
                Caravan caravan2      = CaravanExitMapUtility.ExitMapAndCreateCaravan(Gen.YieldSingle <Pawn>(pawn), pawn.Faction, map.Tile, directionTile, -1, false);
                caravan2.autoJoinable = true;
                bool        flag            = false;
                List <Pawn> allPawnsSpawned = map.mapPawns.AllPawnsSpawned;
                for (int i = 0; i < allPawnsSpawned.Count; i++)
                {
                    if (CaravanExitMapUtility.FindCaravanToJoinFor(allPawnsSpawned[i]) != null && !allPawnsSpawned[i].Downed && !allPawnsSpawned[i].Drafted)
                    {
                        if (allPawnsSpawned[i].RaceProps.Animal)
                        {
                            flag = true;
                        }
                        RestUtility.WakeUp(allPawnsSpawned[i]);
                        allPawnsSpawned[i].jobs.CheckForJobOverride();
                    }
                }
                string text = "MessagePawnLeftMapAndCreatedCaravan".Translate(new object[]
                {
                    pawn.LabelShort
                }).CapitalizeFirst();
                if (flag)
                {
                    text = text + " " + "MessagePawnLeftMapAndCreatedCaravan_AnimalsWantToJoin".Translate();
                }
                Messages.Message(text, caravan2, MessageTypeDefOf.TaskCompletion, true);
            }
            else
            {
                Log.Error("Pawn " + pawn + " didn't find any caravan to join, and he can't create one.", false);
            }
        }
Beispiel #2
0
        public static Caravan ExitMapAndCreateCaravan(IEnumerable <Pawn> pawns, Faction faction, int exitFromTile, Direction8Way dir, int destinationTile, bool sendMessage = true)
        {
            int directionTile = CaravanExitMapUtility.FindRandomStartingTileBasedOnExitDir(exitFromTile, dir);

            return(CaravanExitMapUtility.ExitMapAndCreateCaravan(pawns, faction, exitFromTile, directionTile, destinationTile, sendMessage));
        }