From bddca1bc73077ccff0e4e73cff33c6fa105709dd Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Wed, 13 Jul 2011 22:38:55 -0600 Subject: [PATCH] Actually added the file this time. --- TShockAPI/Region.cs | 67 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 TShockAPI/Region.cs diff --git a/TShockAPI/Region.cs b/TShockAPI/Region.cs new file mode 100644 index 00000000..c64dfe5a --- /dev/null +++ b/TShockAPI/Region.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using TShockAPI.DB; + +namespace TShockAPI +{ + class Region + { + public int X1; + public int X2; + public int Y1; + public int Y2; + public int IsProtected; + public string[] UserIDs; + public Region(string tX1, string tX2, string tY1, string tY2, int tIsProtected, string[] tUserIDs) + { + X1 = Convert.ToInt32(tX1); + X2 = Convert.ToInt32(tX2); + Y1 = Convert.ToInt32(tY1); + Y2 = Convert.ToInt32(tY2); + IsProtected = tIsProtected; + UserIDs = tUserIDs; + } + + public Region(int tX1, int tX2, int tY1, int tY2, int tIsProtected, string[] tUserIDs) + { + X1 = Convert.ToInt32(tX1); + X2 = Convert.ToInt32(tX2); + Y1 = Convert.ToInt32(tY1); + Y2 = Convert.ToInt32(tY2); + IsProtected = tIsProtected; + UserIDs = tUserIDs; + } + + public Region(string tX1, string tX2, string tY1, string tY2) + { + X1 = Convert.ToInt32(tX1); + X2 = Convert.ToInt32(tX2); + Y1 = Convert.ToInt32(tY1); + Y2 = Convert.ToInt32(tY2); + } + + public Region(int tX1, int tX2, int tY1, int tY2) + { + X1 = Convert.ToInt32(tX1); + X2 = Convert.ToInt32(tX2); + Y1 = Convert.ToInt32(tY1); + Y2 = Convert.ToInt32(tY2); + } + + public bool InProtectedArea(int x, int y, User user) + { + if (x >= X1 && + x <= X2 && + y >= Y1 && + y <= Y2 && + IsProtected == 1) + { + if (!UserIDs.Contains(user.ID.ToString())) + return true; + } + return false; + } + } +}