This commit formats the entire codebase according to `dotnet format` and its limited understanding of our provided `.editorconfig`.
123 lines
5.0 KiB
C#
123 lines
5.0 KiB
C#
using CalamityMod.Buffs.DamageOverTime;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Rogue
|
|
{
|
|
public class SupernovaSpike : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Rogue";
|
|
public override string Texture => "CalamityMod/Projectiles/Rogue/BallisticPoisonBombSpike";
|
|
|
|
private Color currentColor = Color.Black;
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 10;
|
|
Projectile.height = 10;
|
|
Projectile.alpha = 255;
|
|
Projectile.friendly = true;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.penetrate = 3;
|
|
Projectile.alpha = 255;
|
|
Projectile.extraUpdates = 2;
|
|
Projectile.aiStyle = ProjAIStyleID.Nail;
|
|
AIType = ProjectileID.NailFriendly;
|
|
Projectile.DamageType = RogueDamageClass.Instance;
|
|
Projectile.usesLocalNPCImmunity = true;
|
|
Projectile.localNPCHitCooldown = 5;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Projectile.alpha -= 10;
|
|
if (Projectile.alpha < 0)
|
|
{
|
|
Projectile.alpha = 0;
|
|
}
|
|
int dustType = Main.rand.NextBool() ? 107 : 234;
|
|
if (Main.rand.NextBool(4))
|
|
{
|
|
dustType = 269;
|
|
}
|
|
Projectile.localAI[1] += 1f;
|
|
if (Projectile.localAI[1] > 4f)
|
|
{
|
|
int theDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 0.75f);
|
|
Main.dust[theDust].noGravity = true;
|
|
Main.dust[theDust].velocity *= 0f;
|
|
}
|
|
if (currentColor == Color.Black)
|
|
{
|
|
int startPoint = Main.rand.Next(6);
|
|
Projectile.localAI[0] = startPoint;
|
|
currentColor = GetStartingColor(startPoint);
|
|
}
|
|
Visuals(Projectile, ref currentColor);
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<MiracleBlight>(), 180);
|
|
|
|
public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType<MiracleBlight>(), 180);
|
|
|
|
internal static void Visuals(Projectile projectile, ref Color c)
|
|
{
|
|
CalamityUtils.IterateDisco(ref c, ref projectile.localAI[0], 15);
|
|
Vector3 compositeColor = 0.1f * Color.White.ToVector3() + 0.05f * c.ToVector3();
|
|
Lighting.AddLight(projectile.Center, compositeColor);
|
|
}
|
|
|
|
internal static Color GetStartingColor(int startPoint = 0)
|
|
{
|
|
switch (startPoint)
|
|
{
|
|
default: return new Color(1f, 0f, 0f, 0f); // Color.Red
|
|
case 1: return new Color(1f, 1f, 0f, 0f); // Color.Yellow
|
|
case 2: return new Color(0f, 1f, 0f, 0f); // Color.Green
|
|
case 3: return new Color(0f, 1f, 1f, 0f); // Color.Turquoise
|
|
case 4: return new Color(0f, 0f, 1f, 0f); // Color.Blue
|
|
case 5: return new Color(1f, 0f, 1f, 0f); // Color.Violet
|
|
}
|
|
}
|
|
|
|
// This projectile is always fullbright.
|
|
public override Color? GetAlpha(Color lightColor)
|
|
{
|
|
return currentColor;
|
|
}
|
|
|
|
public override void OnKill(int timeLeft)
|
|
{
|
|
Projectile.position = Projectile.Center;
|
|
Projectile.width = Projectile.height = 32;
|
|
Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2);
|
|
Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2);
|
|
int dustType = Main.rand.NextBool() ? 107 : 234;
|
|
if (Main.rand.NextBool(4))
|
|
{
|
|
dustType = 269;
|
|
}
|
|
for (int i = 0; i < 2; i++)
|
|
{
|
|
int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 1.2f);
|
|
Main.dust[dust].velocity *= 3f;
|
|
if (Main.rand.NextBool())
|
|
{
|
|
Main.dust[dust].scale = 0.5f;
|
|
Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f;
|
|
}
|
|
}
|
|
for (int j = 0; j < 2; j++)
|
|
{
|
|
int dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, DustID.Torch, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f);
|
|
Main.dust[dust2].noGravity = true;
|
|
Main.dust[dust2].velocity *= 5f;
|
|
dust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, DustID.Torch, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f);
|
|
Main.dust[dust2].velocity *= 2f;
|
|
}
|
|
}
|
|
}
|
|
}
|