Пример #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, Direction8Way exitDir)
        {
            tileCandidates.Clear();
            World     world = Find.World;
            WorldGrid grid  = world.grid;

            grid.GetTileNeighbors(tileID, tmpNeighbors);
            for (int i = 0; i < tmpNeighbors.Count; i++)
            {
                int num = tmpNeighbors[i];
                if (IsGoodCaravanStartingTile(num) && grid.GetDirection8WayFromTo(tileID, num) == exitDir)
                {
                    tileCandidates.Add(num);
                }
            }
            if (tileCandidates.TryRandomElement(out int result))
            {
                return(result);
            }
            if (tmpNeighbors.Where(IsGoodCaravanStartingTile).TryRandomElement(out result))
            {
                return(result);
            }
            return(tileID);
        }
Пример #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);
        }