Generalize Wave Pounder into BaseMassiveExplosion
This commit is contained in:
10 files changed
+161
-255
No files matched your search
@@ -0,0 +1,15 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace CalamityMod.DataStructures
|
||||
{
|
||||
public struct ScreenShakeSpot
|
||||
{
|
||||
public float ScreenShakePower;
|
||||
public Vector2 Position;
|
||||
public ScreenShakeSpot(float screenShakePower, Vector2 position)
|
||||
{
|
||||
ScreenShakePower = screenShakePower;
|
||||
Position = position;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
|
||||
{
|
||||
// Whether the body is venting heat or not, it is vulnerable to damage during venting
|
||||
private bool vulnerable = false;
|
||||
public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 4, 0f, 16f, 1.5f);
|
||||
public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f);
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
|
||||
{
|
||||
// Whether the body is venting heat or not, it is vulnerable to damage during venting
|
||||
private bool vulnerable = false;
|
||||
public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 4, 0f, 16f, 1.5f);
|
||||
public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f);
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
|
||||
set => npc.Calamity().newAI[1] = value;
|
||||
}
|
||||
|
||||
public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 4, 0f, 16f, 1.5f);
|
||||
public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f);
|
||||
|
||||
// Invincibility time for the first 10 seconds
|
||||
public const float immunityTime = 600f;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
|
||||
{
|
||||
// Whether the tail is venting heat or not, it is vulnerable to damage during venting
|
||||
private bool vulnerable = false;
|
||||
public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 4, 0f, 16f, 1.5f);
|
||||
public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f);
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
@@ -25,11 +26,20 @@ namespace CalamityMod.Particles
|
||||
|
||||
public override void UpdateBehavior(Particle particle)
|
||||
{
|
||||
particle.Scale += RelativePower * 0.02f;
|
||||
particle.RelativeOffset -= (BaseMoveRotation + Main.rand.NextFloat(-0.38f, 0.38f)).ToRotationVector2() * RelativePower * 4.5f;
|
||||
if (particle.Scale < 1.25f)
|
||||
particle.Scale += RelativePower * 0.04f;
|
||||
particle.RelativeOffset -= (BaseMoveRotation + Main.rand.NextFloat(-0.18f, 0.18f)).ToRotationVector2() * RelativePower * 4.5f;
|
||||
}
|
||||
|
||||
public override Color DetermineParticleColor(float lifetimeCompletion) => Color.White * Utils.InverseLerp(1f, 0.85f, lifetimeCompletion, true);
|
||||
public override Color DetermineParticleColor(float lifetimeCompletion)
|
||||
{
|
||||
Color color = Color.DarkRed;
|
||||
color = Color.Lerp(color, new Color(154, 139, 138), (float)Math.Pow(Utils.InverseLerp(0f, 0.57f, lifetimeCompletion, true), 2D) * 0.5f + 0.5f);
|
||||
color.A = 92;
|
||||
|
||||
float opacity = Utils.InverseLerp(1f, 0.85f, lifetimeCompletion, true);
|
||||
return color * opacity;
|
||||
}
|
||||
|
||||
public override Particle SpawnParticle() => new Particle(ParticleLifetime, Main.rand.NextVector2Circular(1f, 1f) * SpawnAreaCompactness, 0.06f, Main.rand.Next(3));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
using CalamityMod.DataStructures;
|
||||
using CalamityMod.World;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.BaseProjectiles
|
||||
{
|
||||
public abstract class BaseMassiveExplosionProjectile : ModProjectile
|
||||
{
|
||||
public ScreenShakeSpot ScreenShakeSpot;
|
||||
public ref float CurrentRadius => ref projectile.ai[0];
|
||||
public ref float MaxRadius => ref projectile.ai[1];
|
||||
public virtual bool UsesScreenshake { get; } = false;
|
||||
public virtual float GetScreenshakePower(float pulseCompletionRatio) => 0f;
|
||||
|
||||
public abstract int Lifetime { get; }
|
||||
public abstract Color GetCurrentExplosionColor(float pulseCompletionRatio);
|
||||
|
||||
// Use the invisible projectile by default. This can be overridden in child types if desired.
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
// Declare this projectile as needing to use the UUID system if it uses screen shake spots, due to a need for said spots to reference their parent projectile.
|
||||
public sealed override void SetStaticDefaults()
|
||||
{
|
||||
SafeSetStaticDefaults();
|
||||
if (UsesScreenshake)
|
||||
ProjectileID.Sets.NeedsUUID[projectile.type] = true;
|
||||
}
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(projectile.localAI[0]);
|
||||
writer.Write(ScreenShakeSpot.ScreenShakePower);
|
||||
writer.WriteVector2(ScreenShakeSpot.Position);
|
||||
}
|
||||
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
projectile.localAI[0] = reader.ReadSingle();
|
||||
ScreenShakeSpot = new ScreenShakeSpot(reader.ReadInt32(), reader.ReadVector2());
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (UsesScreenshake)
|
||||
{
|
||||
if (projectile.localAI[0] == 0f)
|
||||
{
|
||||
ScreenShakeSpot = new ScreenShakeSpot(0, projectile.Center);
|
||||
projectile.localAI[0] = 1f;
|
||||
}
|
||||
ScreenShakeSpot.ScreenShakePower = GetScreenshakePower(projectile.timeLeft / (float)Lifetime);
|
||||
ScreenShakeSpot.Position = projectile.Center;
|
||||
CalamityWorld.ScreenShakeSpots[Projectile.GetByUUID(projectile.owner, projectile.whoAmI)] = ScreenShakeSpot;
|
||||
}
|
||||
|
||||
// Expand outward.
|
||||
CurrentRadius = MathHelper.Lerp(CurrentRadius, MaxRadius, 0.25f);
|
||||
projectile.scale = MathHelper.Lerp(1.2f, 5f, Utils.InverseLerp(Lifetime, 0f, projectile.timeLeft, true));
|
||||
|
||||
// Adjust the hitbox.
|
||||
CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(CurrentRadius * projectile.scale), (int)(CurrentRadius * projectile.scale));
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
spriteBatch.End();
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix);
|
||||
|
||||
float pulseCompletionRatio = Utils.InverseLerp(Lifetime, 0f, projectile.timeLeft, true);
|
||||
Vector2 scale = new Vector2(1.5f, 1f);
|
||||
Vector2 drawPosition = projectile.Center - Main.screenPosition + projectile.Size * scale * 0.5f;
|
||||
Rectangle drawArea = new Rectangle(0, 0, projectile.width, projectile.height);
|
||||
Color fadeoutColor = new Color(new Vector4(1f - (float)Math.Sqrt(pulseCompletionRatio))) * projectile.Opacity * 0.7f;
|
||||
DrawData drawData = new DrawData(ModContent.GetTexture("Terraria/Misc/Perlin"), drawPosition, drawArea, fadeoutColor, projectile.rotation, projectile.Size, scale, SpriteEffects.None, 0);
|
||||
|
||||
GameShaders.Misc["ForceField"].UseColor(GetCurrentExplosionColor(pulseCompletionRatio));
|
||||
GameShaders.Misc["ForceField"].Apply(drawData);
|
||||
drawData.Draw(spriteBatch);
|
||||
|
||||
spriteBatch.End();
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
// Remove the explosion associated with this projectile's UUID.
|
||||
if (UsesScreenshake)
|
||||
CalamityWorld.ScreenShakeSpots.Remove(Projectile.GetByUUID(projectile.owner, projectile.whoAmI));
|
||||
SafeKill(timeLeft);
|
||||
}
|
||||
|
||||
public virtual void SafeSetStaticDefaults() { }
|
||||
|
||||
public virtual void SafeKill(int timeLeft) { }
|
||||
}
|
||||
}
|
||||
@@ -174,6 +174,7 @@ namespace CalamityMod.Projectiles.Boss
|
||||
Projectile explosion = Projectile.NewProjectileDirect(projectile.Center, Vector2.Zero, ModContent.ProjectileType<AresGaussNukeProjectileBoom>(), projectile.damage, 0f, Main.myPlayer);
|
||||
if (explosion.whoAmI.WithinBounds(Main.maxProjectiles))
|
||||
{
|
||||
// Make the max explosion radius decrease over time, creating a ring effect.
|
||||
explosion.ai[1] = 800f + i * 45f;
|
||||
explosion.localAI[1] = 0.25f;
|
||||
explosion.Opacity = MathHelper.Lerp(0.18f, 0.6f, i / 7f) + Main.rand.NextFloat(-0.08f, 0.08f);
|
||||
|
||||
@@ -1,154 +1,38 @@
|
||||
using CalamityMod.Projectiles.DraedonsArsenal;
|
||||
using CalamityMod.World;
|
||||
using CalamityMod.Projectiles.BaseProjectiles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Boss
|
||||
{
|
||||
public class AresGaussNukeProjectileBoom : ModProjectile
|
||||
public class AresGaussNukeProjectileBoom : BaseMassiveExplosionProjectile
|
||||
{
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
public override int Lifetime => 60;
|
||||
public override bool UsesScreenshake => true;
|
||||
public override float GetScreenshakePower(float pulseCompletionRatio) => CalamityUtils.Convert01To010(pulseCompletionRatio) * 16f;
|
||||
public override Color GetCurrentExplosionColor(float pulseCompletionRatio) => Color.Lerp(Color.Yellow * 1.6f, Color.White, MathHelper.Clamp(pulseCompletionRatio * 2.2f, 0f, 1f));
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public ScreenShakeSpot CurrentSpot;
|
||||
|
||||
public float Radius
|
||||
{
|
||||
get => projectile.ai[0];
|
||||
set => projectile.ai[0] = value;
|
||||
}
|
||||
|
||||
public float MaxRadius
|
||||
{
|
||||
get => projectile.ai[1];
|
||||
set => projectile.ai[1] = value;
|
||||
}
|
||||
|
||||
public float InterpolationStep
|
||||
{
|
||||
get => projectile.localAI[1];
|
||||
set => projectile.localAI[1] = value;
|
||||
}
|
||||
|
||||
public const int Lifetime = 60;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Gauss Explosion");
|
||||
ProjectileID.Sets.NeedsUUID[projectile.type] = true;
|
||||
}
|
||||
public override void SafeSetStaticDefaults() => DisplayName.SetDefault("Gauss Explosion");
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.Calamity().canBreakPlayerDefense = true;
|
||||
projectile.width = 2;
|
||||
projectile.height = 2;
|
||||
projectile.width = projectile.height = 2;
|
||||
projectile.hostile = true;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.tileCollide = false;
|
||||
projectile.penetrate = -1;
|
||||
cooldownSlot = 1;
|
||||
projectile.timeLeft = Lifetime;
|
||||
cooldownSlot = 1;
|
||||
}
|
||||
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(projectile.localAI[0]);
|
||||
writer.Write(projectile.localAI[1]);
|
||||
writer.Write(CurrentSpot.ScreenShakePower);
|
||||
writer.WriteVector2(CurrentSpot.Position);
|
||||
}
|
||||
public override void PostAI() => Lighting.AddLight(projectile.Center, 0.2f, 0.1f, 0f);
|
||||
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
projectile.localAI[0] = reader.ReadSingle();
|
||||
projectile.localAI[1] = reader.ReadSingle();
|
||||
CurrentSpot = new ScreenShakeSpot(reader.ReadInt32(), reader.ReadVector2());
|
||||
}
|
||||
public override bool CanHitPlayer(Player target) => CalamityUtils.CircularHitboxCollision(projectile.Center, CurrentRadius * projectile.scale * 0.5f, target.Hitbox);
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (projectile.localAI[0] == 0f)
|
||||
{
|
||||
CurrentSpot = new ScreenShakeSpot(0, projectile.Center);
|
||||
projectile.localAI[0] = 1f;
|
||||
}
|
||||
public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) => target.Calamity().lastProjectileHit = projectile;
|
||||
|
||||
CurrentSpot.ScreenShakePower = (float)Math.Sin(MathHelper.Pi * projectile.timeLeft / Lifetime) * 16f;
|
||||
CurrentSpot.Position = projectile.Center;
|
||||
CalamityWorld.ScreenShakeSpots[Projectile.GetByUUID(projectile.owner, projectile.whoAmI)] = CurrentSpot;
|
||||
|
||||
Lighting.AddLight(projectile.Center, 0.2f, 0.1f, 0f);
|
||||
Radius = MathHelper.Lerp(Radius, MaxRadius, 0.25f);
|
||||
projectile.scale = MathHelper.Lerp(1.2f, 5f, Utils.InverseLerp(Lifetime, 0f, projectile.timeLeft, true));
|
||||
CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(Radius * projectile.scale), (int)(Radius * projectile.scale));
|
||||
}
|
||||
|
||||
public override void OnHitPlayer(Player target, int damage, bool crit)
|
||||
{
|
||||
target.AddBuff(BuffID.OnFire, 480);
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
CalamityWorld.ScreenShakeSpots.Remove(Projectile.GetByUUID(projectile.owner, projectile.whoAmI)); // Remove the explosion associated with this projectile's UUID.
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
spriteBatch.End();
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix);
|
||||
|
||||
float pulseCompletionRatio = Utils.InverseLerp(Lifetime, 0f, projectile.timeLeft, true);
|
||||
Vector2 scale = new Vector2(1.5f, 1f);
|
||||
DrawData drawData = new DrawData(ModContent.GetTexture("Terraria/Misc/Perlin"),
|
||||
projectile.Center - Main.screenPosition + projectile.Size * scale * 0.5f,
|
||||
new Rectangle(0, 0, projectile.width, projectile.height),
|
||||
new Color(new Vector4(1f - (float)Math.Sqrt(pulseCompletionRatio))) * 0.7f * projectile.Opacity,
|
||||
projectile.rotation,
|
||||
projectile.Size,
|
||||
scale,
|
||||
SpriteEffects.None, 0);
|
||||
|
||||
Color pulseColor = Color.Lerp(Color.Yellow * 1.6f, Color.White, MathHelper.Clamp(pulseCompletionRatio * 2.2f, 0f, 1f));
|
||||
GameShaders.Misc["ForceField"].UseColor(pulseColor);
|
||||
GameShaders.Misc["ForceField"].Apply(drawData);
|
||||
drawData.Draw(spriteBatch);
|
||||
|
||||
spriteBatch.End();
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool CanHitPlayer(Player target)
|
||||
{
|
||||
Rectangle targetHitbox = target.Hitbox;
|
||||
|
||||
float dist1 = Vector2.Distance(projectile.Center, targetHitbox.TopLeft());
|
||||
float dist2 = Vector2.Distance(projectile.Center, targetHitbox.TopRight());
|
||||
float dist3 = Vector2.Distance(projectile.Center, targetHitbox.BottomLeft());
|
||||
float dist4 = Vector2.Distance(projectile.Center, targetHitbox.BottomRight());
|
||||
|
||||
float minDist = dist1;
|
||||
if (dist2 < minDist)
|
||||
minDist = dist2;
|
||||
if (dist3 < minDist)
|
||||
minDist = dist3;
|
||||
if (dist4 < minDist)
|
||||
minDist = dist4;
|
||||
|
||||
return minDist <= Radius * projectile.scale * 0.5f;
|
||||
}
|
||||
|
||||
public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit)
|
||||
{
|
||||
target.Calamity().lastProjectileHit = projectile;
|
||||
}
|
||||
public override void OnHitPlayer(Player target, int damage, bool crit) => target.AddBuff(BuffID.OnFire, 480);
|
||||
}
|
||||
}
|
||||
@@ -1,137 +1,29 @@
|
||||
using CalamityMod.World;
|
||||
using CalamityMod.Projectiles.BaseProjectiles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.DraedonsArsenal
|
||||
{
|
||||
public struct ScreenShakeSpot
|
||||
public class WavePounderBoom : BaseMassiveExplosionProjectile
|
||||
{
|
||||
public float ScreenShakePower;
|
||||
public Vector2 Position;
|
||||
public ScreenShakeSpot(float screenShakePower, Vector2 position)
|
||||
{
|
||||
ScreenShakePower = screenShakePower;
|
||||
Position = position;
|
||||
}
|
||||
}
|
||||
|
||||
public class WavePounderBoom : ModProjectile
|
||||
{
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public ScreenShakeSpot CurrentSpot;
|
||||
|
||||
public float Radius
|
||||
{
|
||||
get => projectile.ai[0];
|
||||
set => projectile.ai[0] = value;
|
||||
}
|
||||
|
||||
public float MaxRadius
|
||||
{
|
||||
get => projectile.ai[1];
|
||||
set => projectile.ai[1] = value;
|
||||
}
|
||||
|
||||
public float InterpolationStep
|
||||
{
|
||||
get => projectile.localAI[1];
|
||||
set => projectile.localAI[1] = value;
|
||||
}
|
||||
|
||||
public const int Lifetime = 60;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Explosion");
|
||||
ProjectileID.Sets.NeedsUUID[projectile.type] = true;
|
||||
}
|
||||
public override int Lifetime => 60;
|
||||
public override bool UsesScreenshake => projectile.Calamity().stealthStrike;
|
||||
public override float GetScreenshakePower(float pulseCompletionRatio) => CalamityUtils.Convert01To010(pulseCompletionRatio) * 16f;
|
||||
public override Color GetCurrentExplosionColor(float pulseCompletionRatio) => Color.Lerp(Color.Yellow * 1.6f, Color.White, MathHelper.Clamp(pulseCompletionRatio * 2.2f, 0f, 1f));
|
||||
public override void SafeSetStaticDefaults() => DisplayName.SetDefault("Explosion");
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 2;
|
||||
projectile.height = 2;
|
||||
projectile.width = projectile.height = 2;
|
||||
projectile.friendly = true;
|
||||
projectile.Calamity().rogue = true;
|
||||
projectile.tileCollide = false;
|
||||
projectile.penetrate = -1;
|
||||
projectile.usesLocalNPCImmunity = true;
|
||||
projectile.localNPCHitCooldown = 10;
|
||||
projectile.timeLeft = Lifetime;
|
||||
projectile.Calamity().rogue = true;
|
||||
}
|
||||
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(projectile.localAI[0]);
|
||||
writer.Write(projectile.localAI[1]);
|
||||
writer.Write(CurrentSpot.ScreenShakePower);
|
||||
writer.WriteVector2(CurrentSpot.Position);
|
||||
}
|
||||
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
projectile.localAI[0] = reader.ReadSingle();
|
||||
projectile.localAI[1] = reader.ReadSingle();
|
||||
CurrentSpot = new ScreenShakeSpot(reader.ReadInt32(), reader.ReadVector2());
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (projectile.Calamity().stealthStrike)
|
||||
{
|
||||
if (projectile.localAI[0] == 0f)
|
||||
{
|
||||
CurrentSpot = new ScreenShakeSpot(0, projectile.Center);
|
||||
projectile.localAI[0] = 1f;
|
||||
}
|
||||
CurrentSpot.ScreenShakePower = (float)Math.Sin(MathHelper.Pi * projectile.timeLeft / Lifetime) * 16f;
|
||||
CurrentSpot.Position = projectile.Center;
|
||||
CalamityWorld.ScreenShakeSpots[Projectile.GetByUUID(projectile.owner, projectile.whoAmI)] = CurrentSpot;
|
||||
}
|
||||
|
||||
Lighting.AddLight(projectile.Center, 0.2f, 0.1f, 0f);
|
||||
Radius = MathHelper.Lerp(Radius, MaxRadius, 0.25f);
|
||||
projectile.scale = MathHelper.Lerp(1.2f, 5f, Utils.InverseLerp(Lifetime, 0f, projectile.timeLeft, true));
|
||||
CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(Radius * projectile.scale), (int)(Radius * projectile.scale));
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
if (projectile.Calamity().stealthStrike)
|
||||
CalamityWorld.ScreenShakeSpots.Remove(Projectile.GetByUUID(projectile.owner, projectile.whoAmI)); // Remove the explosion associated with this projectile's UUID.
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
spriteBatch.End();
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix);
|
||||
|
||||
float pulseCompletionRatio = Utils.InverseLerp(Lifetime, 0f, projectile.timeLeft, true);
|
||||
Vector2 scale = new Vector2(1.5f, 1f);
|
||||
DrawData drawData = new DrawData(ModContent.GetTexture("Terraria/Misc/Perlin"),
|
||||
projectile.Center - Main.screenPosition + projectile.Size * scale * 0.5f,
|
||||
new Rectangle(0, 0, projectile.width, projectile.height),
|
||||
new Color(new Vector4(1f - (float)Math.Sqrt(pulseCompletionRatio))) * 0.7f * projectile.Opacity,
|
||||
projectile.rotation,
|
||||
projectile.Size,
|
||||
scale,
|
||||
SpriteEffects.None, 0);
|
||||
|
||||
Color pulseColor = Color.Lerp(Color.Yellow * 1.6f, Color.White, MathHelper.Clamp(pulseCompletionRatio * 2.2f, 0f, 1f));
|
||||
GameShaders.Misc["ForceField"].UseColor(pulseColor);
|
||||
GameShaders.Misc["ForceField"].Apply(drawData);
|
||||
drawData.Draw(spriteBatch);
|
||||
|
||||
spriteBatch.End();
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
|
||||
return false;
|
||||
}
|
||||
public override void PostAI() => Lighting.AddLight(projectile.Center, 0.2f, 0.1f, 0f);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user