private bool TryRecoverFromUnwalkablePosition()
 {
     if (GenWorldClosest.TryFindClosestTile(caravan.Tile, (int t) => IsPassable(t) && WorldVehicleReachability.Instance.CanReach(caravan, t), out int num, 2147483647, true))
     {
         Log.Warning(string.Concat(new object[]
         {
             caravan,
             " on unwalkable tile ",
             caravan.Tile,
             ". Teleporting to ",
             num
         }));
         caravan.Tile = num;
         caravan.Notify_VehicleTeleported();
         return(true);
     }
     Log.Error(string.Concat(new object[]
     {
         caravan,
         " on unwalkable tile ",
         caravan.Tile,
         ". Could not find walkable position nearby. Removed."
     }));
     caravan.Destroy();
     return(false);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Find best tile to snap to when ordering a caravan
        /// </summary>
        /// <param name="c"></param>
        /// <param name="tile"></param>
        public static int BestGotoDestForVehicle(Caravan caravan, int tile)
        {
            Predicate <int> predicate = (int t) => caravan.UniqueVehicleDefsInCaravan().All(v => WorldVehiclePathGrid.Instance.Passable(t, v)) &&
                                        WorldVehicleReachability.Instance.CanReach(caravan, t);

            if (predicate(tile))
            {
                return(tile);
            }
            GenWorldClosest.TryFindClosestTile(tile, predicate, out int result, 50, true);
            return(result);
        }
Ejemplo n.º 3
0
 private bool TryRecoverFromUnwalkablePosition()
 {
     if (GenWorldClosest.TryFindClosestTile(warObject.Tile, (int t) => IsPassable(t), out int foundTile))
     {
         Log.Warning(warObject + " on unwalkable tile " + warObject.Tile + ". Teleporting to " + foundTile);
         warObject.Tile = foundTile;
         warObject.Notify_Teleported();
         return(true);
     }
     Verse.Find.WorldObjects.Remove(warObject);
     Log.Error(warObject + " on unwalkable tile " + warObject.Tile + ". Could not find walkable position nearby. Removed.");
     return(false);
 }