public static void GetExitMapEdges(WorldGrid grid, int fromTileID, int toTileID, out Rot4 primary, out Rot4 secondary) { primary = (secondary = Rot4.Invalid); int num = 0; float heading = grid.GetHeadingFromTo(fromTileID, toTileID); if (heading >= 292.5f || heading <= 67.5f) { rotTmp[num++] = Rot4.North; } else if (heading >= 112.5f && heading <= 247.5f) { rotTmp[num++] = Rot4.South; } if (heading >= 22.5f && heading <= 157.5f) { rotTmp[num++] = Rot4.East; } else if (heading >= 202.5f && heading <= 337.5f) { rotTmp[num++] = Rot4.West; } Array.Sort(rotTmp, (Rot4 r1, Rot4 r2) => Mathf.Abs(r1.AsAngle - heading).CompareTo(Mathf.Abs(r2.AsAngle - heading))); if (num >= 1) { primary = rotTmp[0]; } if (num >= 2) { secondary = rotTmp[1]; } }
public static List <int> AvailableExitTilesAt(Map map) { retTiles.Clear(); int currentTileID = map.Tile; World world = Find.World; WorldGrid grid = world.grid; grid.GetTileNeighbors(currentTileID, tmpNeighbors); for (int i = 0; i < tmpNeighbors.Count; i++) { int num = tmpNeighbors[i]; if (IsGoodCaravanStartingTile(num)) { GetExitMapEdges(grid, currentTileID, num, out Rot4 primary, out Rot4 secondary); if (((primary != Rot4.Invalid && CellFinder.TryFindRandomEdgeCellWith((IntVec3 x) => x.Walkable(map) && !x.Fogged(map), map, primary, CellFinder.EdgeRoadChance_Ignore, out IntVec3 result)) || (secondary != Rot4.Invalid && CellFinder.TryFindRandomEdgeCellWith((IntVec3 x) => x.Walkable(map) && !x.Fogged(map), map, secondary, CellFinder.EdgeRoadChance_Ignore, out result))) && !retTiles.Contains(num)) { retTiles.Add(num); } } } retTiles.SortBy((int x) => grid.GetHeadingFromTo(currentTileID, x)); return(retTiles); }
public static List <int> AvailableExitTilesAt(Map map) { retTiles.Clear(); int currentTileID = map.Tile; World world = Find.World; WorldGrid grid = world.grid; grid.GetTileNeighbors(currentTileID, tmpNeighbors); for (int i = 0; i < tmpNeighbors.Count; i++) { int num = tmpNeighbors[i]; if (IsGoodCaravanStartingTile(num)) { Rot4 rotFromTo = grid.GetRotFromTo(currentTileID, num); if (CellFinder.TryFindRandomEdgeCellWith((IntVec3 x) => x.Walkable(map) && !x.Fogged(map), map, rotFromTo, CellFinder.EdgeRoadChance_Ignore, out IntVec3 _)) { retTiles.Add(num); } } } retTiles.SortBy((int x) => grid.GetHeadingFromTo(currentTileID, x)); return(retTiles); }