示例#1
0
 private bool TryRecoverFromUnwalkablePosition()
 {
     if (GenWorldClosest.TryFindClosestTile(caravan.Tile, (int t) => IsPassable(t), out var foundTile))
     {
         Log.Warning(string.Concat(caravan, " on unwalkable tile ", caravan.Tile, ". Teleporting to ", foundTile));
         caravan.Tile = foundTile;
         caravan.Notify_Teleported();
         return(true);
     }
     Log.Error(string.Concat(caravan, " on unwalkable tile ", caravan.Tile, ". Could not find walkable position nearby. Removed."));
     caravan.Destroy();
     return(false);
 }
示例#2
0
        private static void MergeCaravans(List <Caravan> caravans)
        {
            Caravan caravan = caravans.MaxBy((Caravan x) => x.PawnsListForReading.Count);

            for (int i = 0; i < caravans.Count; i++)
            {
                Caravan caravan2 = caravans[i];
                if (caravan2 != caravan)
                {
                    caravan2.pawns.TryTransferAllToContainer(caravan.pawns);
                    caravan2.Destroy();
                }
            }
            caravan.Notify_Merged(caravans);
        }
        public static void Enter(Caravan caravan, Map map, Func <Pawn, IntVec3> spawnCellGetter, CaravanDropInventoryMode dropInventoryMode = CaravanDropInventoryMode.DoNotDrop, bool draftColonists = false)
        {
            tmpPawns.Clear();
            tmpPawns.AddRange(caravan.PawnsListForReading);
            for (int i = 0; i < tmpPawns.Count; i++)
            {
                IntVec3 loc = spawnCellGetter(tmpPawns[i]);
                GenSpawn.Spawn(tmpPawns[i], loc, map, Rot4.Random);
            }
            switch (dropInventoryMode)
            {
            case CaravanDropInventoryMode.DropInstantly:
                DropAllInventory(tmpPawns);
                break;

            case CaravanDropInventoryMode.UnloadIndividually:
            {
                for (int j = 0; j < tmpPawns.Count; j++)
                {
                    tmpPawns[j].inventory.UnloadEverything = true;
                }
                break;
            }
            }
            if (draftColonists)
            {
                DraftColonists(tmpPawns);
            }
            if (map.IsPlayerHome)
            {
                for (int k = 0; k < tmpPawns.Count; k++)
                {
                    if (tmpPawns[k].IsPrisoner)
                    {
                        tmpPawns[k].guest.WaitInsteadOfEscapingForDefaultTicks();
                    }
                }
            }
            caravan.RemoveAllPawns();
            if (!caravan.Destroyed)
            {
                caravan.Destroy();
            }
            tmpPawns.Clear();
        }