+ False Brains now draw differently instead of using a unique texture if Brain of Cthulhu's texture has changed due to a Resource Pack

This commit is contained in:
Big E committed 2025-12-29 22:19:38 -05:00
1 parent c9b8742dff
commit 8e6fd3583b
1 file changed
+43 -7
@@ -46,7 +46,11 @@ public class FalseBrain : ModNPC, ILocalizedModType
Music = MusicID.Boss3;
NPC.localAI[0] = Main.rand.Next(5);
NPC.localAI[1] = 1 + Main.rand.NextFloat(-0.5f, 0.5f);
if(BrainOfCthulhuSystem.IsBrainOfCthulhuTextureVanilla)
NPC.localAI[1] = 1 + Main.rand.NextFloat(-0.5f, 0.5f);
else
NPC.localAI[1] = 1 + (Main.rand.NextFloat(0.25f, 0.75f) * (Main.rand.NextBool() ? -1 : 1));
}
private int Variant => (int)NPC.localAI[0];
private float Angle => NPC.ai[0];
@@ -161,27 +165,59 @@ public class FalseBrain : ModNPC, ILocalizedModType
internal void DrawSelf(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
Texture2D tex = TextureAssets.Npc[Type].Value;
Rectangle frame = tex.Frame(5, 4, Variant, (int)NPC.frameCounter);
Texture2D tex;
Rectangle frame;
Vector2 scaleDistort = new Vector2((float)Math.Cos(Main.GlobalTimeWrappedHourly * MathHelper.TwoPi * 2) / 2f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.TwoPi * 2) / 2f);
Vector2 scaleAddition = Vector2.zeroVector;
float endLerp = AttackTime / 60f;
float startLerp = SpawnTime / 60f;
if (BrainOfCthulhuSystem.IsBrainOfCthulhuTextureVanilla)
{
tex = TextureAssets.Npc[Type].Value;
frame = tex.Frame(5, 4, Variant, (int)NPC.frameCounter);
}
else
{
tex = TextureAssets.Npc[NPCID.BrainofCthulhu].Value;
frame = tex.Frame(1, 8, 0, 4 + (int)NPC.frameCounter);
switch(Variant)
{
case 0:
scaleAddition = new(-0.125f, 0.25f);
break;
case 1:
scaleAddition = new(0.25f, -0.125f);
break;
case 2:
drawColor = Color.Lerp(drawColor, Color.Red.MultiplyRGB(drawColor), 0.5f);
break;
case 3:
drawColor = Color.Lerp(drawColor, Color.Orange.MultiplyRGB(drawColor), 0.5f);
break;
case 4:
drawColor = Color.Lerp(drawColor, Color.Yellow.MultiplyRGB(drawColor), 0.5f);
break;
}
}
if (SpawnTime > 0)
{
drawColor *= (1 - startLerp);
scaleDistort *= startLerp;
}
else
else if (AttackTime > 0)
{
drawColor = Color.Lerp(drawColor, Color.Red, endLerp) * (1 - endLerp);
scaleDistort *= endLerp;
}
else
scaleDistort = Vector2.Zero;
spriteBatch.Draw(tex, NPC.Center + (Vector2.UnitY * 16) - screenPos, frame, drawColor, NPC.rotation, frame.Size() * 0.5f, (Vector2.One + scaleDistort) * NPC.scale, 0, 0);
spriteBatch.Draw(tex, NPC.Center + (Vector2.UnitY * 16) - screenPos, frame, drawColor, NPC.rotation, frame.Size() * 0.5f, (Vector2.One + scaleAddition + scaleDistort) * NPC.scale, 0, 0);
}
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) => false;