Updated Regions.InAreaRegion.Name to allow overlapping regions - For plugins that use this it will require updating the code
This commit is contained in:
parent
62bc28332a
commit
6079d84c9e
2 changed files with 19 additions and 16 deletions
|
|
@ -258,19 +258,20 @@ namespace TShockAPI.DB
|
|||
return false;
|
||||
}
|
||||
|
||||
public string InAreaRegionName(int x, int y)
|
||||
{
|
||||
foreach (Region region in Regions)
|
||||
{
|
||||
if (x >= region.Area.Left && x <= region.Area.Right &&
|
||||
y >= region.Area.Top && y <= region.Area.Bottom &&
|
||||
region.DisableBuild)
|
||||
{
|
||||
return region.Name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public List<string> InAreaRegionName(int x, int y)
|
||||
{
|
||||
List<string> regions = new List<string>() { };
|
||||
foreach (Region region in Regions)
|
||||
{
|
||||
if (x >= region.Area.Left && x <= region.Area.Right &&
|
||||
y >= region.Area.Top && y <= region.Area.Bottom &&
|
||||
region.DisableBuild)
|
||||
{
|
||||
regions.Add(region.Name);
|
||||
}
|
||||
}
|
||||
return regions;
|
||||
}
|
||||
|
||||
public static List<string> ListIDs(string MergedIDs)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1197,13 +1197,15 @@ namespace TShockAPI
|
|||
|
||||
if (args.Player.AwaitingName)
|
||||
{
|
||||
if (TShock.Regions.InAreaRegionName(tileX, tileY) == null)
|
||||
{
|
||||
var protectedregions = TShock.Regions.InAreaRegionName(tileX, tileY);
|
||||
if (protectedregions.Count == 0)
|
||||
{
|
||||
args.Player.SendMessage("Region is not protected", Color.Yellow);
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Player.SendMessage("Region Name: " + TShock.Regions.InAreaRegionName(tileX, tileY), Color.Yellow);
|
||||
string regionlist = string.Join(",", protectedregions.ToArray());
|
||||
args.Player.SendMessage("Region Name(s): " + regionlist, Color.Yellow);
|
||||
}
|
||||
args.Player.SendTileSquare(tileX, tileY);
|
||||
args.Player.AwaitingName = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue