Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
MoonLordProgressBar.cs
Go to the documentation of this file.
4using Terraria.ID;
5
7
9{
11
13
14 private HashSet<int> ValidIds = new HashSet<int> { 396, 397, 398 };
15
17 {
18 _referenceDummy = new NPC();
19 }
20
22 {
23 if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200)
24 {
25 return false;
26 }
27 NPC nPC = Main.npc[info.npcIndexToAimAt];
28 if ((!nPC.active || IsInBadAI(nPC)) && !TryFindingAnotherMoonLordPiece(ref info))
29 {
30 return false;
31 }
32 int num = 0;
34 nPCSpawnParams.strengthMultiplierOverride = nPC.strengthMultiplier;
35 nPCSpawnParams.playerCountForMultiplayerDifficultyOverride = nPC.statsAreScaledForThisManyPlayers;
44 float num2 = 0f;
45 for (int i = 0; i < 200; i++)
46 {
47 NPC nPC2 = Main.npc[i];
48 if (nPC2.active && ValidIds.Contains(nPC2.type) && !IsInBadAI(nPC2))
49 {
50 num2 += (float)nPC2.life;
51 }
52 }
53 _cache.SetLife(num2, num);
54 return true;
55 }
56
57 private bool IsInBadAI(NPC npc)
58 {
59 if (npc.type == 398 && (npc.ai[0] == 2f || npc.ai[0] == -1f))
60 {
61 return true;
62 }
63 if (npc.type == 398 && npc.localAI[3] == 0f)
64 {
65 return true;
66 }
67 if (npc.ai[0] == -2f || npc.ai[0] == -3f)
68 {
69 return true;
70 }
71 return false;
72 }
73
74 public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
75 {
76 int num = NPCID.Sets.BossHeadTextures[396];
77 Texture2D value = TextureAssets.NpcHeadBoss[num].Value;
78 Rectangle barIconFrame = value.Frame();
80 }
81
83 {
84 for (int i = 0; i < 200; i++)
85 {
86 NPC nPC = Main.npc[i];
87 if (nPC.active && ValidIds.Contains(nPC.type) && !IsInBadAI(nPC))
88 {
89 info.npcIndexToAimAt = i;
90 return true;
91 }
92 }
93 return false;
94 }
95}
static Asset< Texture2D >[] NpcHeadBoss
static void DrawFancyBar(SpriteBatch spriteBatch, float lifeAmount, float lifeMax, Texture2D barIconTexture, Rectangle barIconFrame)
void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
static int[] BossHeadTextures
Definition NPCID.cs:4240
static NPC[] npc
Definition Main.cs:1685
void SetDefaults(int Type, NPCSpawnParams spawnparams=default(NPCSpawnParams))
Definition NPC.cs:2523
float[] localAI
Definition NPC.cs:449
int lifeMax
Definition NPC.cs:479
float[] ai
Definition NPC.cs:447
int type
Definition NPC.cs:445