Files
CalamityModPublic/Projectiles/Ranged/PrismExplosionSmall.cs
T
2024-10-15 23:48:00 +07:00

57 lines
2.1 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Ranged
{
public class PrismExplosionSmall : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Ranged";
public override void SetStaticDefaults()
{
Main.projFrames[Type] = 7;
}
public override void SetDefaults()
{
Projectile.width = Projectile.height = 130;
Projectile.friendly = true;
Projectile.ignoreWater = false;
Projectile.tileCollide = false;
Projectile.DamageType = DamageClass.Ranged;
Projectile.penetrate = -1;
Projectile.timeLeft = 150;
Projectile.extraUpdates = 2;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 11;
Projectile.scale = 0.5f;
}
public override void AI()
{
Lighting.AddLight(Projectile.Center, Color.White.ToVector3() * 1.15f);
Projectile.frameCounter++;
if (Projectile.frameCounter % 8 == 7)
Projectile.frame++;
if (Projectile.frame >= Main.projFrames[Type])
Projectile.Kill();
Projectile.scale *= 1.0115f;
Projectile.Opacity = Utils.GetLerpValue(5f, 36f, Projectile.timeLeft, true);
}
public override bool PreDraw(ref Color lightColor)
{
Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value;
Texture2D lightTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value;
Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame);
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
Vector2 origin = frame.Size() * 0.5f;
Main.EntitySpriteDraw(texture, drawPosition, frame, Color.White, 0f, origin, 1f, SpriteEffects.None, 0);
return false;
}
}
}