Terraria 1.4.0.5 Source Code

This commit is contained in:
MikeyIsBaeYT 2021-10-26 12:45:26 -04:00
commit 05205f009e
1059 changed files with 563450 additions and 0 deletions

View file

@ -0,0 +1,116 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.BigProgressBarHelper
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class BigProgressBarHelper
{
private const string _bossBarTexturePath = "Images/UI/UI_BossBar";
public static void DrawBareBonesBar(SpriteBatch spriteBatch, float lifePercent)
{
Rectangle destinationRectangle1 = Utils.CenteredRectangle(Main.ScreenSize.ToVector2() * new Vector2(0.5f, 1f) + new Vector2(0.0f, -50f), new Vector2(400f, 20f));
Rectangle destinationRectangle2 = destinationRectangle1;
destinationRectangle2.Inflate(2, 2);
Texture2D texture = TextureAssets.MagicPixel.Value;
Rectangle rectangle = new Rectangle(0, 0, 1, 1);
Rectangle destinationRectangle3 = destinationRectangle1;
destinationRectangle3.Width = (int) ((double) destinationRectangle3.Width * (double) lifePercent);
spriteBatch.Draw(texture, destinationRectangle2, new Rectangle?(rectangle), Color.White * 0.6f);
spriteBatch.Draw(texture, destinationRectangle1, new Rectangle?(rectangle), Color.Black * 0.6f);
spriteBatch.Draw(texture, destinationRectangle3, new Rectangle?(rectangle), Color.LimeGreen * 0.5f);
}
public static void DrawFancyBar(
SpriteBatch spriteBatch,
float lifePercent,
Texture2D barIconTexture,
Rectangle barIconFrame)
{
Texture2D texture2D = Main.Assets.Request<Texture2D>("Images/UI/UI_BossBar", (AssetRequestMode) 1).Value;
Point p1 = new Point(456, 22);
Point p2 = new Point(32, 24);
int verticalFrames = 6;
Rectangle rectangle1 = texture2D.Frame(verticalFrames: verticalFrames, frameY: 3);
Color color = Color.White * 0.2f;
int num1 = (int) ((double) p1.X * (double) lifePercent);
int num2 = num1 - num1 % 2;
Rectangle rectangle2 = texture2D.Frame(verticalFrames: verticalFrames, frameY: 2);
rectangle2.X += p2.X;
rectangle2.Y += p2.Y;
rectangle2.Width = 2;
rectangle2.Height = p1.Y;
Rectangle rectangle3 = texture2D.Frame(verticalFrames: verticalFrames, frameY: 1);
rectangle3.X += p2.X;
rectangle3.Y += p2.Y;
rectangle3.Width = 2;
rectangle3.Height = p1.Y;
Rectangle r = Utils.CenteredRectangle(Main.ScreenSize.ToVector2() * new Vector2(0.5f, 1f) + new Vector2(0.0f, -50f), p1.ToVector2());
Vector2 position = r.TopLeft() - p2.ToVector2();
spriteBatch.Draw(texture2D, position, new Rectangle?(rectangle1), color, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
spriteBatch.Draw(texture2D, r.TopLeft(), new Rectangle?(rectangle2), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (num2 / rectangle2.Width), 1f), SpriteEffects.None, 0.0f);
spriteBatch.Draw(texture2D, r.TopLeft() + new Vector2((float) (num2 - 2), 0.0f), new Rectangle?(rectangle3), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
Rectangle rectangle4 = texture2D.Frame(verticalFrames: verticalFrames);
spriteBatch.Draw(texture2D, position, new Rectangle?(rectangle4), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
Vector2 vector2 = new Vector2(4f, 20f) + new Vector2(26f, 28f) / 2f;
spriteBatch.Draw(barIconTexture, position + vector2, new Rectangle?(barIconFrame), Color.White, 0.0f, barIconFrame.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
}
public static void DrawFancyBar(
SpriteBatch spriteBatch,
float lifePercent,
Texture2D barIconTexture,
Rectangle barIconFrame,
float shieldPercent)
{
Texture2D texture2D = Main.Assets.Request<Texture2D>("Images/UI/UI_BossBar", (AssetRequestMode) 1).Value;
Point p1 = new Point(456, 22);
Point p2 = new Point(32, 24);
int verticalFrames = 6;
Rectangle rectangle1 = texture2D.Frame(verticalFrames: verticalFrames, frameY: 3);
Color color = Color.White * 0.2f;
int num1 = (int) ((double) p1.X * (double) lifePercent);
int num2 = num1 - num1 % 2;
Rectangle rectangle2 = texture2D.Frame(verticalFrames: verticalFrames, frameY: 2);
rectangle2.X += p2.X;
rectangle2.Y += p2.Y;
rectangle2.Width = 2;
rectangle2.Height = p1.Y;
Rectangle rectangle3 = texture2D.Frame(verticalFrames: verticalFrames, frameY: 1);
rectangle3.X += p2.X;
rectangle3.Y += p2.Y;
rectangle3.Width = 2;
rectangle3.Height = p1.Y;
int num3 = (int) ((double) p1.X * (double) shieldPercent);
int num4 = num3 - num3 % 2;
Rectangle rectangle4 = texture2D.Frame(verticalFrames: verticalFrames, frameY: 5);
rectangle4.X += p2.X;
rectangle4.Y += p2.Y;
rectangle4.Width = 2;
rectangle4.Height = p1.Y;
Rectangle rectangle5 = texture2D.Frame(verticalFrames: verticalFrames, frameY: 4);
rectangle5.X += p2.X;
rectangle5.Y += p2.Y;
rectangle5.Width = 2;
rectangle5.Height = p1.Y;
Rectangle r = Utils.CenteredRectangle(Main.ScreenSize.ToVector2() * new Vector2(0.5f, 1f) + new Vector2(0.0f, -50f), p1.ToVector2());
Vector2 position = r.TopLeft() - p2.ToVector2();
spriteBatch.Draw(texture2D, position, new Rectangle?(rectangle1), color, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
spriteBatch.Draw(texture2D, r.TopLeft(), new Rectangle?(rectangle2), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (num2 / rectangle2.Width), 1f), SpriteEffects.None, 0.0f);
spriteBatch.Draw(texture2D, r.TopLeft() + new Vector2((float) (num2 - 2), 0.0f), new Rectangle?(rectangle3), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
spriteBatch.Draw(texture2D, r.TopLeft(), new Rectangle?(rectangle4), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (num4 / rectangle4.Width), 1f), SpriteEffects.None, 0.0f);
spriteBatch.Draw(texture2D, r.TopLeft() + new Vector2((float) (num4 - 2), 0.0f), new Rectangle?(rectangle5), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
Rectangle rectangle6 = texture2D.Frame(verticalFrames: verticalFrames);
spriteBatch.Draw(texture2D, position, new Rectangle?(rectangle6), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
Vector2 vector2 = new Vector2(4f, 20f) + barIconFrame.Size() / 2f;
spriteBatch.Draw(barIconTexture, position + vector2, new Rectangle?(barIconFrame), Color.White, 0.0f, barIconFrame.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
}
}
}

View file

@ -0,0 +1,14 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.BigProgressBarInfo
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.GameContent.UI.BigProgressBar
{
public struct BigProgressBarInfo
{
public int npcIndexToAimAt;
public bool validatedAtLeastOnce;
}
}

View file

@ -0,0 +1,185 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.BigProgressBarSystem
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class BigProgressBarSystem
{
private IBigProgressBar _currentBar;
private CommonBossBigProgressBar _bossBar = new CommonBossBigProgressBar();
private BigProgressBarInfo _info;
private static TwinsBigProgressBar _twinsBar = new TwinsBigProgressBar();
private static EaterOfWorldsProgressBar _eaterOfWorldsBar = new EaterOfWorldsProgressBar();
private static BrainOfCthuluBigProgressBar _brainOfCthuluBar = new BrainOfCthuluBigProgressBar();
private static GolemHeadProgressBar _golemBar = new GolemHeadProgressBar();
private static MoonLordProgressBar _moonlordBar = new MoonLordProgressBar();
private static SolarFlarePillarBigProgressBar _solarPillarBar = new SolarFlarePillarBigProgressBar();
private static VortexPillarBigProgressBar _vortexPillarBar = new VortexPillarBigProgressBar();
private static NebulaPillarBigProgressBar _nebulaPillarBar = new NebulaPillarBigProgressBar();
private static StardustPillarBigProgressBar _stardustPillarBar = new StardustPillarBigProgressBar();
private static NeverValidProgressBar _neverValid = new NeverValidProgressBar();
private static PirateShipBigProgressBar _pirateShipBar = new PirateShipBigProgressBar();
private static MartianSaucerBigProgressBar _martianSaucerBar = new MartianSaucerBigProgressBar();
private Dictionary<int, IBigProgressBar> _bossBarsByNpcNetId = new Dictionary<int, IBigProgressBar>()
{
{
125,
(IBigProgressBar) BigProgressBarSystem._twinsBar
},
{
126,
(IBigProgressBar) BigProgressBarSystem._twinsBar
},
{
13,
(IBigProgressBar) BigProgressBarSystem._eaterOfWorldsBar
},
{
14,
(IBigProgressBar) BigProgressBarSystem._eaterOfWorldsBar
},
{
15,
(IBigProgressBar) BigProgressBarSystem._eaterOfWorldsBar
},
{
266,
(IBigProgressBar) BigProgressBarSystem._brainOfCthuluBar
},
{
245,
(IBigProgressBar) BigProgressBarSystem._golemBar
},
{
246,
(IBigProgressBar) BigProgressBarSystem._golemBar
},
{
517,
(IBigProgressBar) BigProgressBarSystem._solarPillarBar
},
{
422,
(IBigProgressBar) BigProgressBarSystem._vortexPillarBar
},
{
507,
(IBigProgressBar) BigProgressBarSystem._nebulaPillarBar
},
{
493,
(IBigProgressBar) BigProgressBarSystem._stardustPillarBar
},
{
398,
(IBigProgressBar) BigProgressBarSystem._moonlordBar
},
{
396,
(IBigProgressBar) BigProgressBarSystem._moonlordBar
},
{
397,
(IBigProgressBar) BigProgressBarSystem._moonlordBar
},
{
548,
(IBigProgressBar) BigProgressBarSystem._neverValid
},
{
549,
(IBigProgressBar) BigProgressBarSystem._neverValid
},
{
491,
(IBigProgressBar) BigProgressBarSystem._pirateShipBar
},
{
492,
(IBigProgressBar) BigProgressBarSystem._pirateShipBar
},
{
440,
(IBigProgressBar) BigProgressBarSystem._neverValid
},
{
395,
(IBigProgressBar) BigProgressBarSystem._martianSaucerBar
},
{
393,
(IBigProgressBar) BigProgressBarSystem._martianSaucerBar
},
{
394,
(IBigProgressBar) BigProgressBarSystem._martianSaucerBar
},
{
68,
(IBigProgressBar) BigProgressBarSystem._neverValid
}
};
public void Update()
{
if (this._currentBar == null)
this.TryFindingNPCToTrack();
if (this._currentBar == null || this._currentBar.ValidateAndCollectNecessaryInfo(ref this._info))
return;
this._currentBar = (IBigProgressBar) null;
}
public void Draw(SpriteBatch spriteBatch)
{
if (this._currentBar == null)
return;
this._currentBar.Draw(ref this._info, spriteBatch);
}
private void TryFindingNPCToTrack()
{
Rectangle rectangle = new Rectangle((int) Main.screenPosition.X, (int) Main.screenPosition.Y, Main.screenWidth, Main.screenHeight);
rectangle.Inflate(5000, 5000);
float num1 = float.PositiveInfinity;
for (int npcIndex = 0; npcIndex < 200; ++npcIndex)
{
NPC npc = Main.npc[npcIndex];
if (npc.active && npc.Hitbox.Intersects(rectangle))
{
float num2 = npc.Distance(Main.LocalPlayer.Center);
if ((double) num1 > (double) num2 && this.TryTracking(npcIndex))
num1 = num2;
}
}
}
public bool TryTracking(int npcIndex)
{
if (npcIndex < 0 || npcIndex > 200)
return false;
NPC npc = Main.npc[npcIndex];
if (!npc.active)
return false;
BigProgressBarInfo info = new BigProgressBarInfo()
{
npcIndexToAimAt = npcIndex
};
IBigProgressBar bigProgressBar1 = (IBigProgressBar) this._bossBar;
IBigProgressBar bigProgressBar2;
if (this._bossBarsByNpcNetId.TryGetValue(npc.netID, out bigProgressBar2))
bigProgressBar1 = bigProgressBar2;
if (!bigProgressBar1.ValidateAndCollectNecessaryInfo(ref info))
return false;
this._currentBar = bigProgressBar1;
this._info = info;
return true;
}
}
}

View file

@ -0,0 +1,49 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.BrainOfCthuluBigProgressBar
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.ID;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class BrainOfCthuluBigProgressBar : IBigProgressBar
{
private float _lifePercentToShow;
private NPC _creeperForReference;
public BrainOfCthuluBigProgressBar() => this._creeperForReference = new NPC();
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info)
{
if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200)
return false;
NPC npc1 = Main.npc[info.npcIndexToAimAt];
if (!npc1.active)
return false;
int cthuluCreepersCount = NPC.GetBrainOfCthuluCreepersCount();
this._creeperForReference.SetDefaults(267, npc1.GetMatchingSpawnParams());
int num1 = this._creeperForReference.lifeMax * cthuluCreepersCount;
float num2 = 0.0f;
for (int index = 0; index < 200; ++index)
{
NPC npc2 = Main.npc[index];
if (npc2.active && npc2.type == this._creeperForReference.type)
num2 += (float) npc2.life;
}
this._lifePercentToShow = Utils.Clamp<float>(((float) npc1.life + num2) / (float) (npc1.lifeMax + num1), 0.0f, 1f);
return true;
}
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
int bossHeadTexture = NPCID.Sets.BossHeadTextures[266];
Texture2D texture2D = TextureAssets.NpcHeadBoss[bossHeadTexture].Value;
Rectangle barIconFrame = texture2D.Frame();
BigProgressBarHelper.DrawFancyBar(spriteBatch, this._lifePercentToShow, texture2D, barIconFrame);
}
}
}

View file

@ -0,0 +1,39 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.CommonBossBigProgressBar
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class CommonBossBigProgressBar : IBigProgressBar
{
private float _lifePercentToShow;
private int _headIndex;
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info)
{
if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200)
return false;
NPC npc = Main.npc[info.npcIndexToAimAt];
if (!npc.active)
return false;
int headTextureIndex = npc.GetBossHeadTextureIndex();
if (headTextureIndex == -1)
return false;
this._lifePercentToShow = Utils.Clamp<float>((float) npc.life / (float) npc.lifeMax, 0.0f, 1f);
this._headIndex = headTextureIndex;
return true;
}
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
Texture2D texture2D = TextureAssets.NpcHeadBoss[this._headIndex].Value;
Rectangle barIconFrame = texture2D.Frame();
BigProgressBarHelper.DrawFancyBar(spriteBatch, this._lifePercentToShow, texture2D, barIconFrame);
}
}
}

View file

@ -0,0 +1,55 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.EaterOfWorldsProgressBar
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.ID;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class EaterOfWorldsProgressBar : IBigProgressBar
{
private float _lifePercentToShow;
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info)
{
if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200 || !Main.npc[info.npcIndexToAimAt].active && !this.TryFindingAnotherEOWPiece(ref info))
return false;
int worldsSegmentsCount = NPC.GetEaterOfWorldsSegmentsCount();
float num = 0.0f;
for (int index = 0; index < 200; ++index)
{
NPC npc = Main.npc[index];
if (npc.active && npc.type >= 13 && npc.type <= 15)
num += (float) npc.life / (float) npc.lifeMax;
}
this._lifePercentToShow = Utils.Clamp<float>(num / (float) worldsSegmentsCount, 0.0f, 1f);
return true;
}
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
int bossHeadTexture = NPCID.Sets.BossHeadTextures[13];
Texture2D texture2D = TextureAssets.NpcHeadBoss[bossHeadTexture].Value;
Rectangle barIconFrame = texture2D.Frame();
BigProgressBarHelper.DrawFancyBar(spriteBatch, this._lifePercentToShow, texture2D, barIconFrame);
}
private bool TryFindingAnotherEOWPiece(ref BigProgressBarInfo info)
{
for (int index = 0; index < 200; ++index)
{
NPC npc = Main.npc[index];
if (npc.active && npc.type >= 13 && npc.type <= 15)
{
info.npcIndexToAimAt = index;
return true;
}
}
return false;
}
}
}

View file

@ -0,0 +1,71 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.GolemHeadProgressBar
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
using Terraria.ID;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class GolemHeadProgressBar : IBigProgressBar
{
private float _lifePercentToShow;
private NPC _referenceDummy;
private HashSet<int> ValidIds = new HashSet<int>()
{
246,
245
};
public GolemHeadProgressBar() => this._referenceDummy = new NPC();
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info)
{
if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200)
return false;
NPC npc1 = Main.npc[info.npcIndexToAimAt];
if (!npc1.active && !this.TryFindingAnotherGolemPiece(ref info))
return false;
int num1 = 0;
this._referenceDummy.SetDefaults(245, npc1.GetMatchingSpawnParams());
int num2 = num1 + this._referenceDummy.lifeMax;
this._referenceDummy.SetDefaults(246, npc1.GetMatchingSpawnParams());
int num3 = num2 + this._referenceDummy.lifeMax;
float num4 = 0.0f;
for (int index = 0; index < 200; ++index)
{
NPC npc2 = Main.npc[index];
if (npc2.active && this.ValidIds.Contains(npc2.type))
num4 += (float) npc2.life;
}
this._lifePercentToShow = Utils.Clamp<float>(num4 / (float) num3, 0.0f, 1f);
return true;
}
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
int bossHeadTexture = NPCID.Sets.BossHeadTextures[246];
Texture2D texture2D = TextureAssets.NpcHeadBoss[bossHeadTexture].Value;
Rectangle barIconFrame = texture2D.Frame();
BigProgressBarHelper.DrawFancyBar(spriteBatch, this._lifePercentToShow, texture2D, barIconFrame);
}
private bool TryFindingAnotherGolemPiece(ref BigProgressBarInfo info)
{
for (int index = 0; index < 200; ++index)
{
NPC npc = Main.npc[index];
if (npc.active && this.ValidIds.Contains(npc.type))
{
info.npcIndexToAimAt = index;
return true;
}
}
return false;
}
}
}

View file

@ -0,0 +1,17 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.IBigProgressBar
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework.Graphics;
namespace Terraria.GameContent.UI.BigProgressBar
{
internal interface IBigProgressBar
{
bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info);
void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch);
}
}

View file

@ -0,0 +1,50 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.LunarPillarBigProgessBar
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Terraria.GameContent.UI.BigProgressBar
{
public abstract class LunarPillarBigProgessBar : IBigProgressBar
{
private float _lifePercentToShow;
private float _shieldPercentToShow;
private int _headIndex;
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info)
{
if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200)
return false;
NPC npc = Main.npc[info.npcIndexToAimAt];
if (!npc.active)
return false;
int headTextureIndex = npc.GetBossHeadTextureIndex();
if (headTextureIndex == -1 || !this.IsPlayerInCombatArea() || (double) npc.ai[2] == 1.0)
return false;
float num1 = Utils.Clamp<float>((float) npc.life / (float) npc.lifeMax, 0.0f, 1f);
float num2 = this.GetCurrentShieldValue() / this.GetMaxShieldValue();
double num3 = 600.0 * (double) Main.GameModeInfo.EnemyMaxLifeMultiplier * (double) this.GetMaxShieldValue() / (double) npc.lifeMax;
this._lifePercentToShow = num1;
this._shieldPercentToShow = num2;
this._headIndex = headTextureIndex;
return true;
}
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
Texture2D texture2D = TextureAssets.NpcHeadBoss[this._headIndex].Value;
Rectangle barIconFrame = texture2D.Frame();
BigProgressBarHelper.DrawFancyBar(spriteBatch, this._lifePercentToShow, texture2D, barIconFrame, this._shieldPercentToShow);
}
internal abstract float GetCurrentShieldValue();
internal abstract float GetMaxShieldValue();
internal abstract bool IsPlayerInCombatArea();
}
}

View file

@ -0,0 +1,85 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.MartianSaucerBigProgressBar
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
using Terraria.ID;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class MartianSaucerBigProgressBar : IBigProgressBar
{
private float _lifePercentToShow;
private NPC _referenceDummy;
private HashSet<int> ValidIds = new HashSet<int>()
{
395
};
private HashSet<int> ValidIdsToScanHp = new HashSet<int>()
{
395,
393,
394
};
public MartianSaucerBigProgressBar() => this._referenceDummy = new NPC();
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info)
{
if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200)
return false;
NPC npc1 = Main.npc[info.npcIndexToAimAt];
if (!npc1.active || npc1.type != 395)
{
if (!this.TryFindingAnotherMartianSaucerPiece(ref info))
return false;
npc1 = Main.npc[info.npcIndexToAimAt];
}
int num1 = 0;
if (Main.expertMode)
{
this._referenceDummy.SetDefaults(395, npc1.GetMatchingSpawnParams());
num1 += this._referenceDummy.lifeMax;
}
this._referenceDummy.SetDefaults(394, npc1.GetMatchingSpawnParams());
int num2 = num1 + this._referenceDummy.lifeMax * 2;
this._referenceDummy.SetDefaults(393, npc1.GetMatchingSpawnParams());
int num3 = num2 + this._referenceDummy.lifeMax * 2;
float num4 = 0.0f;
for (int index = 0; index < 200; ++index)
{
NPC npc2 = Main.npc[index];
if (npc2.active && this.ValidIdsToScanHp.Contains(npc2.type) && (Main.expertMode || npc2.type != 395))
num4 += (float) npc2.life;
}
this._lifePercentToShow = Utils.Clamp<float>(num4 / (float) num3, 0.0f, 1f);
return true;
}
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
int bossHeadTexture = NPCID.Sets.BossHeadTextures[395];
Texture2D texture2D = TextureAssets.NpcHeadBoss[bossHeadTexture].Value;
Rectangle barIconFrame = texture2D.Frame();
BigProgressBarHelper.DrawFancyBar(spriteBatch, this._lifePercentToShow, texture2D, barIconFrame);
}
private bool TryFindingAnotherMartianSaucerPiece(ref BigProgressBarInfo info)
{
for (int index = 0; index < 200; ++index)
{
NPC npc = Main.npc[index];
if (npc.active && this.ValidIds.Contains(npc.type))
{
info.npcIndexToAimAt = index;
return true;
}
}
return false;
}
}
}

View file

@ -0,0 +1,81 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.MoonLordProgressBar
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
using Terraria.ID;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class MoonLordProgressBar : IBigProgressBar
{
private float _lifePercentToShow;
private NPC _referenceDummy;
private HashSet<int> ValidIds = new HashSet<int>()
{
396,
397,
398
};
public MoonLordProgressBar() => this._referenceDummy = new NPC();
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info)
{
if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200)
return false;
NPC npc1 = Main.npc[info.npcIndexToAimAt];
if ((!npc1.active || this.IsInBadAI(npc1)) && !this.TryFindingAnotherMoonLordPiece(ref info))
return false;
int num1 = 0;
NPCSpawnParams spawnparams = new NPCSpawnParams()
{
strengthMultiplierOverride = new float?(npc1.strengthMultiplier),
playerCountForMultiplayerDifficultyOverride = new int?(npc1.statsAreScaledForThisManyPlayers)
};
this._referenceDummy.SetDefaults(398, spawnparams);
int num2 = num1 + this._referenceDummy.lifeMax;
this._referenceDummy.SetDefaults(396, spawnparams);
int num3 = num2 + this._referenceDummy.lifeMax;
this._referenceDummy.SetDefaults(397, spawnparams);
int num4 = num3 + this._referenceDummy.lifeMax + this._referenceDummy.lifeMax;
float num5 = 0.0f;
for (int index = 0; index < 200; ++index)
{
NPC npc2 = Main.npc[index];
if (npc2.active && this.ValidIds.Contains(npc2.type) && !this.IsInBadAI(npc2))
num5 += (float) npc2.life;
}
this._lifePercentToShow = Utils.Clamp<float>(num5 / (float) num4, 0.0f, 1f);
return true;
}
private bool IsInBadAI(NPC npc) => npc.type == 398 && ((double) npc.ai[0] == 2.0 || (double) npc.ai[0] == -1.0) || (double) npc.ai[0] == -2.0 || (double) npc.ai[0] == -3.0;
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
int bossHeadTexture = NPCID.Sets.BossHeadTextures[396];
Texture2D texture2D = TextureAssets.NpcHeadBoss[bossHeadTexture].Value;
Rectangle barIconFrame = texture2D.Frame();
BigProgressBarHelper.DrawFancyBar(spriteBatch, this._lifePercentToShow, texture2D, barIconFrame);
}
private bool TryFindingAnotherMoonLordPiece(ref BigProgressBarInfo info)
{
for (int index = 0; index < 200; ++index)
{
NPC npc = Main.npc[index];
if (npc.active && this.ValidIds.Contains(npc.type) && !this.IsInBadAI(npc))
{
info.npcIndexToAimAt = index;
return true;
}
}
return false;
}
}
}

View file

@ -0,0 +1,17 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.NebulaPillarBigProgressBar
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.GameContent.UI.BigProgressBar
{
public class NebulaPillarBigProgressBar : LunarPillarBigProgessBar
{
internal override float GetCurrentShieldValue() => (float) NPC.ShieldStrengthTowerNebula;
internal override float GetMaxShieldValue() => (float) NPC.ShieldStrengthTowerMax;
internal override bool IsPlayerInCombatArea() => Main.LocalPlayer.ZoneTowerNebula;
}
}

View file

@ -0,0 +1,19 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.NeverValidProgressBar
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework.Graphics;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class NeverValidProgressBar : IBigProgressBar
{
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info) => false;
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
}
}
}

View file

@ -0,0 +1,76 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.PirateShipBigProgressBar
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
using Terraria.ID;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class PirateShipBigProgressBar : IBigProgressBar
{
private float _lifePercentToShow;
private NPC _referenceDummy;
private HashSet<int> ValidIds = new HashSet<int>()
{
491
};
public PirateShipBigProgressBar() => this._referenceDummy = new NPC();
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info)
{
if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200)
return false;
NPC npc1 = Main.npc[info.npcIndexToAimAt];
if (!npc1.active || npc1.type != 491)
{
if (!this.TryFindingAnotherPirateShipPiece(ref info))
return false;
npc1 = Main.npc[info.npcIndexToAimAt];
}
int num1 = 0;
this._referenceDummy.SetDefaults(492, npc1.GetMatchingSpawnParams());
int num2 = num1 + this._referenceDummy.lifeMax * 4;
float num3 = 0.0f;
for (int index1 = 0; index1 < 4; ++index1)
{
int index2 = (int) npc1.ai[index1];
if (Main.npc.IndexInRange<NPC>(index2))
{
NPC npc2 = Main.npc[index2];
if (npc2.active && npc2.type == 492)
num3 += (float) npc2.life;
}
}
this._lifePercentToShow = Utils.Clamp<float>(num3 / (float) num2, 0.0f, 1f);
return true;
}
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
int bossHeadTexture = NPCID.Sets.BossHeadTextures[491];
Texture2D texture2D = TextureAssets.NpcHeadBoss[bossHeadTexture].Value;
Rectangle barIconFrame = texture2D.Frame();
BigProgressBarHelper.DrawFancyBar(spriteBatch, this._lifePercentToShow, texture2D, barIconFrame);
}
private bool TryFindingAnotherPirateShipPiece(ref BigProgressBarInfo info)
{
for (int index = 0; index < 200; ++index)
{
NPC npc = Main.npc[index];
if (npc.active && this.ValidIds.Contains(npc.type))
{
info.npcIndexToAimAt = index;
return true;
}
}
return false;
}
}
}

View file

@ -0,0 +1,17 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.SolarFlarePillarBigProgressBar
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.GameContent.UI.BigProgressBar
{
public class SolarFlarePillarBigProgressBar : LunarPillarBigProgessBar
{
internal override float GetCurrentShieldValue() => (float) NPC.ShieldStrengthTowerSolar;
internal override float GetMaxShieldValue() => (float) NPC.ShieldStrengthTowerMax;
internal override bool IsPlayerInCombatArea() => Main.LocalPlayer.ZoneTowerSolar;
}
}

View file

@ -0,0 +1,17 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.StardustPillarBigProgressBar
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.GameContent.UI.BigProgressBar
{
public class StardustPillarBigProgressBar : LunarPillarBigProgessBar
{
internal override float GetCurrentShieldValue() => (float) NPC.ShieldStrengthTowerStardust;
internal override float GetMaxShieldValue() => (float) NPC.ShieldStrengthTowerMax;
internal override bool IsPlayerInCombatArea() => Main.LocalPlayer.ZoneTowerStardust;
}
}

View file

@ -0,0 +1,49 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.TwinsBigProgressBar
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class TwinsBigProgressBar : IBigProgressBar
{
private float _lifePercentToShow;
private int _headIndex;
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info)
{
if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200)
return false;
NPC npc1 = Main.npc[info.npcIndexToAimAt];
if (!npc1.active)
return false;
int num = npc1.type == 126 ? 125 : 126;
int lifeMax = npc1.lifeMax;
int life = npc1.life;
for (int index = 0; index < 200; ++index)
{
NPC npc2 = Main.npc[index];
if (npc2.active && npc2.type == num)
{
lifeMax += npc2.lifeMax;
life += npc2.life;
break;
}
}
this._lifePercentToShow = Utils.Clamp<float>((float) life / (float) lifeMax, 0.0f, 1f);
this._headIndex = npc1.GetBossHeadTextureIndex();
return true;
}
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
Texture2D texture2D = TextureAssets.NpcHeadBoss[this._headIndex].Value;
Rectangle barIconFrame = texture2D.Frame();
BigProgressBarHelper.DrawFancyBar(spriteBatch, this._lifePercentToShow, texture2D, barIconFrame);
}
}
}

View file

@ -0,0 +1,17 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.VortexPillarBigProgressBar
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.GameContent.UI.BigProgressBar
{
public class VortexPillarBigProgressBar : LunarPillarBigProgessBar
{
internal override float GetCurrentShieldValue() => (float) NPC.ShieldStrengthTowerVortex;
internal override float GetMaxShieldValue() => (float) NPC.ShieldStrengthTowerMax;
internal override bool IsPlayerInCombatArea() => Main.LocalPlayer.ZoneTowerVortex;
}
}