Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Distance() [1/2]

static float Terraria.Utils.Distance ( this Rectangle r,
Vector2 point )
inlinestatic

Definition at line 1008 of file Utils.cs.

1009 {
1010 if (FloatIntersect(r.Left, r.Top, r.Width, r.Height, point.X, point.Y, 0f, 0f))
1011 {
1012 return 0f;
1013 }
1014 if (point.X >= (float)r.Left && point.X <= (float)r.Right)
1015 {
1016 if (point.Y < (float)r.Top)
1017 {
1018 return (float)r.Top - point.Y;
1019 }
1020 return point.Y - (float)r.Bottom;
1021 }
1022 if (point.Y >= (float)r.Top && point.Y <= (float)r.Bottom)
1023 {
1024 if (point.X < (float)r.Left)
1025 {
1026 return (float)r.Left - point.X;
1027 }
1028 return point.X - (float)r.Right;
1029 }
1030 if (point.X < (float)r.Left)
1031 {
1032 if (point.Y < (float)r.Top)
1033 {
1034 return Vector2.Distance(point, r.TopLeft());
1035 }
1036 return Vector2.Distance(point, r.BottomLeft());
1037 }
1038 if (point.Y < (float)r.Top)
1039 {
1040 return Vector2.Distance(point, r.TopRight());
1041 }
1042 return Vector2.Distance(point, r.BottomRight());
1043 }
static bool FloatIntersect(float r1StartX, float r1StartY, float r1Width, float r1Height, float r2StartX, float r2StartY, float r2Width, float r2Height)
Definition Utils.cs:627
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91

References Microsoft.Xna.Framework.Vector2.Distance(), Terraria.Utils.FloatIntersect(), Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Y.