Files
CalamityModPublic/Projectiles/Summon/StatigelBlightedSlime.cs
T
2026-07-19 08:30:28 +07:00

110 lines
4.3 KiB
C#

using CalamityMod.Buffs.Summon;
using CalamityMod.CalPlayer;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class StatigelBlightedSlime : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
public override string Texture => "CalamityMod/Projectiles/Summon/BlightedSlimeCorro";
public float dust = 0f;
public static Asset<Texture2D> Corroslime;
public static Asset<Texture2D> Crimslime;
public override void SetStaticDefaults()
{
Main.projFrames[Type] = 6;
ProjectileID.Sets.MinionSacrificable[Type] = true;
ProjectileID.Sets.MinionTargettingFeature[Type] = true;
if (!Main.dedServ)
{
Corroslime = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Summon/BlightedSlimeCorro");
Crimslime = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Summon/BlightedSlimeCrim");
}
}
public override void SetDefaults()
{
Projectile.width = 26;
Projectile.height = 26;
Projectile.netImportant = true;
Projectile.friendly = true;
Projectile.minionSlots = 0f;
Projectile.alpha = 75;
Projectile.aiStyle = ProjAIStyleID.Pet;
Projectile.timeLeft = 18000;
Projectile.penetrate = -1;
Projectile.timeLeft *= 5;
Projectile.minion = true;
AIType = ProjectileID.BabySlime;
Projectile.tileCollide = false;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 30;
Projectile.DamageType = DamageClass.Summon;
}
public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac)
{
fallThrough = false;
return true;
}
public override void AI()
{
Player player = Main.player[Projectile.owner];
CalamityPlayer modPlayer = player.Calamity();
if (dust == 0f)
{
int constant = 16;
for (int i = 0; i < constant; i++)
{
Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f;
rotate = rotate.RotatedBy((double)((float)(i - (constant / 2 - 1)) * 6.28318548f / (float)constant), default) + Projectile.Center;
Vector2 faceDirection = rotate - Projectile.Center;
int dust = Dust.NewDust(rotate + faceDirection, 0, 0, DustID.ShadowbeamStaff, faceDirection.X * 1f, faceDirection.Y * 1f, 100, default, 1.1f);
Main.dust[dust].noGravity = true;
Main.dust[dust].noLight = true;
Main.dust[dust].velocity = faceDirection;
}
dust += 1f;
}
bool isMinion = Projectile.type == ModContent.ProjectileType<StatigelBlightedSlime>();
player.AddBuff(ModContent.BuffType<BabyPaladinBuff>(), 3600);
if (!modPlayer.slimeGod)
{
Projectile.active = false;
return;
}
if (isMinion)
{
if (player.dead)
{
modPlayer.sGod = false;
}
if (modPlayer.sGod)
{
Projectile.timeLeft = 2;
}
}
}
public override bool OnTileCollide(Vector2 oldVelocity) => false;
public override bool PreDraw(ref Color lightColor)
{
Texture2D slom = (WorldGen.crimson ? Crimslime : Corroslime).Value;
Rectangle frame = slom.Frame(1, Main.projFrames[Type], 0, Projectile.frame);
Main.EntitySpriteDraw(slom, Projectile.Center - Main.screenPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, frame.Size() / 2f, Projectile.scale, SpriteEffects.None);
return false;
}
}
}