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

◆ DrawInterface_14_EntityHealthBars()

void Terraria.Main.DrawInterface_14_EntityHealthBars ( )
inlineprivate

Definition at line 42776 of file Main.cs.

42777 {
42778 if (HealthBarDrawSettings == 0)
42779 {
42780 return;
42781 }
42782 int num = -1;
42784 {
42786 for (int i = 0; i < 200; i++)
42787 {
42788 NPC nPC = npc[i];
42789 if ((nPC.life == nPC.lifeMax || nPC.dontTakeDamage) && !nPC.dontTakeDamage && nPC.nameOver > 0f && (num == -1 || nPC.Distance(localPlayer.Center) < npc[num].Distance(localPlayer.Center)))
42790 {
42791 num = i;
42792 }
42793 }
42794 }
42795 bool flag = false;
42796 for (int num2 = 199; num2 >= 0; num2--)
42797 {
42798 if (npc[num2].active && npc[num2].type > 0 && npc[num2].shimmerTransparency == 0f)
42799 {
42800 npc[num2].position += npc[num2].netOffset;
42801 if (npc[num2].life != npc[num2].lifeMax && !npc[num2].dontTakeDamage)
42802 {
42803 float scale = 1f;
42804 int type = npc[num2].type;
42805 if (type == 4)
42806 {
42807 scale = 1.5f;
42808 }
42809 if (type == 35)
42810 {
42811 scale = 1.5f;
42812 }
42813 if (type == 36)
42814 {
42815 scale = 1.5f;
42816 }
42817 if (type == 50)
42818 {
42819 scale = 1.5f;
42820 }
42821 if (type == 113)
42822 {
42823 scale = 1.5f;
42824 }
42825 if (type == 114)
42826 {
42827 scale = 1.5f;
42828 }
42829 if (type == 125)
42830 {
42831 scale = 1.5f;
42832 }
42833 if (type == 126)
42834 {
42835 scale = 1.5f;
42836 }
42837 if (type == 127)
42838 {
42839 scale = 1.5f;
42840 }
42841 if (type == 128)
42842 {
42843 scale = 1.5f;
42844 }
42845 if (type == 129)
42846 {
42847 scale = 1.5f;
42848 }
42849 if (type == 130)
42850 {
42851 scale = 1.5f;
42852 }
42853 if (type == 131)
42854 {
42855 scale = 1.5f;
42856 }
42857 if (type == 222)
42858 {
42859 scale = 1.5f;
42860 }
42861 if (type >= 245 && type <= 249)
42862 {
42863 scale = 1.5f;
42864 }
42865 if (type == 262)
42866 {
42867 scale = 1.5f;
42868 }
42869 if (type == 266)
42870 {
42871 scale = 1.5f;
42872 }
42873 if (type == 564 || type == 565 || type == 551 || type == 576 || type == 577)
42874 {
42875 scale = 1.5f;
42876 }
42877 if (type == 87)
42878 {
42879 scale = 1.5f;
42880 }
42881 if (type == 510 || type == 454 || type == 621)
42882 {
42883 scale = 1.5f;
42884 }
42885 if (type == 439 || type == 370)
42886 {
42887 scale = 1.5f;
42888 }
42889 float num3 = 10f;
42890 if (HealthBarDrawSettings == 2)
42891 {
42892 num3 -= 34f;
42893 }
42894 if ((!expertMode || type != 266) && ((type != 439 && type != 440) || npc[num2].ai[0] != 5f))
42895 {
42896 if (type >= 134 && type <= 136)
42897 {
42898 scale = 1.5f;
42899 if (!flag)
42900 {
42901 flag = true;
42902 Vector2 vector = default(Vector2);
42903 float num4 = 999999f;
42904 for (int j = 0; j < 200; j++)
42905 {
42906 if (npc[j].active && npc[j].type >= 134 && npc[j].type <= 136)
42907 {
42908 Vector2 vector2 = player[myPlayer].Center - npc[j].Center;
42909 if (vector2.Length() < num4 && Collision.CanHit(player[myPlayer].Center, 1, 1, npc[j].Center, 1, 1))
42910 {
42911 num4 = vector2.Length();
42912 vector = npc[j].position;
42913 }
42914 }
42915 }
42916 if (num4 < (float)screenWidth)
42917 {
42918 if (destroyerHB.X < 100f && destroyerHB.Y < 100f)
42919 {
42921 }
42922 else
42923 {
42924 destroyerHB = (destroyerHB * 49f + vector) / 50f;
42925 }
42927 int num5 = num2;
42928 if (type != 134 && npc[num2].realLife != -1)
42929 {
42930 num5 = npc[num2].realLife;
42931 }
42932 float num6 = Lighting.Brightness((int)((npc[num2].position.X + (float)(npc[num2].width / 2)) / 16f), (int)((npc[num2].position.Y + (float)(npc[num2].height / 2) + npc[num2].gfxOffY) / 16f));
42933 num6 = (num6 + 1f) / 2f;
42934 DrawHealthBar(vector.X + (float)(npc[num2].width / 2), vector.Y + (float)(npc[num2].height / 2), npc[num5].life, npc[num5].lifeMax, num6, scale);
42935 }
42936 else
42937 {
42938 destroyerHB = new Vector2(0f, 0f);
42939 }
42940 }
42941 }
42942 else
42943 {
42944 switch (type)
42945 {
42946 case 7:
42948 break;
42949 case 95:
42951 break;
42952 case 10:
42954 break;
42955 case 87:
42957 break;
42958 default:
42959 switch (type)
42960 {
42961 case 412:
42963 break;
42964 case 39:
42966 break;
42967 case 98:
42969 break;
42970 case 454:
42972 break;
42973 default:
42974 switch (type)
42975 {
42976 case 510:
42978 break;
42979 case 621:
42981 break;
42982 case 513:
42984 break;
42985 case 117:
42987 break;
42988 default:
42989 if (HealthBarDrawSettings == 1)
42990 {
42992 DrawHealthBar(npc[num2].position.X + (float)(npc[num2].width / 2), npc[num2].position.Y + (float)npc[num2].height + num3 + npc[num2].gfxOffY, npc[num2].life, npc[num2].lifeMax, Lighting.Brightness((int)((npc[num2].position.X + (float)(npc[num2].width / 2)) / 16f), (int)((npc[num2].position.Y + (float)(npc[num2].height / 2) + npc[num2].gfxOffY) / 16f)), scale);
42993 }
42994 else if (HealthBarDrawSettings == 2)
42995 {
42996 num3 -= NPCAddHeight(npc[num2]) / 2f;
42997 DrawHealthBar(npc[num2].position.X + (float)(npc[num2].width / 2), npc[num2].position.Y + num3 + npc[num2].gfxOffY, npc[num2].life, npc[num2].lifeMax, Lighting.Brightness((int)((npc[num2].position.X + (float)(npc[num2].width / 2)) / 16f), (int)((npc[num2].position.Y + (float)(npc[num2].height / 2) + npc[num2].gfxOffY) / 16f)), scale);
42998 }
42999 break;
43000 case 118:
43001 case 119:
43002 case 511:
43003 case 512:
43004 case 514:
43005 case 515:
43006 case 622:
43007 case 623:
43008 break;
43009 }
43010 break;
43011 case 40:
43012 case 41:
43013 case 99:
43014 case 100:
43015 case 413:
43016 case 414:
43017 case 455:
43018 case 456:
43019 case 457:
43020 case 458:
43021 case 459:
43022 break;
43023 }
43024 break;
43025 case 8:
43026 case 9:
43027 case 11:
43028 case 12:
43029 case 88:
43030 case 89:
43031 case 90:
43032 case 91:
43033 case 92:
43034 case 96:
43035 case 97:
43036 break;
43037 }
43038 }
43039 }
43040 }
43041 else if (!npc[num2].dontTakeDamage && npc[num2].nameOver > 0f && PlayerInput.UsingGamepad && num2 == num)
43042 {
43044 Vector2 vector3 = npc[num2].Bottom - screenPosition + new Vector2(0f, 10f);
43045 if (NPC.GetNPCLocation(num2, seekHead: true, averageDirection: true, out var _, out var pos))
43046 {
43047 vector3 = pos - screenPosition + new Vector2(0f, 10 + npc[num2].height / 2);
43048 if (player[myPlayer].gravDir == -1f)
43049 {
43050 vector3 = ReverseGravitySupport(vector3, -npc[num2].height - 20);
43051 }
43052 Vector2 origin = stringSize * new Vector2(0.5f, 0f);
43055 }
43056 }
43057 if (npc[num2].type == 548 && !npc[num2].dontTakeDamageFromHostiles && DD2Event.TimeLeftBetweenWaves > 0 && !hideUI)
43058 {
43059 Vector2 position = npc[num2].Bottom - screenPosition + new Vector2(0f, -100f);
43060 int num7 = DD2Event.TimeLeftBetweenWaves / 60;
43061 string text = $"{num7}";
43063 float num8 = 1f;
43064 Vector2 origin2 = value.MeasureString(text) * num8 * new Vector2(0.5f, 0.5f);
43066 }
43067 npc[num2].position -= npc[num2].netOffset;
43068 }
43069 }
43070 for (int k = 0; k < 255; k++)
43071 {
43072 if (k != myPlayer && player[k].active && !player[k].ghost && !player[k].dead && !player[k].invis && player[k].statLife != player[k].statLifeMax2)
43073 {
43074 if (HealthBarDrawSettings == 1)
43075 {
43076 int num9 = 10;
43077 DrawHealthBar(player[k].position.X + (float)(player[k].width / 2), player[k].position.Y + (float)player[k].height + (float)num9 + player[k].gfxOffY, player[k].statLife, player[k].statLifeMax2, player[k].stealth * Lighting.Brightness((int)((player[k].position.X + (float)(player[k].width / 2)) / 16f), (int)((player[k].position.Y + (float)(player[k].height / 2) + player[k].gfxOffY) / 16f)));
43078 }
43079 else if (HealthBarDrawSettings == 2)
43080 {
43081 int num10 = -20;
43082 DrawHealthBar(player[k].position.X + (float)(player[k].width / 2), player[k].position.Y + (float)num10 + player[k].gfxOffY, player[k].statLife, player[k].statLifeMax2, player[k].stealth * Lighting.Brightness((int)((player[k].position.X + (float)(player[k].width / 2)) / 16f), (int)((player[k].position.Y + (float)(player[k].height / 2) + player[k].gfxOffY) / 16f)));
43083 }
43084 }
43085 }
43086 }
static Asset< DynamicSpriteFont > MouseText
Definition FontAssets.cs:10
static SpriteBatch spriteBatch
Definition Main.cs:974
static int myPlayer
Definition Main.cs:1801
static Vector2 ReverseGravitySupport(Vector2 pos, float height=0f)
Definition Main.cs:3005
static bool expertMode
Definition Main.cs:2737
static byte HealthBarDrawSettings
Definition Main.cs:576
void DrawHealthBar(float X, float Y, int Health, int MaxHealth, float alpha, float scale=1f, bool noFlip=false)
Definition Main.cs:20399
static bool hideUI
Definition Main.cs:2219
static Vector2 screenPosition
Definition Main.cs:1715
static Vector2 destroyerHB
Definition Main.cs:355
static NPC[] npc
Definition Main.cs:1685
void DrawInterface_Healthbar_Worm(NPC head, int tailID, float scale)
Definition Main.cs:43088
static int screenWidth
Definition Main.cs:1719
static float NPCAddHeight(NPC theNPC)
Definition Main.cs:20492
static Player LocalPlayer
Definition Main.cs:2829
static Player[] player
Definition Main.cs:1803
static void DrawColorCodedStringShadow(SpriteBatch spriteBatch, DynamicSpriteFont font, TextSnippet[] snippets, Vector2 position, Color baseColor, float rotation, Vector2 origin, Vector2 baseScale, float maxWidth=-1f, float spread=2f)
static Vector2 DrawColorCodedString(SpriteBatch spriteBatch, DynamicSpriteFont font, TextSnippet[] snippets, Vector2 position, Color baseColor, float rotation, Vector2 origin, Vector2 baseScale, out int hoveredSnippet, float maxWidth, bool ignoreColors=false)
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)
static Vector2 GetStringSize(DynamicSpriteFont font, string text, Vector2 baseScale, float maxWidth=-1f)

References Microsoft.Xna.Framework.Color.Black, Terraria.Lighting.Brightness(), Terraria.Collision.CanHit(), Terraria.Main.destroyerHB, Terraria.UI.Chat.ChatManager.DrawColorCodedString(), Terraria.UI.Chat.ChatManager.DrawColorCodedStringShadow(), Terraria.UI.Chat.ChatManager.DrawColorCodedStringWithShadow(), Terraria.Main.DrawHealthBar(), Terraria.Main.DrawInterface_Healthbar_Worm(), Terraria.Main.expertMode, Terraria.NPC.GetNPCLocation(), Terraria.UI.Chat.ChatManager.GetStringSize(), Terraria.Main.HealthBarDrawSettings, Terraria.Main.hideUI, System.Text.RegularExpressions.i, Terraria.Main.LocalPlayer, Terraria.GameContent.FontAssets.MouseText, Terraria.Main.myPlayer, Terraria.Main.npc, Terraria.Main.NPCAddHeight(), Microsoft.Xna.Framework.Vector2.One, Terraria.Main.player, Terraria.Main.ReverseGravitySupport(), Terraria.Main.screenPosition, Terraria.Main.screenWidth, Terraria.Main.spriteBatch, System.text, Terraria.GameContent.Events.DD2Event.TimeLeftBetweenWaves, System.type, Terraria.GameInput.PlayerInput.UsingGamepad, System.value, Microsoft.Xna.Framework.Graphics.Vector2, and Microsoft.Xna.Framework.Color.White.

Referenced by Terraria.Main.SetupDrawInterfaceLayers().