diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index b3e91a02..4edf40d5 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1978,19 +1978,17 @@ namespace TShockAPI { Vector2 tile = new Vector2(x, y); Vector2 spawn = new Vector2(Main.spawnTileX, Main.spawnTileY); - return Distance(spawn, tile) <= Config.SpawnProtectionRadius; + return Utils.Distance(spawn, tile) <= Config.SpawnProtectionRadius; } /// Distance - Determines the distance between two vectors. /// value1 - The first vector location. /// value2 - The second vector location. /// float - The distance between the two vectors. + [Obsolete("Use TShock.Utils.Distance(Vector2, Vector2) instead.", true)] public static float Distance(Vector2 value1, Vector2 value2) { - float num2 = value1.X - value2.X; - float num = value1.Y - value2.Y; - float num3 = (num2 * num2) + (num * num); - return (float)Math.Sqrt(num3); + return Utils.Distance(value1, value2); } /// HackedInventory - Checks to see if a user has a hacked inventory. In addition, messages players the result. diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index eaa62dd3..5175934d 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -1456,5 +1456,17 @@ namespace TShockAPI empty ? 0 : ActivePlayers(), TShock.Config.MaxSlots, Main.worldName, Netplay.ServerIP.ToString(), Netplay.ListenPort, TShock.VersionNum); } + + /// Distance - Determines the distance between two vectors. + /// value1 - The first vector location. + /// value2 - The second vector location. + /// float - The distance between the two vectors. + public static float Distance(Vector2 value1, Vector2 value2) + { + float num2 = value1.X - value2.X; + float num = value1.Y - value2.Y; + float num3 = (num2 * num2) + (num * num); + return (float)Math.Sqrt(num3); + } } }