This commit formats the entire codebase according to `dotnet format` and its limited understanding of our provided `.editorconfig`.
80 lines
3.3 KiB
C#
80 lines
3.3 KiB
C#
using CalamityMod.Particles;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Rogue
|
|
{
|
|
public class EclipsesFallMain : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Rogue";
|
|
public override string Texture => "CalamityMod/Items/Weapons/Rogue/EclipsesFall";
|
|
|
|
// these also affect KB
|
|
public static float RainDamageMult = 0.4f;
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
ProjectileID.Sets.TrailCacheLength[Type] = 6;
|
|
ProjectileID.Sets.TrailingMode[Type] = 0;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = Projectile.height = 40;
|
|
Projectile.friendly = true;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.tileCollide = false;
|
|
Projectile.DamageType = RogueDamageClass.Instance;
|
|
Projectile.MaxUpdates = 2;
|
|
Projectile.penetrate = 3;
|
|
Projectile.usesLocalNPCImmunity = true;
|
|
Projectile.localNPCHitCooldown = 6 * Projectile.MaxUpdates;
|
|
Projectile.timeLeft = 150 * Projectile.MaxUpdates;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Lighting.AddLight(Projectile.Center, 1f, 0.8f, 0.3f);
|
|
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4;
|
|
if (Main.rand.NextBool(5))
|
|
{
|
|
Vector2 trailPos = Projectile.Center + Vector2.UnitY.RotatedBy(Projectile.rotation) * Main.rand.NextFloat(-16f, 16f);
|
|
float trailScale = Main.rand.NextFloat(0.8f, 1.2f);
|
|
Color trailColor = Main.rand.NextBool() ? Color.Indigo : Color.DarkOrange;
|
|
Particle eclipseTrail = new SparkParticle(trailPos, Projectile.velocity * 0.2f, false, 60, trailScale, trailColor);
|
|
GeneralParticleHandler.SpawnParticle(eclipseTrail);
|
|
}
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => SpawnSpears(target.Center);
|
|
|
|
public override void OnHitPlayer(Player target, Player.HurtInfo info) => SpawnSpears(target.Center);
|
|
|
|
private void SpawnSpears(Vector2 targetPos)
|
|
{
|
|
int spearAmt = Main.rand.Next(3, 4 + 1); // 3 or 4 spears
|
|
var source = Projectile.GetSource_FromThis();
|
|
for (int n = 0; n < spearAmt; n++)
|
|
{
|
|
;
|
|
CalamityUtils.ProjectileRain(source, targetPos, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType<EclipsesSmol>(), (int)(Projectile.damage * RainDamageMult), Projectile.knockBack * RainDamageMult, Projectile.owner);
|
|
}
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1);
|
|
return false;
|
|
}
|
|
|
|
public override void PostDraw(Color lightColor)
|
|
{
|
|
Texture2D glow = ModContent.Request<Texture2D>(Texture + "Glow").Value;
|
|
Main.EntitySpriteDraw(glow, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, glow.Size() * 0.5f, Projectile.scale, SpriteEffects.None);
|
|
}
|
|
}
|
|
}
|