75 lines
2.5 KiB
C#
75 lines
2.5 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using System.Collections.Generic;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Summon
|
|
{
|
|
public class MechwormTail : ModProjectile
|
|
{
|
|
private int playerMinionSlots = 0;
|
|
private bool runCheck = true;
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Mechworm");
|
|
ProjectileID.Sets.MinionSacrificable[projectile.type] = true;
|
|
ProjectileID.Sets.NeedsUUID[projectile.type] = true;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
projectile.width = 24;
|
|
projectile.height = 24;
|
|
projectile.friendly = true;
|
|
projectile.ignoreWater = true;
|
|
projectile.alpha = 255;
|
|
projectile.netImportant = true;
|
|
projectile.timeLeft = 18000;
|
|
projectile.penetrate = -1;
|
|
projectile.tileCollide = false;
|
|
projectile.timeLeft *= 5;
|
|
projectile.minion = true;
|
|
projectile.usesLocalNPCImmunity = true;
|
|
projectile.localNPCHitCooldown = 5;
|
|
projectile.hide = true;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Player owner = Main.player[projectile.owner];
|
|
if (owner.maxMinions > playerMinionSlots)
|
|
playerMinionSlots = owner.maxMinions;
|
|
|
|
if (runCheck)
|
|
{
|
|
runCheck = false;
|
|
playerMinionSlots = owner.maxMinions;
|
|
}
|
|
|
|
projectile.localAI[0] = 0f;
|
|
|
|
MechwormBody.SegmentAI(projectile, 16, ref playerMinionSlots);
|
|
}
|
|
|
|
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
|
{
|
|
Texture2D tex = Main.projectileTexture[projectile.type];
|
|
Vector2 drawPosition = projectile.Center - Main.screenPosition;
|
|
spriteBatch.Draw(tex, drawPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f);
|
|
return false;
|
|
}
|
|
|
|
public override bool CanDamage() => projectile.alpha == 0;
|
|
|
|
public override void DrawBehind(int index, List<int> drawCacheProjsBehindNPCsAndTiles, List<int> drawCacheProjsBehindNPCs, List<int> drawCacheProjsBehindProjectiles, List<int> drawCacheProjsOverWiresUI)
|
|
{
|
|
drawCacheProjsBehindProjectiles.Add(index);
|
|
}
|
|
|
|
public override bool ShouldUpdatePosition() => false;
|
|
}
|
|
}
|