Files
CalamityModPublic/Projectiles/Melee/DarklightGreatswordSlash.cs
T
2024-05-17 15:01:49 -07:00

58 lines
2.3 KiB
C#

using System;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Melee
{
public class DarklightGreatswordSlash : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public override string Texture => "CalamityMod/Projectiles/Melee/ExobeamSlash";
public override void SetDefaults()
{
Projectile.width = 512;
Projectile.height = 24;
Projectile.friendly = true;
Projectile.DamageType = DamageClass.MeleeNoSpeed;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.penetrate = 2;
Projectile.Opacity = 1f;
Projectile.timeLeft = 35;
Projectile.MaxUpdates = 2;
Projectile.scale = 0.75f;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = Projectile.MaxUpdates * 12;
Projectile.noEnchantmentVisuals = true;
}
public override void AI()
{
Projectile.rotation = Projectile.velocity.ToRotation();
Projectile.Opacity = Projectile.timeLeft / 35f;
if (Projectile.timeLeft == 34)
{
Particle spark2 = new GlowSparkParticle(Projectile.Center, new Vector2(0.1f, 0.1f).RotatedByRandom(100), false, 12, Main.rand.NextFloat(0.03f, 0.05f), Main.rand.NextBool() ? Color.Pink : Color.Cyan, new Vector2(2, 0.5f), true);
GeneralParticleHandler.SpawnParticle(spark2);
}
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => Projectile.RotatingHitboxCollision(targetHitbox.TopLeft(), targetHitbox.Size());
public override bool ShouldUpdatePosition() => true;
public override Color? GetAlpha(Color lightColor) => Color.Lerp(Projectile.ai[2] == 0f ? Color.Cyan : Color.Pink, Projectile.ai[2] == 0f ? Color.DarkBlue : Color.DarkRed, Projectile.identity / 7f % 1f) * Projectile.Opacity;
public override bool PreDraw(ref Color lightColor)
{
return false;
}
}
}