예제 #1
0
        private static int FindRandomStartingTileBasedOnExitDir(int tileID, Direction8Way exitDir)
        {
            CaravanExitMapUtility.tileCandidates.Clear();
            World     world = Find.World;
            WorldGrid grid  = world.grid;

            grid.GetTileNeighbors(tileID, CaravanExitMapUtility.tmpNeighbors);
            for (int i = 0; i < CaravanExitMapUtility.tmpNeighbors.Count; i++)
            {
                int num = CaravanExitMapUtility.tmpNeighbors[i];
                if (CaravanExitMapUtility.IsGoodCaravanStartingTile(num))
                {
                    if (grid.GetDirection8WayFromTo(tileID, num) == exitDir)
                    {
                        CaravanExitMapUtility.tileCandidates.Add(num);
                    }
                }
            }
            int result;

            if (CaravanExitMapUtility.tileCandidates.TryRandomElement(out result))
            {
                return(result);
            }
            if (CaravanExitMapUtility.tmpNeighbors.Where(new Func <int, bool>(CaravanExitMapUtility.IsGoodCaravanStartingTile)).TryRandomElement(out result))
            {
                return(result);
            }
            return(tileID);
        }
예제 #2
0
        private static int FindRandomStartingTileBasedOnExitDir(int tileID, Rot4 exitDir)
        {
            CaravanExitMapUtility.tileCandidates.Clear();
            World     world = Find.World;
            WorldGrid grid  = world.grid;

            grid.GetTileNeighbors(tileID, CaravanExitMapUtility.tmpNeighbors);
            for (int i = 0; i < CaravanExitMapUtility.tmpNeighbors.Count; i++)
            {
                int num = CaravanExitMapUtility.tmpNeighbors[i];
                if (CaravanExitMapUtility.IsGoodCaravanStartingTile(num))
                {
                    if (!exitDir.IsValid || !(grid.GetRotFromTo(tileID, num) != exitDir))
                    {
                        CaravanExitMapUtility.tileCandidates.Add(num);
                    }
                }
            }
            int num2;
            int result;

            if (CaravanExitMapUtility.tileCandidates.TryRandomElement(out num2))
            {
                result = num2;
            }
            else if (CaravanExitMapUtility.tmpNeighbors.Where(delegate(int x)
            {
                bool result2;
                if (!CaravanExitMapUtility.IsGoodCaravanStartingTile(x))
                {
                    result2 = false;
                }
                else
                {
                    Rot4 rotFromTo = grid.GetRotFromTo(tileID, x);
                    result2 = (((exitDir == Rot4.North || exitDir == Rot4.South) && (rotFromTo == Rot4.East || rotFromTo == Rot4.West)) || ((exitDir == Rot4.East || exitDir == Rot4.West) && (rotFromTo == Rot4.North || rotFromTo == Rot4.South)));
                }
                return(result2);
            }).TryRandomElement(out num2))
            {
                result = num2;
            }
            else if ((from x in CaravanExitMapUtility.tmpNeighbors
                      where CaravanExitMapUtility.IsGoodCaravanStartingTile(x)
                      select x).TryRandomElement(out num2))
            {
                result = num2;
            }
            else
            {
                result = tileID;
            }
            return(result);
        }
예제 #3
0
        private static int FindRandomStartingTileBasedOnExitDir(int tileID, Direction8Way exitDir)
        {
            CaravanExitMapUtility.tileCandidates.Clear();
            World     world = Find.World;
            WorldGrid grid  = world.grid;

            grid.GetTileNeighbors(tileID, CaravanExitMapUtility.tmpNeighbors);
            for (int i = 0; i < CaravanExitMapUtility.tmpNeighbors.Count; i++)
            {
                int num = CaravanExitMapUtility.tmpNeighbors[i];
                if (CaravanExitMapUtility.IsGoodCaravanStartingTile(num))
                {
                    if (grid.GetDirection8WayFromTo(tileID, num) == exitDir)
                    {
                        CaravanExitMapUtility.tileCandidates.Add(num);
                    }
                }
            }
            int num2;
            int result;

            if (CaravanExitMapUtility.tileCandidates.TryRandomElement(out num2))
            {
                result = num2;
            }
            else if ((from x in CaravanExitMapUtility.tmpNeighbors
                      where CaravanExitMapUtility.IsGoodCaravanStartingTile(x)
                      select x).TryRandomElement(out num2))
            {
                result = num2;
            }
            else
            {
                result = tileID;
            }
            return(result);
        }
예제 #4
0
        public static List <int> AvailableExitTilesAt(Map map)
        {
            CaravanExitMapUtility.retTiles.Clear();
            int       currentTileID = map.Tile;
            World     world         = Find.World;
            WorldGrid grid          = world.grid;

            grid.GetTileNeighbors(currentTileID, CaravanExitMapUtility.tmpNeighbors);
            for (int i = 0; i < CaravanExitMapUtility.tmpNeighbors.Count; i++)
            {
                int num = CaravanExitMapUtility.tmpNeighbors[i];
                if (CaravanExitMapUtility.IsGoodCaravanStartingTile(num))
                {
                    Rot4    rotFromTo = grid.GetRotFromTo(currentTileID, num);
                    IntVec3 intVec;
                    if (CellFinder.TryFindRandomEdgeCellWith((IntVec3 x) => x.Walkable(map) && !x.Fogged(map), map, rotFromTo, CellFinder.EdgeRoadChance_Ignore, out intVec))
                    {
                        CaravanExitMapUtility.retTiles.Add(num);
                    }
                }
            }
            CaravanExitMapUtility.retTiles.SortBy((int x) => grid.GetHeadingFromTo(currentTileID, x));
            return(CaravanExitMapUtility.retTiles);
        }
예제 #5
0
 private static bool <FindRandomStartingTileBasedOnExitDir> m__3(int x)
 {
     return(CaravanExitMapUtility.IsGoodCaravanStartingTile(x));
 }