Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ GetDistance()

static void Terraria.GameContent.UI.NewMultiplayerClosePlayersOverlay.GetDistance ( int testWidth,
int testHeight,
Vector2 testPosition,
Player localPlayer,
DynamicSpriteFont font,
Player player,
string nameToShow,
out Vector2 namePlatePos,
out float namePlateDist,
out Vector2 measurement )
inlinestaticprivate

Definition at line 200 of file NewMultiplayerClosePlayersOverlay.cs.

201 {
202 float uIScale = Main.UIScale;
203 SpriteViewMatrix gameViewMatrix = Main.GameViewMatrix;
204 namePlatePos = font.MeasureString(nameToShow);
205 float num = 0f;
206 if (player.chatOverhead.timeLeft > 0)
207 {
208 num = (0f - namePlatePos.Y) * uIScale;
209 }
210 else if (player.emoteTime > 0)
211 {
212 num = (0f - namePlatePos.Y) * uIScale;
213 }
214 Vector2 vector = new Vector2((float)(testWidth / 2) + testPosition.X, (float)(testHeight / 2) + testPosition.Y);
215 Vector2 position = player.position;
216 position += (position - vector) * (gameViewMatrix.Zoom - Vector2.One);
217 namePlateDist = 0f;
218 float num2 = position.X + (float)(player.width / 2) - vector.X;
219 float num3 = position.Y - namePlatePos.Y - 2f + num - vector.Y;
220 float num4 = (float)Math.Sqrt(num2 * num2 + num3 * num3);
221 int num5 = testHeight;
222 if (testHeight > testWidth)
223 {
224 num5 = testWidth;
225 }
226 num5 = num5 / 2 - 50;
227 if (num5 < 100)
228 {
229 num5 = 100;
230 }
231 if (num4 < (float)num5)
232 {
233 namePlatePos.X = position.X + (float)(player.width / 2) - namePlatePos.X / 2f - testPosition.X;
234 namePlatePos.Y = position.Y - namePlatePos.Y - 2f + num - testPosition.Y;
235 }
236 else
237 {
239 num4 = (float)num5 / num4;
240 namePlatePos.X = (float)(testWidth / 2) + num2 * num4 - namePlatePos.X / 2f;
241 namePlatePos.Y = (float)(testHeight / 2) + num3 * num4 + 40f * uIScale;
242 }
243 measurement = font.MeasureString(nameToShow);
244 namePlatePos += measurement / 2f;
245 namePlatePos *= 1f / uIScale;
246 namePlatePos -= measurement / 2f;
247 if (localPlayer.gravDir == -1f)
248 {
249 namePlatePos.Y = (float)testHeight - namePlatePos.Y;
250 }
251 }
static double Sqrt(double d)

References Terraria.Player.chatOverhead, Terraria.Player.emoteTime, Terraria.Main.GameViewMatrix, Microsoft.Xna.Framework.Vector2.One, Terraria.Entity.position, System.Math.Sqrt(), Terraria.Player.OverheadMessage.timeLeft, Terraria.Main.UIScale, Microsoft.Xna.Framework.Graphics.Vector2, and Terraria.Entity.width.

Referenced by Terraria.GameContent.UI.NewMultiplayerClosePlayersOverlay.Draw().