From e5aa68e603b05f1f6796830b3c07a52381f40eb6 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Mon, 31 Aug 2020 15:43:09 -0400 Subject: [PATCH] made a beam proj util --- Projectiles/Boss/DoGNebulaShot.cs | 34 +-------- Projectiles/Enemy/DraedonLaser.cs | 28 +------- Projectiles/Hybrid/AetherBeam.cs | 38 +--------- Projectiles/Magic/PurgeLaser.cs | 48 ++----------- Projectiles/Magic/SHPL.cs | 67 ++++-------------- Projectiles/Magic/T1000Laser.cs | 48 ++----------- Projectiles/Ranged/BlueExoArrow.cs | 38 +--------- Projectiles/Ranged/BlueExoArrow2.cs | 38 +--------- Projectiles/Ranged/ChargedBlast.cs | 38 +--------- Projectiles/Ranged/ChargedBlast2.cs | 38 +--------- Projectiles/Ranged/ChargedBlast3.cs | 38 +--------- Projectiles/Ranged/DrataliornusExoArrow.cs | 38 +--------- Projectiles/Ranged/GreenExoArrow.cs | 50 ++------------ Projectiles/Ranged/MagnomalyBeam.cs | 48 ++----------- Projectiles/Ranged/OrangeExoArrow.cs | 77 +++++---------------- Projectiles/Ranged/PolarStar.cs | 80 +++++----------------- Projectiles/Ranged/TealExoArrow.cs | 48 ++----------- Projectiles/Ranged/TorrentialArrow.cs | 38 +--------- Projectiles/Typeless/MarkRound.cs | 48 ++----------- Utilities/CalamityUtils.cs | 36 ++++++++++ 20 files changed, 138 insertions(+), 778 deletions(-) diff --git a/Projectiles/Boss/DoGNebulaShot.cs b/Projectiles/Boss/DoGNebulaShot.cs index 561983f54e..e22d41f93e 100644 --- a/Projectiles/Boss/DoGNebulaShot.cs +++ b/Projectiles/Boss/DoGNebulaShot.cs @@ -84,39 +84,9 @@ namespace CalamityMod.Projectiles.Boss } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(255, 100, 255, 0); - } + public override Color? GetAlpha(Color lightColor) => new Color(255, 100, 255, 0); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - int num147 = 0; - int num148 = 0; - float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(value6)) - { - Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); - float num162 = 50f; - float scaleFactor = 1.5f; - for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) - { - Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; - Color color29 = projectile.GetAlpha(color25); - color29 *= (num162 - (float)num163) / num162; - color29.A = 0; - Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(50f, 1.5f, lightColor); public override void OnHitPlayer(Player target, int damage, bool crit) { diff --git a/Projectiles/Enemy/DraedonLaser.cs b/Projectiles/Enemy/DraedonLaser.cs index 735763c9ca..22ce49e929 100644 --- a/Projectiles/Enemy/DraedonLaser.cs +++ b/Projectiles/Enemy/DraedonLaser.cs @@ -51,32 +51,6 @@ namespace CalamityMod.Projectiles.Enemy public override Color? GetAlpha(Color lightColor) => new Color(255, 190, 255, 0); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = ModContent.GetTexture(Texture); - float adjustedXOrigin = (texture.Width - projectile.width) * 0.5f + projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle roughScreenBounds = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - // Only draw when within the bounds of the screen for performance reasons. - if (projectile.Hitbox.Intersects(roughScreenBounds)) - { - Vector2 drawPosition = new Vector2(projectile.position.X + adjustedXOrigin, projectile.position.Y + projectile.height / 2) - Main.screenPosition; - drawPosition += Vector2.UnitY * projectile.gfxOffY; - for (int i = 1; i <= (int)TrailLength; i++) - { - Vector2 drawOffset = Vector2.Normalize(projectile.velocity) * i * 1.5f; - Color drawColor = projectile.GetAlpha(lightColor); // The parameter doesn't really matter. The lightColor parameter in GetAlpha is ignored in this case. - drawColor.A = (byte)(255 - projectile.alpha); - drawColor *= (MaxTrailPoints - i) / (float)MaxTrailPoints; - float scale = MathHelper.Lerp(0.45f, 1f, 1f - i / TrailLength) * projectile.scale; - spriteBatch.Draw(texture, drawPosition - drawOffset, null, drawColor, projectile.rotation, new Vector2(adjustedXOrigin, projectile.height * 0.5f), scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(MaxTrailPoints, 1.5f, lightColor); } } diff --git a/Projectiles/Hybrid/AetherBeam.cs b/Projectiles/Hybrid/AetherBeam.cs index e945b3dcff..c30ffe7541 100644 --- a/Projectiles/Hybrid/AetherBeam.cs +++ b/Projectiles/Hybrid/AetherBeam.cs @@ -71,43 +71,9 @@ namespace CalamityMod.Projectiles.Hybrid } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(250, 50, 200, 0); - } + public override Color? GetAlpha(Color lightColor) => new Color(250, 50, 200, 0); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - int num147 = 0; - int num148 = 0; - float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(value6)) - { - Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); - float num162 = 100f; - float scaleFactor = 2f; - if (projectile.ai[1] == 1f) - { - num162 = (float)(int)projectile.localAI[0]; - } - for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) - { - Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; - Color color29 = projectile.GetAlpha(color25); - color29 *= (num162 - (float)num163) / num162; - color29.A = 0; - Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(100f, 2f, lightColor); public override bool OnTileCollide(Vector2 oldVelocity) { diff --git a/Projectiles/Magic/PurgeLaser.cs b/Projectiles/Magic/PurgeLaser.cs index 4f8cf505d6..4e20342b5e 100644 --- a/Projectiles/Magic/PurgeLaser.cs +++ b/Projectiles/Magic/PurgeLaser.cs @@ -54,52 +54,18 @@ namespace CalamityMod.Projectiles.Magic } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(100, 255, 100, 0); - } + public override Color? GetAlpha(Color lightColor) => new Color(100, 255, 100, 0); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - int num147 = 0; - int num148 = 0; - float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(value6)) - { - Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); - float num162 = 100f; - float scaleFactor = 3f; - if (projectile.ai[1] == 1f) - { - num162 = (float)(int)projectile.localAI[0]; - } - for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) - { - Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; - Color color29 = projectile.GetAlpha(color25); - color29 *= (num162 - (float)num163) / num162; - color29.A = 0; - Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(100f, 3f, lightColor); public override void Kill(int timeLeft) { - int num212 = Main.rand.Next(3, 7); - for (int num213 = 0; num213 < num212; num213++) + int dustAmt = Main.rand.Next(3, 7); + for (int d = 0; d < dustAmt; d++) { - int num214 = Dust.NewDust(projectile.Center - projectile.velocity / 2f, 0, 0, 107, 0f, 0f, 100, default, 2.1f); - Main.dust[num214].velocity *= 2f; - Main.dust[num214].noGravity = true; + int nano = Dust.NewDust(projectile.Center - projectile.velocity / 2f, 0, 0, 107, 0f, 0f, 100, default, 2.1f); + Main.dust[nano].velocity *= 2f; + Main.dust[nano].noGravity = true; } } } diff --git a/Projectiles/Magic/SHPL.cs b/Projectiles/Magic/SHPL.cs index af8553ca67..44f8d7250a 100644 --- a/Projectiles/Magic/SHPL.cs +++ b/Projectiles/Magic/SHPL.cs @@ -55,65 +55,24 @@ namespace CalamityMod.Projectiles.Magic } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(255, Main.DiscoG, 155, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(255, Main.DiscoG, 155, projectile.alpha); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - int num147 = 0; - int num148 = 0; - float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(value6)) - { - Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); - float num162 = 100f; - float scaleFactor = 3f; - if (projectile.ai[1] == 1f) - { - num162 = (float)(int)projectile.localAI[0]; - } - for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) - { - Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; - Color color29 = projectile.GetAlpha(color25); - color29 *= (num162 - (float)num163) / num162; - color29.A = 0; - Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(100f, 3f, lightColor); public override void Kill(int timeLeft) { - int num212 = Main.rand.Next(3, 7); - for (int num213 = 0; num213 < num212; num213++) + int dustAmt = Main.rand.Next(3, 7); + for (int d = 0; d < dustAmt; d++) { - int randomDust = Main.rand.Next(3); - if (randomDust == 0) - { - randomDust = 246; - } - else if (randomDust == 1) - { - randomDust = 73; - } - else - { - randomDust = 187; - } - int num214 = Dust.NewDust(projectile.Center - projectile.velocity / 2f, 0, 0, randomDust, 0f, 0f, 100, default, 2.1f); - Main.dust[num214].velocity *= 2f; - Main.dust[num214].noGravity = true; + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 246, + 73, + 187 + }); + int idx = Dust.NewDust(projectile.Center - projectile.velocity / 2f, 0, 0, dustType, 0f, 0f, 100, default, 2.1f); + Main.dust[idx].velocity *= 2f; + Main.dust[idx].noGravity = true; } } } diff --git a/Projectiles/Magic/T1000Laser.cs b/Projectiles/Magic/T1000Laser.cs index abdecd9dc4..4fa913a742 100644 --- a/Projectiles/Magic/T1000Laser.cs +++ b/Projectiles/Magic/T1000Laser.cs @@ -54,52 +54,18 @@ namespace CalamityMod.Projectiles.Magic } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); - } + public override Color? GetAlpha(Color lightColor) => new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - int num147 = 0; - int num148 = 0; - float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(value6)) - { - Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); - float num162 = 100f; - float scaleFactor = 3f; - if (projectile.ai[1] == 1f) - { - num162 = (float)(int)projectile.localAI[0]; - } - for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) - { - Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; - Color color29 = projectile.GetAlpha(color25); - color29 *= (num162 - (float)num163) / num162; - color29.A = 0; - Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(100f, 3f, lightColor); public override void Kill(int timeLeft) { - int num212 = Main.rand.Next(3, 7); - for (int num213 = 0; num213 < num212; num213++) + int dustAmt = Main.rand.Next(3, 7); + for (int d = 0; d < dustAmt; d++) { - int num214 = Dust.NewDust(projectile.Center - projectile.velocity / 2f, 0, 0, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 2.1f); - Main.dust[num214].velocity *= 2f; - Main.dust[num214].noGravity = true; + int rainbow = Dust.NewDust(projectile.Center - projectile.velocity / 2f, 0, 0, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 2.1f); + Main.dust[rainbow].velocity *= 2f; + Main.dust[rainbow].noGravity = true; } } } diff --git a/Projectiles/Ranged/BlueExoArrow.cs b/Projectiles/Ranged/BlueExoArrow.cs index af1e56c89d..03834fd351 100644 --- a/Projectiles/Ranged/BlueExoArrow.cs +++ b/Projectiles/Ranged/BlueExoArrow.cs @@ -58,43 +58,9 @@ namespace CalamityMod.Projectiles.Ranged } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(0, 0, 250, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(0, 0, 250, projectile.alpha); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - int num147 = 0; - int num148 = 0; - float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(value6)) - { - Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); - float num162 = 40f; - float scaleFactor = 1.5f; - if (projectile.ai[1] == 1f) - { - num162 = (float)(int)projectile.localAI[0]; - } - for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) - { - Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; - Color color29 = projectile.GetAlpha(color25); - color29 *= (num162 - (float)num163) / num162; - color29.A = 0; - Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(40f, 1.5f, lightColor); public override void OnHitPvp(Player target, int damage, bool crit) { diff --git a/Projectiles/Ranged/BlueExoArrow2.cs b/Projectiles/Ranged/BlueExoArrow2.cs index 9a21c15e2b..79dc4951c1 100644 --- a/Projectiles/Ranged/BlueExoArrow2.cs +++ b/Projectiles/Ranged/BlueExoArrow2.cs @@ -55,42 +55,8 @@ namespace CalamityMod.Projectiles.Ranged } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(0, 0, 250, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(0, 0, 250, projectile.alpha); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - int num147 = 0; - int num148 = 0; - float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(value6)) - { - Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); - float num162 = 40f; - float scaleFactor = 1.5f; - if (projectile.ai[1] == 1f) - { - num162 = (float)(int)projectile.localAI[0]; - } - for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) - { - Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; - Color color29 = projectile.GetAlpha(color25); - color29 *= (num162 - (float)num163) / num162; - color29.A = 0; - Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(40f, 1.5f, lightColor); } } diff --git a/Projectiles/Ranged/ChargedBlast.cs b/Projectiles/Ranged/ChargedBlast.cs index ac3663da55..1cf2ed9638 100644 --- a/Projectiles/Ranged/ChargedBlast.cs +++ b/Projectiles/Ranged/ChargedBlast.cs @@ -56,43 +56,9 @@ namespace CalamityMod.Projectiles.Ranged } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(100, 100, 255, 0); - } + public override Color? GetAlpha(Color lightColor) => new Color(100, 100, 255, 0); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - int num147 = 0; - int num148 = 0; - float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(value6)) - { - Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); - float num162 = 100f; - float scaleFactor = 3f; - if (projectile.ai[1] == 1f) - { - num162 = (float)(int)projectile.localAI[0]; - } - for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) - { - Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; - Color color29 = projectile.GetAlpha(color25); - color29 *= (num162 - (float)num163) / num162; - color29.A = 0; - Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(100f, 3f, lightColor); public override void Kill(int timeLeft) { diff --git a/Projectiles/Ranged/ChargedBlast2.cs b/Projectiles/Ranged/ChargedBlast2.cs index 21c98913f5..b30748bba4 100644 --- a/Projectiles/Ranged/ChargedBlast2.cs +++ b/Projectiles/Ranged/ChargedBlast2.cs @@ -56,43 +56,9 @@ namespace CalamityMod.Projectiles.Ranged } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(100, 100, 255, 0); - } + public override Color? GetAlpha(Color lightColor) => new Color(100, 100, 255, 0); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - int num147 = 0; - int num148 = 0; - float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(value6)) - { - Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); - float num162 = 30f; - float scaleFactor = 1f; - if (projectile.ai[1] == 1f) - { - num162 = (float)(int)projectile.localAI[0]; - } - for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) - { - Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; - Color color29 = projectile.GetAlpha(color25); - color29 *= (num162 - (float)num163) / num162; - color29.A = 0; - Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(100f, 3f, lightColor); public override bool OnTileCollide(Vector2 oldVelocity) { diff --git a/Projectiles/Ranged/ChargedBlast3.cs b/Projectiles/Ranged/ChargedBlast3.cs index 6640730753..3681b87ca3 100644 --- a/Projectiles/Ranged/ChargedBlast3.cs +++ b/Projectiles/Ranged/ChargedBlast3.cs @@ -55,43 +55,9 @@ namespace CalamityMod.Projectiles.Ranged } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(100, 100, 255, 0); - } + public override Color? GetAlpha(Color lightColor) => new Color(100, 100, 255, 0); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - int num147 = 0; - int num148 = 0; - float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(value6)) - { - Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); - float num162 = 50f; - float scaleFactor = 1.5f; - if (projectile.ai[1] == 1f) - { - num162 = (float)(int)projectile.localAI[0]; - } - for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) - { - Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; - Color color29 = projectile.GetAlpha(color25); - color29 *= (num162 - (float)num163) / num162; - color29.A = 0; - Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(100f, 3f, lightColor); public override bool OnTileCollide(Vector2 oldVelocity) { diff --git a/Projectiles/Ranged/DrataliornusExoArrow.cs b/Projectiles/Ranged/DrataliornusExoArrow.cs index d57837122d..542676e270 100644 --- a/Projectiles/Ranged/DrataliornusExoArrow.cs +++ b/Projectiles/Ranged/DrataliornusExoArrow.cs @@ -76,42 +76,8 @@ namespace CalamityMod.Projectiles.Ranged target.ExoDebuffs(); } - public override Color? GetAlpha(Color lightColor) - { - return new Color(250, 25, 0, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(250, 25, 0, projectile.alpha); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - int num147 = 0; - int num148 = 0; - float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(value6)) - { - Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); - float num162 = 100f; - float scaleFactor = 3f; - if (projectile.ai[1] == 1f) - { - num162 = (float)(int)projectile.localAI[0]; - } - for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) - { - Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; - Color color29 = projectile.GetAlpha(color25); - color29 *= (num162 - (float)num163) / num162; - color29.A = 0; - Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(100f, 3f, lightColor); } } diff --git a/Projectiles/Ranged/GreenExoArrow.cs b/Projectiles/Ranged/GreenExoArrow.cs index 966670abc7..11fdbe8181 100644 --- a/Projectiles/Ranged/GreenExoArrow.cs +++ b/Projectiles/Ranged/GreenExoArrow.cs @@ -55,59 +55,19 @@ namespace CalamityMod.Projectiles.Ranged } } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.ExoDebuffs(); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => target.ExoDebuffs(); - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.ExoDebuffs(); - } + public override void OnHitPvp(Player target, int damage, bool crit) => target.ExoDebuffs(); - public override Color? GetAlpha(Color lightColor) - { - return new Color(0, 250, 0, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(0, 250, 0, projectile.alpha); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - int num147 = 0; - int num148 = 0; - float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(value6)) - { - Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); - float num162 = 40f; - float scaleFactor = 1.5f; - if (projectile.ai[1] == 1f) - { - num162 = (float)(int)projectile.localAI[0]; - } - for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) - { - Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; - Color color29 = projectile.GetAlpha(color25); - color29 *= (num162 - (float)num163) / num162; - color29.A = 0; - Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(40f, 1.5f, lightColor); public override void Kill(int timeLeft) { if (projectile.owner == Main.myPlayer) { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(),projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(),projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Ranged/MagnomalyBeam.cs b/Projectiles/Ranged/MagnomalyBeam.cs index 6814cdcebe..d61fe1ca81 100644 --- a/Projectiles/Ranged/MagnomalyBeam.cs +++ b/Projectiles/Ranged/MagnomalyBeam.cs @@ -63,52 +63,12 @@ namespace CalamityMod.Projectiles.Ranged } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - int num147 = 0; - int num148 = 0; - float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(value6)) - { - Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); - float num162 = 100f; - float scaleFactor = 2f; - if (projectile.ai[1] == 1f) - { - num162 = (float)(int)projectile.localAI[0]; - } - for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) - { - Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; - Color color29 = projectile.GetAlpha(color25); - color29 *= (num162 - (float)num163) / num162; - color29.A = 0; - Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(100f, 2f, lightColor); - public override Color? GetAlpha(Color lightColor) - { - return new Color(0, 250, 75, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(0, 250, 75, projectile.alpha); - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.ExoDebuffs(); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => target.ExoDebuffs(); - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.ExoDebuffs(); - } + public override void OnHitPvp(Player target, int damage, bool crit) => target.ExoDebuffs(); } } diff --git a/Projectiles/Ranged/OrangeExoArrow.cs b/Projectiles/Ranged/OrangeExoArrow.cs index 275bbc4e0a..35520c58ad 100644 --- a/Projectiles/Ranged/OrangeExoArrow.cs +++ b/Projectiles/Ranged/OrangeExoArrow.cs @@ -55,80 +55,37 @@ namespace CalamityMod.Projectiles.Ranged } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(250, 100, 0, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(250, 100, 0, projectile.alpha); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - int num147 = 0; - int num148 = 0; - float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(value6)) - { - Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); - float num162 = 40f; - float scaleFactor = 1.5f; - if (projectile.ai[1] == 1f) - { - num162 = (float)(int)projectile.localAI[0]; - } - for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) - { - Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; - Color color29 = projectile.GetAlpha(color25); - color29 *= (num162 - (float)num163) / num162; - color29.A = 0; - Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(40f, 1.5f, lightColor); - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.ExoDebuffs(); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => target.ExoDebuffs(); - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.ExoDebuffs(); - } + public override void OnHitPvp(Player target, int damage, bool crit) => target.ExoDebuffs(); public override void Kill(int timeLeft) { - projectile.position = projectile.Center; - projectile.width = projectile.height = 188; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 188); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 20; projectile.Damage(); - Main.PlaySound(SoundID.Item14, projectile.position); - for (int num193 = 0; num193 < 4; num193++) + Main.PlaySound(SoundID.Item14, projectile.Center); + for (int d = 0; d < 4; d++) { - Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 127, 0f, 0f, 50, default, 1f); + Dust.NewDust(projectile.position, projectile.width, projectile.height, 127, 0f, 0f, 50, default, 1f); } - for (int num194 = 0; num194 < 40; num194++) + for (int d = 0; d < 40; d++) { - int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 127, 0f, 0f, 0, default, 1.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].noLight = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 127, 0f, 0f, 50, default, 1f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; - Main.dust[num195].noLight = true; + int orange = Dust.NewDust(projectile.position, projectile.width, projectile.height, 127, 0f, 0f, 0, default, 1.5f); + Main.dust[orange].noGravity = true; + Main.dust[orange].noLight = true; + Main.dust[orange].velocity *= 3f; + orange = Dust.NewDust(projectile.position, projectile.width, projectile.height, 127, 0f, 0f, 50, default, 1f); + Main.dust[orange].velocity *= 2f; + Main.dust[orange].noGravity = true; + Main.dust[orange].noLight = true; } } } diff --git a/Projectiles/Ranged/PolarStar.cs b/Projectiles/Ranged/PolarStar.cs index e315f5bfe0..cb784f7e50 100644 --- a/Projectiles/Ranged/PolarStar.cs +++ b/Projectiles/Ranged/PolarStar.cs @@ -44,17 +44,17 @@ namespace CalamityMod.Projectiles.Ranged } else { - for (int num41 = 0; num41 < 2; num41++) + for (int d = 0; d < 2; d++) { - int dustType = num41 == 0 ? dust1 : dust2; + int dustType = d == 0 ? dust1 : dust2; Vector2 value8 = Vector2.UnitX * -12f; - value8 = -Vector2.UnitY.RotatedBy((double)(projectile.localAI[0] * 0.1308997f + (float)num41 * 3.14159274f), default) * value7; + value8 = -Vector2.UnitY.RotatedBy((double)(projectile.localAI[0] * 0.1308997f + (float)d * MathHelper.Pi), default) * value7; int num42 = Dust.NewDust(projectile.Center, 0, 0, dustType, 0f, 0f, 160, default, 1f); Main.dust[num42].scale = dustType == dust1 ? 1.5f : 1f; Main.dust[num42].noGravity = true; Main.dust[num42].position = projectile.Center + value8; Main.dust[num42].velocity = projectile.velocity; - int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 0.8f); + int num458 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 0.8f); Main.dust[num458].noGravity = true; Main.dust[num458].velocity *= 0f; } @@ -124,55 +124,17 @@ namespace CalamityMod.Projectiles.Ranged } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(255, 255, 255, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(255, 255, 255, projectile.alpha); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - int num147 = 0; - int num148 = 0; - float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(value6)) - { - Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); - float num162 = 40f; - float scaleFactor = 1.5f; - if (projectile.ai[1] == 1f) - { - num162 = (float)(int)projectile.localAI[0]; - } - for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) - { - Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; - Color color29 = projectile.GetAlpha(color25); - color29 *= (num162 - (float)num163) / num162; - color29.A = 0; - Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(40f, 1.5f, lightColor); public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { Player player = Main.player[projectile.owner]; - if ((target.damage > 5 || target.boss) && player.whoAmI == Main.myPlayer && !target.SpawnedFromStatue) + if ((target.damage > 5 || target.boss) && projectile.owner == Main.myPlayer && !target.SpawnedFromStatue) { player.AddBuff(ModContent.BuffType(), 180); } - else - { - return; - } } public override bool OnTileCollide(Vector2 oldVelocity) @@ -199,11 +161,7 @@ namespace CalamityMod.Projectiles.Ranged } if (projectile.ai[1] == 2f) //Boost three { - int height = 150; - - projectile.position = projectile.Center; - projectile.width = projectile.height = height; - projectile.Center = projectile.position; + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 150); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; @@ -211,21 +169,21 @@ namespace CalamityMod.Projectiles.Ranged projectile.damage /= 2; projectile.Damage(); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) // 108 dusts + int dustAmt = 36; + for (int d = 0; d < dustAmt; d++) // 108 dusts { - Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.3f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * MathHelper.TwoPi / (float)num226), default) + projectile.Center; - Vector2 vector7 = vector6 - projectile.Center; + Vector2 source = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.3f; + source = source.RotatedBy((double)((float)(d - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + projectile.Center; + Vector2 dustVel = source - projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, Main.rand.NextBool(2) ? dust1 : dust2, vector7.X * 0.3f, vector7.Y * 0.3f, 100, default, 2f); - Main.dust[num228].noGravity = true; + int i = Dust.NewDust(source + dustVel, 0, 0, Main.rand.NextBool(2) ? dust1 : dust2, dustVel.X * 0.3f, dustVel.Y * 0.3f, 100, default, 2f); + Main.dust[i].noGravity = true; - int num229 = Dust.NewDust(vector6 + vector7, 0, 0, Main.rand.NextBool(2) ? dust1 : dust2, vector7.X * 0.2f, vector7.Y * 0.2f, 100, default, 2f); - Main.dust[num229].noGravity = true; + int j = Dust.NewDust(source + dustVel, 0, 0, Main.rand.NextBool(2) ? dust1 : dust2, dustVel.X * 0.2f, dustVel.Y * 0.2f, 100, default, 2f); + Main.dust[j].noGravity = true; - int num230 = Dust.NewDust(vector6 + vector7, 0, 0, Main.rand.NextBool(2) ? dust1 : dust2, vector7.X * 0.1f, vector7.Y * 0.1f, 100, default, 2f); - Main.dust[num230].noGravity = true; + int k = Dust.NewDust(source + dustVel, 0, 0, Main.rand.NextBool(2) ? dust1 : dust2, dustVel.X * 0.1f, dustVel.Y * 0.1f, 100, default, 2f); + Main.dust[k].noGravity = true; } bool random = Main.rand.NextBool(); diff --git a/Projectiles/Ranged/TealExoArrow.cs b/Projectiles/Ranged/TealExoArrow.cs index 0704497d31..c0ceeba1a9 100644 --- a/Projectiles/Ranged/TealExoArrow.cs +++ b/Projectiles/Ranged/TealExoArrow.cs @@ -57,52 +57,12 @@ namespace CalamityMod.Projectiles.Ranged } } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.ExoDebuffs(); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => target.ExoDebuffs(); - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.ExoDebuffs(); - } + public override void OnHitPvp(Player target, int damage, bool crit) => target.ExoDebuffs(); - public override Color? GetAlpha(Color lightColor) - { - return new Color(0, 100, 100, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(0, 100, 100, projectile.alpha); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - int num147 = 0; - int num148 = 0; - float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(value6)) - { - Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); - float num162 = 40f; - float scaleFactor = 1.5f; - if (projectile.ai[1] == 1f) - { - num162 = (float)(int)projectile.localAI[0]; - } - for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) - { - Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; - Color color29 = projectile.GetAlpha(color25); - color29 *= (num162 - (float)num163) / num162; - color29.A = 0; - Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(40f, 1.5f, lightColor); } } diff --git a/Projectiles/Ranged/TorrentialArrow.cs b/Projectiles/Ranged/TorrentialArrow.cs index 087a802f04..adfffe776a 100644 --- a/Projectiles/Ranged/TorrentialArrow.cs +++ b/Projectiles/Ranged/TorrentialArrow.cs @@ -56,42 +56,8 @@ namespace CalamityMod.Projectiles.Ranged } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(53, Main.DiscoG, 255, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(53, Main.DiscoG, 255, projectile.alpha); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - int num147 = 0; - int num148 = 0; - float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(value6)) - { - Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); - float num162 = 40f; - float scaleFactor = 1.5f; - if (projectile.ai[1] == 1f) - { - num162 = (float)(int)projectile.localAI[0]; - } - for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) - { - Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; - Color color29 = projectile.GetAlpha(color25); - color29 *= (num162 - (float)num163) / num162; - color29.A = 0; - Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(40f, 1.5f, lightColor); } } diff --git a/Projectiles/Typeless/MarkRound.cs b/Projectiles/Typeless/MarkRound.cs index 3e6ca65fbb..dd12c3e8ec 100644 --- a/Projectiles/Typeless/MarkRound.cs +++ b/Projectiles/Typeless/MarkRound.cs @@ -54,52 +54,18 @@ namespace CalamityMod.Projectiles.Typeless } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(200, 0, 250, 0); - } + public override Color? GetAlpha(Color lightColor) => new Color(200, 0, 250, 0); - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); - int num147 = 0; - int num148 = 0; - float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); - if (projectile.getRect().Intersects(value6)) - { - Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); - float num162 = 30f; - float scaleFactor = 2f; - if (projectile.ai[1] == 1f) - { - num162 = (float)(int)projectile.localAI[0]; - } - for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) - { - Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; - Color color29 = projectile.GetAlpha(color25); - color29 *= (num162 - (float)num163) / num162; - color29.A = 0; - Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); - } - } - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.DrawBeam(30f, 2f, lightColor); public override void Kill(int timeLeft) { - int num212 = Main.rand.Next(3, 7); - for (int num213 = 0; num213 < num212; num213++) + int dustAmt = Main.rand.Next(3, 7); + for (int d = 0; d < dustAmt; d++) { - int num214 = Dust.NewDust(projectile.Center - projectile.velocity / 2f, 0, 0, 173, 0f, 0f, 100, default, 2.1f); - Main.dust[num214].velocity *= 2f; - Main.dust[num214].noGravity = true; + int purple = Dust.NewDust(projectile.Center - projectile.velocity / 2f, 0, 0, 173, 0f, 0f, 100, default, 2.1f); + Main.dust[purple].velocity *= 2f; + Main.dust[purple].noGravity = true; } } diff --git a/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index 1fe61dfec4..1b41e70c7a 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -1781,6 +1781,42 @@ namespace CalamityMod } } + public static bool DrawBeam(this Projectile projectile, float length, float width, Color lightColor, Texture2D texture = null) + { + if (texture is null) + texture = Main.projectileTexture[projectile.type]; + + float widthOffset = (float)(texture.Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; + float heightOffset = (float)(projectile.height / 2); + Vector2 origin = new Vector2(widthOffset, heightOffset); + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + { + spriteEffects = SpriteEffects.FlipHorizontally; + } + Rectangle roughScreenBounds = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); + if (projectile.getRect().Intersects(roughScreenBounds)) + { + Vector2 drawPos = projectile.position - Main.screenPosition + origin; + drawPos.Y += projectile.gfxOffY; + float maxTrailPoints = length; + float wide = width; + if (projectile.ai[1] == 1f) + { + maxTrailPoints = (int)projectile.localAI[0]; + } + for (int i = 1; i <= (int)projectile.localAI[0]; i++) + { + Vector2 offset = Vector2.Normalize(projectile.velocity) * (float)i * wide; + Color color = projectile.GetAlpha(lightColor); + color *= (maxTrailPoints - (float)i) / maxTrailPoints; + color.A = 0; + Main.spriteBatch.Draw(texture, drawPos - offset, null, color, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + } + } + return false; + } + public static void ExplodeandDestroyTiles(Projectile projectile, int explosionRadius, bool checkExplosions, List tilesToCheck, List wallsToCheck) { int minTileX = (int)projectile.position.X / 16 - explosionRadius;