-Added "-d" parameter to "/region info". Use to display the given region's boundaries as wires.

This commit is contained in:
CoderCow 2013-07-01 20:06:17 +02:00
parent 8c23d68727
commit 33b1ca969b
2 changed files with 69 additions and 5 deletions

View file

@ -22,7 +22,8 @@ using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
using System.Text;
using TShockAPI.DB;
using Terraria;
namespace TShockAPI
@ -841,5 +842,25 @@ namespace TShockAPI
}
return new string(returnstr);
}
/// <summary>
/// Enumerates boundary points of the given region's rectangle.
/// </summary>
/// <param name="regionArea">The region's area to enumerate through.</param>
/// <returns>The enumerated boundary points.</returns>
public IEnumerable<Point> EnumerateRegionBoundaries(Rectangle regionArea)
{
for (int x = 0; x < regionArea.Width + 1; x++)
{
yield return new Point(regionArea.Left + x, regionArea.Top);
yield return new Point(regionArea.Left + x, regionArea.Bottom);
}
for (int y = 1; y < regionArea.Height; y++)
{
yield return new Point(regionArea.Left, regionArea.Top + y);
yield return new Point(regionArea.Right, regionArea.Top + y);
}
}
}
}