Files
CalamityModPublic/Projectiles/Summon/PlantationStaffSeed.cs
T
GinYuH ba50bb246f split client and server configs
rebased by Ozzatron 15AUG2024 to fix conflicts
2024-08-15 16:54:43 -04:00

78 lines
2.9 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class PlantationStaffSeed : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
public ref float RandomTexture => ref Projectile.ai[0];
public override void SetStaticDefaults()
{
Main.projFrames[Type] = 2;
ProjectileID.Sets.MinionShot[Type] = true;
ProjectileID.Sets.TrailingMode[Type] = 2;
ProjectileID.Sets.TrailCacheLength[Type] = 3;
}
public override void SetDefaults()
{
Projectile.DamageType = DamageClass.Summon;
Projectile.width = Projectile.height = 14;
Projectile.timeLeft = 600;
Projectile.friendly = true;
Projectile.tileCollide = false;
Projectile.ignoreWater = true;
}
public override void AI()
{
DoAnimation();
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
}
#region AI Methods
private void DoAnimation()
{
Projectile.frameCounter++;
if (Projectile.frameCounter >= 8)
{
Projectile.frameCounter = 0;
Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Type];
}
}
#endregion
public override bool PreDraw(ref Color lightColor)
{
Texture2D texture = (RandomTexture == 0f) ? Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value : ModContent.Request<Texture2D>("CalamityMod/Projectiles/Summon/PlantationStaffSeed2").Value;
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame);
Vector2 origin = frame.Size() * 0.5f;
if (CalamityClientConfig.Instance.Afterimages)
{
for (int i = 0; i < Projectile.oldPos.Length; i++)
{
Color afterimageDrawColor = ((RandomTexture == 0f) ? Color.Green : Color.Pink) with { A = 25 } * Projectile.Opacity * (1f - i / (float)Projectile.oldPos.Length);
Vector2 afterimageDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition;
Main.EntitySpriteDraw(texture, afterimageDrawPosition, frame, afterimageDrawColor, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0);
}
}
Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0);
return false;
}
}
}