public static void DrawWorldRadiusRing(int center, int radius) { if (radius >= 0) { if (GenDraw.cachedEdgeTilesForCenter != center || GenDraw.cachedEdgeTilesForRadius != radius || GenDraw.cachedEdgeTilesForWorldSeed != Find.World.info.Seed) { GenDraw.cachedEdgeTilesForCenter = center; GenDraw.cachedEdgeTilesForRadius = radius; GenDraw.cachedEdgeTilesForWorldSeed = Find.World.info.Seed; GenDraw.cachedEdgeTiles.Clear(); Find.WorldFloodFiller.FloodFill(center, (int tile) => true, delegate(int tile, int dist) { bool result; if (dist > radius + 1) { result = true; } else { if (dist == radius + 1) { GenDraw.cachedEdgeTiles.Add(tile); } result = false; } return(result); }, int.MaxValue, null); WorldGrid worldGrid = Find.WorldGrid; Vector3 c = worldGrid.GetTileCenter(center); Vector3 n = c.normalized; GenDraw.cachedEdgeTiles.Sort(delegate(int a, int b) { float num = Vector3.Dot(n, Vector3.Cross(worldGrid.GetTileCenter(a) - c, worldGrid.GetTileCenter(b) - c)); int result; if (Mathf.Abs(num) < 0.0001f) { result = 0; } else if (num < 0f) { result = -1; } else { result = 1; } return(result); }); } GenDraw.DrawWorldLineStrip(GenDraw.cachedEdgeTiles, GenDraw.OneSidedWorldLineMatWhite, 5f); } }
public static void DrawWorldRadiusRing(int center, int radius) { if (radius >= 0) { if (GenDraw.cachedEdgeTilesForCenter != center || GenDraw.cachedEdgeTilesForRadius != radius || GenDraw.cachedEdgeTilesForWorldSeed != Find.World.info.Seed) { GenDraw.cachedEdgeTilesForCenter = center; GenDraw.cachedEdgeTilesForRadius = radius; GenDraw.cachedEdgeTilesForWorldSeed = Find.World.info.Seed; GenDraw.cachedEdgeTiles.Clear(); Find.WorldFloodFiller.FloodFill(center, (int tile) => true, delegate(int tile, int dist) { if (dist > radius + 1) { return(true); } if (dist == radius + 1) { GenDraw.cachedEdgeTiles.Add(tile); } return(false); }, 2147483647, null); WorldGrid worldGrid = Find.WorldGrid; Vector3 c = worldGrid.GetTileCenter(center); Vector3 i = c.normalized; GenDraw.cachedEdgeTiles.Sort(delegate(int a, int b) { float num = Vector3.Dot(i, Vector3.Cross(worldGrid.GetTileCenter(a) - c, worldGrid.GetTileCenter(b) - c)); if (Mathf.Abs(num) < 9.9999997473787516E-05) { return(0); } if (num < 0.0) { return(-1); } return(1); }); } GenDraw.DrawWorldLineStrip(GenDraw.cachedEdgeTiles, GenDraw.OneSidedWorldLineMatWhite, 5f); } }