// Returns the highest point in the world between this column and each neighbor column. private static int ComputeMaxY(int x, int z, int ray) { ray = Mathf.Max(ray, MapLight.GetRaySafe(x - 1, z)); ray = Mathf.Max(ray, MapLight.GetRaySafe(x + 1, z)); ray = Mathf.Max(ray, MapLight.GetRaySafe(x, z - 1)); ray = Mathf.Max(ray, MapLight.GetRaySafe(x, z + 1)); return(ray); }
protected Vector3 TryFindLand(Vector3i center) { Vector3i?land = null; for (int x = center.x - 20; x <= center.x + 20; x++) { for (int z = center.z - 20; z <= center.z + 20; z++) { int height = MapLight.GetRaySafe(x, z); Block surface = Map.GetBlockSafe(x, height - 1, z); if (!surface.IsFluid()) { Vector3i current = new Vector3i(x, height, z); if (!land.HasValue) { land = current; } else { int dis = center.DistanceSquared(current); int oldDis = center.DistanceSquared(land.Value); if (dis < oldDis) { land = current; } } } } } if (land.HasValue) { return(land.Value.ToVector3()); } return(new Vector3(center.x, MapLight.GetRay(center.x, center.z), center.z)); }