163 lines
6.3 KiB
C#
163 lines
6.3 KiB
C#
using CalamityMod.Projectiles.BaseProjectiles;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using ReLogic.Content;
|
|
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using Terraria;
|
|
using Terraria.Audio;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Boss
|
|
{
|
|
public class CirrusBlast : BaseLaserbeamProjectile, ILocalizedModType
|
|
{
|
|
// Modified clone of Seraphim's Laser
|
|
public new string LocalizationCategory => "Projectiles.Boss";
|
|
|
|
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
|
|
|
public int OwnerIndex
|
|
{
|
|
get => (int)Projectile.ai[1];
|
|
set => Projectile.ai[1] = value;
|
|
}
|
|
|
|
public override float MaxScale => Projectile.ai[0];
|
|
|
|
public override float MaxLaserLength => 2400f;
|
|
|
|
public override float Lifetime => 50;
|
|
|
|
public override Color LaserOverlayColor
|
|
{
|
|
get
|
|
{
|
|
return new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0);
|
|
}
|
|
}
|
|
|
|
public override Color LightCastColor => Color.Transparent;
|
|
|
|
public override Texture2D LaserBeginTexture => ModContent.Request<Texture2D>("CalamityMod/Projectiles/Rogue/SeraphimBeamLarge", AssetRequestMode.ImmediateLoad).Value;
|
|
|
|
public override Texture2D LaserMiddleTexture => ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Lasers/SeraphimBeamLargeMiddle", AssetRequestMode.ImmediateLoad).Value;
|
|
|
|
public override Texture2D LaserEndTexture => ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Lasers/SeraphimBeamLargeEnd", AssetRequestMode.ImmediateLoad).Value;
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
Main.projFrames[Projectile.type] = 10;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = Projectile.height = 30;
|
|
Projectile.hostile = true;
|
|
Projectile.alpha = 255;
|
|
Projectile.penetrate = -1;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.tileCollide = false;
|
|
Projectile.timeLeft = 200;
|
|
Projectile.Calamity().DealsDefenseDamage = true;
|
|
CooldownSlot = ImmunityCooldownID.Bosses;
|
|
}
|
|
|
|
public override void SendExtraAI(BinaryWriter writer)
|
|
{
|
|
writer.Write(Projectile.localAI[0]);
|
|
writer.Write(Projectile.localAI[1]);
|
|
writer.Write(Projectile.scale);
|
|
}
|
|
|
|
public override void ReceiveExtraAI(BinaryReader reader)
|
|
{
|
|
Projectile.localAI[0] = reader.ReadSingle();
|
|
Projectile.localAI[1] = reader.ReadSingle();
|
|
Projectile.scale = reader.ReadSingle();
|
|
}
|
|
|
|
public override void UpdateLaserMotion()
|
|
{
|
|
// Update the direction and rotation of the laser.
|
|
Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY);
|
|
Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2;
|
|
}
|
|
|
|
public override float DetermineLaserLength() => MaxLaserLength;
|
|
|
|
public override void PostAI()
|
|
{
|
|
// Determine frames.
|
|
Projectile.frameCounter++;
|
|
if (Projectile.frameCounter % 5f == 4f)
|
|
Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Projectile.type];
|
|
}
|
|
|
|
public override bool CanHitPlayer(Player target) => Projectile.scale >= 0.5f;
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
// This should never happen, but just in case.
|
|
if (Projectile.velocity == Vector2.Zero)
|
|
return false;
|
|
|
|
Color beamColor = LaserOverlayColor;
|
|
Rectangle startFrameArea = LaserBeginTexture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame);
|
|
Rectangle middleFrameArea = LaserMiddleTexture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame);
|
|
Rectangle endFrameArea = LaserEndTexture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame);
|
|
|
|
// Start texture drawing.
|
|
Vector2 centerOnLaser = Projectile.Center + Projectile.velocity * Projectile.scale * 116f;
|
|
Main.EntitySpriteDraw(LaserBeginTexture,
|
|
centerOnLaser - Main.screenPosition,
|
|
startFrameArea,
|
|
beamColor,
|
|
Projectile.rotation,
|
|
LaserBeginTexture.Size() / 2f,
|
|
Projectile.scale,
|
|
SpriteEffects.None,
|
|
0);
|
|
|
|
// Prepare things for body drawing.
|
|
float laserBodyLength = LaserLength + middleFrameArea.Height;
|
|
|
|
// Body drawing.
|
|
if (laserBodyLength > 0f)
|
|
{
|
|
float laserOffset = middleFrameArea.Height * Projectile.scale;
|
|
float incrementalBodyLength = 0f;
|
|
while (incrementalBodyLength + 1f < laserBodyLength)
|
|
{
|
|
centerOnLaser += Projectile.velocity * laserOffset;
|
|
incrementalBodyLength += laserOffset;
|
|
Main.EntitySpriteDraw(LaserMiddleTexture,
|
|
centerOnLaser - Main.screenPosition,
|
|
middleFrameArea,
|
|
beamColor,
|
|
Projectile.rotation,
|
|
LaserMiddleTexture.Size() * 0.5f,
|
|
Projectile.scale,
|
|
SpriteEffects.None,
|
|
0);
|
|
}
|
|
}
|
|
|
|
Vector2 laserEndCenter = centerOnLaser + Projectile.velocity * endFrameArea.Height * Projectile.scale - Main.screenPosition;
|
|
Main.EntitySpriteDraw(LaserEndTexture,
|
|
laserEndCenter,
|
|
endFrameArea,
|
|
beamColor,
|
|
Projectile.rotation,
|
|
LaserEndTexture.Size() * 0.5f,
|
|
Projectile.scale,
|
|
SpriteEffects.None,
|
|
0);
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|