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

◆ Draw()

void Terraria.GameContent.UI.LegacyMultiplayerClosePlayersOverlay.Draw ( )
inline

Implements Terraria.GameContent.UI.IMultiplayerClosePlayersOverlay.

Definition at line 15 of file LegacyMultiplayerClosePlayersOverlay.cs.

16 {
17 int teamNamePlateDistance = Main.teamNamePlateDistance;
18 if (teamNamePlateDistance <= 0)
19 {
20 return;
21 }
22 SpriteBatch spriteBatch = Main.spriteBatch;
23 spriteBatch.End();
24 spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, null, null, Main.UIScaleMatrix);
26 int screenWidth = Main.screenWidth;
27 int screenHeight = Main.screenHeight;
28 Vector2 screenPosition = Main.screenPosition;
30 float uIScale = Main.UIScale;
31 int num = teamNamePlateDistance * 8;
32 Player[] player = Main.player;
33 int myPlayer = Main.myPlayer;
34 SpriteViewMatrix gameViewMatrix = Main.GameViewMatrix;
35 byte mouseTextColor = Main.mouseTextColor;
36 Color[] teamColor = Main.teamColor;
37 Camera camera = Main.Camera;
38 IPlayerRenderer playerRenderer = Main.PlayerRenderer;
39 Vector2 screenPosition2 = Main.screenPosition;
40 for (int i = 0; i < 255; i++)
41 {
42 if (!player[i].active || myPlayer == i || player[i].dead || player[myPlayer].team <= 0 || player[myPlayer].team != player[i].team)
43 {
44 continue;
45 }
46 string name = player[i].name;
47 Vector2 namePlatePos = FontAssets.MouseText.Value.MeasureString(name);
48 float num2 = 0f;
49 if (player[i].chatOverhead.timeLeft > 0)
50 {
51 num2 = (0f - namePlatePos.Y) * uIScale;
52 }
53 else if (player[i].emoteTime > 0)
54 {
55 num2 = (0f - namePlatePos.Y) * uIScale;
56 }
57 Vector2 vector = new Vector2((float)(screenWidth / 2) + screenPosition.X, (float)(screenHeight / 2) + screenPosition.Y);
58 Vector2 position = player[i].position;
59 position += (position - vector) * (gameViewMatrix.Zoom - Vector2.One);
60 float num3 = 0f;
61 float num4 = (float)(int)mouseTextColor / 255f;
62 Color namePlateColor = new Color((byte)((float)(int)teamColor[player[i].team].R * num4), (byte)((float)(int)teamColor[player[i].team].G * num4), (byte)((float)(int)teamColor[player[i].team].B * num4), mouseTextColor);
63 float num5 = position.X + (float)(player[i].width / 2) - vector.X;
64 float num6 = position.Y - namePlatePos.Y - 2f + num2 - vector.Y;
65 float num7 = (float)Math.Sqrt(num5 * num5 + num6 * num6);
66 int num8 = screenHeight;
67 if (screenHeight > screenWidth)
68 {
69 num8 = screenWidth;
70 }
71 num8 = num8 / 2 - 50;
72 if (num8 < 100)
73 {
74 num8 = 100;
75 }
76 if (num7 < (float)num8)
77 {
78 namePlatePos.X = position.X + (float)(player[i].width / 2) - namePlatePos.X / 2f - screenPosition.X;
79 namePlatePos.Y = position.Y - namePlatePos.Y - 2f + num2 - screenPosition.Y;
80 }
81 else
82 {
83 num3 = num7;
84 num7 = (float)num8 / num7;
85 namePlatePos.X = (float)(screenWidth / 2) + num5 * num7 - namePlatePos.X / 2f;
86 namePlatePos.Y = (float)(screenHeight / 2) + num6 * num7 + 40f * uIScale;
87 }
88 Vector2 vector2 = FontAssets.MouseText.Value.MeasureString(name);
89 namePlatePos += vector2 / 2f;
90 namePlatePos *= 1f / uIScale;
91 namePlatePos -= vector2 / 2f;
92 if (player[myPlayer].gravDir == -1f)
93 {
94 namePlatePos.Y = (float)screenHeight - namePlatePos.Y;
95 }
96 if (num3 > 0f)
97 {
98 float num9 = 20f;
99 float num10 = -27f;
100 num10 -= (vector2.X - 85f) / 2f;
101 num5 = player[i].Center.X - player[myPlayer].Center.X;
102 num6 = player[i].Center.Y - player[myPlayer].Center.Y;
103 float num11 = (float)Math.Sqrt(num5 * num5 + num6 * num6);
104 if (!(num11 > (float)num))
105 {
106 string textValue = Language.GetTextValue("GameUI.PlayerDistance", (int)(num11 / 16f * 2f));
107 Vector2 npDistPos = FontAssets.MouseText.Value.MeasureString(textValue);
108 npDistPos.X = namePlatePos.X - num10;
109 npDistPos.Y = namePlatePos.Y + vector2.Y / 2f - npDistPos.Y / 2f - num9;
110 DrawPlayerName2(spriteBatch, ref namePlateColor, textValue, ref npDistPos);
111 Color playerHeadBordersColor = Main.GetPlayerHeadBordersColor(player[i]);
112 Vector2 position2 = new Vector2(namePlatePos.X, namePlatePos.Y - num9);
113 position2.X -= 22f + num10;
114 position2.Y += 8f;
115 playerRenderer.DrawPlayerHead(camera, player[i], position2, 1f, 0.8f, playerHeadBordersColor);
116 Vector2 vector3 = npDistPos + screenPosition2 + new Vector2(26f, 20f);
117 if (player[i].statLife != player[i].statLifeMax2)
118 {
119 Main.instance.DrawHealthBar(vector3.X, vector3.Y, player[i].statLife, player[i].statLifeMax2, 1f, 1.25f, noFlip: true);
120 }
121 ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.MouseText.Value, name, namePlatePos + new Vector2(0f, -40f), namePlateColor, 0f, Vector2.Zero, Vector2.One);
122 }
123 }
124 else
125 {
126 DrawPlayerName(spriteBatch, name, ref namePlatePos, ref namePlateColor);
127 }
128 }
129 }
static double Sqrt(double d)
static void DrawPlayerName2(SpriteBatch spriteBatch, ref Color namePlateColor, string npDist, ref Vector2 npDistPos)
static void DrawPlayerName(SpriteBatch spriteBatch, string namePlate, ref Vector2 namePlatePos, ref Color namePlateColor)
static string GetTextValue(string key)
Definition Language.cs:15
static Vector2 DrawColorCodedStringWithShadow(SpriteBatch spriteBatch, DynamicSpriteFont font, TextSnippet[] snippets, Vector2 position, float rotation, Vector2 origin, Vector2 baseScale, out int hoveredSnippet, float maxWidth=-1f, float spread=2f)
void DrawPlayerHead(Camera camera, Player drawPlayer, Vector2 position, float alpha=1f, float scale=1f, Color borderColor=default(Color))

References System.B, Microsoft.Xna.Framework.Graphics.SpriteBatch.Begin(), Terraria.Main.Camera, Terraria.Entity.Center, Microsoft.Xna.Framework.Graphics.Color, Terraria.UI.Chat.ChatManager.DrawColorCodedStringWithShadow(), Terraria.Graphics.Renderers.IPlayerRenderer.DrawPlayerHead(), Terraria.GameContent.UI.LegacyMultiplayerClosePlayersOverlay.DrawPlayerName(), Terraria.GameContent.UI.LegacyMultiplayerClosePlayersOverlay.DrawPlayerName2(), Microsoft.Xna.Framework.Graphics.SpriteBatch.End(), System.G, Terraria.Main.GameViewMatrix, Terraria.Main.GetPlayerHeadBordersColor(), Terraria.Localization.Language.GetTextValue(), Terraria.Main.instance, Terraria.GameContent.FontAssets.MouseText, Terraria.Main.mouseTextColor, Terraria.Main.myPlayer, Terraria.Player.name, Microsoft.Xna.Framework.Vector2.One, Terraria.Main.player, Terraria.Main.PlayerRenderer, Terraria.Entity.position, System.R, Terraria.Main.screenHeight, Terraria.Main.screenPosition, Terraria.Main.screenWidth, Terraria.GameInput.PlayerInput.SetZoom_UI(), Terraria.GameInput.PlayerInput.SetZoom_World(), Terraria.Main.spriteBatch, System.Math.Sqrt(), Terraria.Player.statLife, Terraria.Player.statLifeMax2, Terraria.Main.teamColor, Terraria.Main.teamNamePlateDistance, Terraria.Main.UIScale, Terraria.Main.UIScaleMatrix, Microsoft.Xna.Framework.Graphics.Vector2, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Vector2.Y, Microsoft.Xna.Framework.Vector2.Zero, and Terraria.Graphics.SpriteViewMatrix.Zoom.