Files
CalamityModPublic/Projectiles/Boss/GreatSandBlast.cs
T
tomat 67bceff6e7 Initial dotnet format pass.
This commit formats the entire codebase according to `dotnet format` and its limited understanding of our provided `.editorconfig`.
2024-02-28 21:49:50 -08:00

102 lines
4.0 KiB
C#

using System;
using System.IO;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Boss
{
public class GreatSandBlast : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Boss";
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 4;
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
}
public override void SetDefaults()
{
Projectile.width = 10;
Projectile.height = 10;
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
Projectile.scale = 2f;
Projectile.hostile = true;
Projectile.tileCollide = false;
Projectile.penetrate = 1;
Projectile.timeLeft = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 900 : 600;
Projectile.aiStyle = ProjAIStyleID.Arrow;
Projectile.alpha = 255;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(Projectile.localAI[0]);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
Projectile.localAI[0] = reader.ReadSingle();
}
public override void AI()
{
Projectile.tileCollide = Projectile.timeLeft < 540;
Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + 1.57f;
Projectile.localAI[0] += 1f;
if (Projectile.localAI[0] > 4f)
{
Projectile.alpha -= 50;
if (Projectile.alpha < 0)
{
Projectile.alpha = 0;
}
int sandyDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, DustID.UnusedBrown, 0f, 0f, 100, default, 1f);
Main.dust[sandyDust].noGravity = true;
Main.dust[sandyDust].velocity *= 0f;
}
}
public override void OnKill(int timeLeft)
{
SoundEngine.PlaySound(SoundID.Item14, Projectile.Center);
Projectile.position = Projectile.Center;
Projectile.width = Projectile.height = (int)(32 * Projectile.scale);
Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2);
Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2);
int dustAmt = 36;
for (int i = 0; i < dustAmt; i++)
{
Vector2 dustRotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f;
dustRotate = dustRotate.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center;
Vector2 dustDirection = dustRotate - Projectile.Center;
int killSand = Dust.NewDust(dustRotate + dustDirection, 0, 0, DustID.UnusedBrown, dustDirection.X * 1.5f, dustDirection.Y * 1.5f, 100, default, 1.2f);
Main.dust[killSand].noGravity = true;
Main.dust[killSand].noLight = true;
Main.dust[killSand].velocity = dustDirection;
}
Projectile.Damage();
}
public override void OnHitPlayer(Player target, Player.HurtInfo info)
{
if (info.Damage <= 0)
return;
target.velocity *= 0.5f;
}
public override bool PreDraw(ref Color lightColor)
{
lightColor.R = (byte)(255 * Projectile.Opacity);
lightColor.G = (byte)(255 * Projectile.Opacity);
lightColor.B = (byte)(255 * Projectile.Opacity);
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
return false;
}
}
}