diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index f990cdbb25..f2daddd259 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -42,6 +42,7 @@ using CalamityMod.Items.PermanentBoosters; using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Items.Potions; using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.Items.Tools; using CalamityMod.Items.Tools.ClimateChange; using CalamityMod.Items.TreasureBags.MiscGrabBags; using CalamityMod.Items.VanillaArmorChanges; @@ -52,16 +53,19 @@ using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs; using CalamityMod.NPCs.ProfanedGuardians; +using CalamityMod.NPCs.Ravager; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.Melee.Shortswords; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; using CalamityMod.Systems; using CalamityMod.Systems.Collections; +using CalamityMod.Systems.Mechanic; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -79,9 +83,6 @@ using Terraria.ModLoader.IO; using Terraria.Net; using static Terraria.Main; using static Terraria.ModLoader.ModContent; -using CalamityMod.Projectiles.Melee.Shortswords; -using CalamityMod.NPCs.Ravager; -using CalamityMod.Items.Tools; namespace CalamityMod.CalPlayer { @@ -203,7 +204,7 @@ namespace CalamityMod.CalPlayer /// /// A cooldown for losing Starbursts over time, reset by holding Stratus items or having Sirius spawned /// - public int HasStratusItemCooldown = 0; + public int StratusStarburstResetTimer = 0; /// /// Duration of Stratus Sphere's Starshield /// @@ -2111,10 +2112,10 @@ namespace CalamityMod.CalPlayer if (Starshield > 0) { Starshield--; - HasStratusItemCooldown = (int)MathHelper.Max(300,HasStratusItemCooldown); + StratusStarburstResetTimer = (int)MathHelper.Max(300,StratusStarburstResetTimer); } - if (HasStratusItemCooldown > 0) - HasStratusItemCooldown--; + if (StratusStarburstResetTimer > 0) + StratusStarburstResetTimer--; else if (StratusStarburst > 0) StratusStarburst--; if (StratusStarburst > MaxStratusStarburst) @@ -2161,7 +2162,7 @@ namespace CalamityMod.CalPlayer oneCount -= 10; } AvaliableStarburst = avaliableStarpower; - if (HasStratusItemCooldown > 0) + if (StratusStarburstResetTimer > 0) { if (cooldowns.TryGetValue(Starburst.ID, out var cooldown)) { @@ -4792,21 +4793,6 @@ namespace CalamityMod.CalPlayer public override void PostUpdate() { - for (var i = 0; i < StarburstEntities.Count; i++) - { - StarburstEntity star = StarburstEntities[i]; - star.AI(Player, i); - star.UpdatePosition(); - star.UpdateAnimation(); - var safeStarLooper = star.MergeChildren.ToList(); - foreach (var ministar in safeStarLooper) - { - ministar.AI(Player, i); - ministar.UpdatePosition(); - ministar.UpdateAnimation(); - } - } - if (subtitletext != null) { if (!subtitletext.active) diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index d582719b0a..724180957a 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -15,8 +15,9 @@ using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; using CalamityMod.Systems.Collections; -using CalamityMod.Utilities.Daybreak; using CalamityMod.Systems.Graphic.PixelationSystem; +using CalamityMod.Systems.Mechanic; +using CalamityMod.Utilities.Daybreak; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -72,34 +73,6 @@ namespace CalamityMod.CalPlayer AndromedaMechLayer.DrawTheStupidFuckingRobot(ref drawInfo); CalamityPlayer calamityPlayer = Player.Calamity(); - //Stratus Starburst visuals - if (StarburstEntities.Count > 0 && drawInfo.shadow == 0f) - { - PixelationManager.AddPixelatedDrawer(drawLayer: Enums.GeneralDrawLayer.AfterProjectiles, defaultBlendState: BlendState.Additive, drawAction: (matrix) => - { - //This uses the same star and glow textures that the constellations use, so we're just getting the static textures Draco uses to prevent needless requests - var tex = TextureAssets.Projectile[ModContent.ProjectileType()].Value; - var glowTex = DracoConstellation.GetGlowTex(); - for (var i = 0; i < StarburstEntities.Count; i++) - { - StarburstEntity star = StarburstEntities[i]; - var color = star.color; - var value = star.value; - value -= star.MergeChildren.Count; - var ScaleMod = MathHelper.Lerp(0.4f, 0.8f, value / 10f); - - Main.spriteBatch.Draw(glowTex, star.Center - Main.screenPosition, null, star.color * 0.66f, 0, glowTex.Size() * 0.5f, 0.2f * star.scale * ScaleMod, SpriteEffects.None, 1); - Main.spriteBatch.Draw(tex, star.Center - Main.screenPosition, null, star.color * 0.66f, MathHelper.WrapAngle(Main.GlobalTimeWrappedHourly + i), tex.Size() * 0.5f, 0.75f * star.scale * ScaleMod, SpriteEffects.None, 1); - for (var i2 = 0; i2 < star.MergeChildren.Count; i2++) - { - var ministar = star.MergeChildren[i2]; - ScaleMod = MathHelper.Lerp(0.4f, 0.8f, ministar.value / 10f); - Main.spriteBatch.Draw(glowTex, ministar.Center - Main.screenPosition, null, ministar.color * 0.66f, 0, glowTex.Size() * 0.5f, 0.2f * ministar.scale * ScaleMod, SpriteEffects.None, 1); - Main.spriteBatch.Draw(tex, ministar.Center - Main.screenPosition, null, ministar.color * 0.66f, MathHelper.WrapAngle(Main.GlobalTimeWrappedHourly + i), tex.Size() * 0.5f, 0.75f * ministar.scale * ScaleMod, SpriteEffects.None, 1); - } - } - }); - } if (Starshield > 0 && drawInfo.shadow == 0) { @@ -115,7 +88,6 @@ namespace CalamityMod.CalPlayer //Draw the bloom circle Texture2D telegraphBase = StratusBlackHole.GetTransparentBloomTex(); - //Main.EntitySpriteDraw(telegraphBase, drawPosition, null, Color.DarkSlateBlue * opacity, 0, telegraphBase.Size() / 2f, size * 1.5f * opacity / telegraphBase.Width, 0, 0); //Draw the inner particles Main.spriteBatch.EnterShaderRegion(matrix: matrix); @@ -123,7 +95,6 @@ namespace CalamityMod.CalPlayer GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].UseSaturation(0.2f); GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/MeltyNoiseHighContrast"), 1); GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].Apply(); - //telegraphBase = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; Main.EntitySpriteDraw(telegraphBase, drawPosition, null, Color.DarkSlateBlue * opacity, 0, telegraphBase.Size() / 2f, size * 2f * opacity / telegraphBase.Width, 0, 0); //Draw the outer particles diff --git a/Cooldowns/Starburst.cs b/Cooldowns/Starburst.cs index f615ba7b2a..d91bd2f585 100644 --- a/Cooldowns/Starburst.cs +++ b/Cooldowns/Starburst.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Cooldowns public static new string ID => "Starburst"; public override bool CanTickDown => false; public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); - public override bool ShouldDisplay => instance.player.Calamity().HasStratusItemCooldown > 0; + public override bool ShouldDisplay => instance.player.Calamity().StratusStarburstResetTimer > 0; public override string Texture => "CalamityMod/Cooldowns/" + ID; public override Color CooldownStartColor => IsEmpty ? Color.DimGray : Color.Lerp(Color.SkyBlue, Color.DeepSkyBlue, instance.Completion); @@ -36,8 +36,6 @@ namespace CalamityMod.Cooldowns public override void DrawExpanded(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) { base.DrawExpanded(spriteBatch, position, opacity, scale); - - //CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, MathHelper.Min(instance.player.Calamity().StratusStarburst,CalamityPlayer.MaxStratusStarburst).ToString(), position + TextPosition, TextColor, TextBorderColor); var value = CalamityPlayer.MaxStratusStarburst - instance.timeLeft; float Xoffset = value > 9 ? value > 99 ? -12.5f : -10f : -5; CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, (value).ToString(), position + new Vector2(Xoffset, 4) * scale, TextColor, TextBorderColor, scale); diff --git a/DataStructures/StarburstEntity.cs b/DataStructures/StarburstEntity.cs deleted file mode 100644 index 158f4946ad..0000000000 --- a/DataStructures/StarburstEntity.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.DataStructures -{ - public class StarburstEntity - { - public Vector2 Center = Vector2.Zero; - public Vector2 Velocity = Vector2.Zero; - /// - /// How long before the starburst resumes normal following AI - /// - public int AICooldown = 0; - public int frameCounter = 0; - public int frame = 0; - public int value = 1; - public float scale = 1f; - public float opacity = 1; - public Color color = Color.Black; - public StarburstEntity MergeTarget = null; - public List MergeChildren = new(); - public bool ShouldRemoveFromList = false; - - public StarburstEntity(Vector2 position, bool shouldRandomize = true) - { - Center = position; - if (shouldRandomize) - { - Velocity = Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi) * 3; - } - switch (Main.rand.Next(1, 7)) - { - case 1: - color = Color.HotPink; - break; - case 2: - color = Color.Yellow; - break; - case 3: - color = Color.LimeGreen; - break; - case 4: - color = Color.SkyBlue; - break; - case 5: - color = Color.Lavender; - break; - case 6: - color = Color.White; - break; - } - color = Color.Lerp(Color.White, color, 0.5f); - } - public void AI(Player owner, int index = 0) - { - if (AICooldown > 0) - { - MergeChildren = new(); - AICooldown--; - return; - } - if (MergeTarget != null) - { - Velocity += Center.DirectionTo(MergeTarget.Center) * 2.5f; - Velocity *= 0.925f; - if (Center.Distance(MergeTarget.Center) < 12) - MergeTarget.MergeChildren.Remove(this); - return; - } - if (Center.Distance(owner.Center) > 100) - { - Velocity += Center.DirectionTo(owner.Center + new Vector2(16,0).RotatedBy(index)).RotatedByRandom(0.3f); - Velocity *= 0.95f; - } - } - - public void UpdatePosition() - { - Center += Velocity; - } - - public void UpdateAnimation() - { - frameCounter++; - if (frameCounter > 6) - { - frame++; - frameCounter = 0; - } - if (frame > 5) - frame = 0; - } - } -} diff --git a/Items/Weapons/Magic/AlphaDraconis.cs b/Items/Weapons/Magic/AlphaDraconis.cs index 31040aebfb..ae908a8aee 100644 --- a/Items/Weapons/Magic/AlphaDraconis.cs +++ b/Items/Weapons/Magic/AlphaDraconis.cs @@ -48,7 +48,7 @@ namespace CalamityMod.Items.Weapons.Magic } public override void HoldItem(Player player) { - player.Calamity().HasStratusItemCooldown = (int)MathHelper.Max(player.Calamity().HasStratusItemCooldown, 600); + player.Calamity().StratusStarburstResetTimer = (int)MathHelper.Max(player.Calamity().StratusStarburstResetTimer, 600); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Melee/CrescentMoon.cs b/Items/Weapons/Melee/CrescentMoon.cs index e0f9eae1f9..de1086891f 100644 --- a/Items/Weapons/Melee/CrescentMoon.cs +++ b/Items/Weapons/Melee/CrescentMoon.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void HoldItem(Player player) { - player.Calamity().HasStratusItemCooldown = (int)MathHelper.Max(player.Calamity().HasStratusItemCooldown, 600); + player.Calamity().StratusStarburstResetTimer = (int)MathHelper.Max(player.Calamity().StratusStarburstResetTimer, 600); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Melee/GalileoGladius.cs b/Items/Weapons/Melee/GalileoGladius.cs index d68d144c50..aeebf858bb 100644 --- a/Items/Weapons/Melee/GalileoGladius.cs +++ b/Items/Weapons/Melee/GalileoGladius.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Melee } public override void HoldItem(Player player) { - player.Calamity().HasStratusItemCooldown = (int)MathHelper.Max(player.Calamity().HasStratusItemCooldown, 600); + player.Calamity().StratusStarburstResetTimer = (int)MathHelper.Max(player.Calamity().StratusStarburstResetTimer, 600); } public override bool AltFunctionUse(Player player) diff --git a/Items/Weapons/Ranged/HalleysInferno.cs b/Items/Weapons/Ranged/HalleysInferno.cs index 36cd11d0ed..f72ae367c7 100644 --- a/Items/Weapons/Ranged/HalleysInferno.cs +++ b/Items/Weapons/Ranged/HalleysInferno.cs @@ -68,7 +68,7 @@ namespace CalamityMod.Items.Weapons.Ranged Projectile.NewProjectile(player.GetSource_ItemUse(Item),player.Center,Vector2.Zero,Item.shoot,0,0,player.whoAmI); } } - player.Calamity().HasStratusItemCooldown = (int)MathHelper.Max(player.Calamity().HasStratusItemCooldown, 600); + player.Calamity().StratusStarburstResetTimer = (int)MathHelper.Max(player.Calamity().StratusStarburstResetTimer, 600); player.Calamity().ammoCost *= 0.5f; } diff --git a/Items/Weapons/Rogue/Vega.cs b/Items/Weapons/Rogue/Vega.cs index 2c88c70e57..7b5832a40d 100644 --- a/Items/Weapons/Rogue/Vega.cs +++ b/Items/Weapons/Rogue/Vega.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void HoldItem(Player player) { ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; - player.Calamity().HasStratusItemCooldown = (int)MathHelper.Max(player.Calamity().HasStratusItemCooldown, 600); + player.Calamity().StratusStarburstResetTimer = (int)MathHelper.Max(player.Calamity().StratusStarburstResetTimer, 600); } public override bool AltFunctionUse(Player player) diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson index 340a0eed0a..50a472b19a 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson @@ -716,7 +716,7 @@ Sirius: { Continue summoning to complete Canis Major Repeated summons increase its power greatly, even after the constellation is complete Sirius passively generates Starbursts when near enemies - When Starbursts are full, Sirius consumes them to launch a powerful piercing quazar + When Starbursts are full, Sirius consumes them to launch a powerful piercing quasar ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson index 1bdc2e1c52..fdc43eba28 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson @@ -325,6 +325,5 @@ WrathwingCinder.DisplayName: Wrathwing Eruption WrathwingFireball.DisplayName: Wrathwing Fireball WrathwingSpear.DisplayName: Wrathwing WulfrumKnifeProj.DisplayName: Wulfrum Knife - LyraConstellation.DisplayName: Lyra Constellation -ScorpiusConstellation.DisplayName: Scorpius Constellation \ No newline at end of file +ScorpiusConstellation.DisplayName: Scorpius Constellation diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson index 62bc68280c..612736762c 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson @@ -254,7 +254,7 @@ Shellfish.DisplayName: Shellfish SilvaCrystal.DisplayName: Silva Crystal SilvaCrystalExplosion.DisplayName: Silva Explosion SiriusBeam.DisplayName: Sirius Beam -SiriusQuazar.DisplayName: Sirius Quazar +SiriusQuasar.DisplayName: Sirius Quasar SiriusExplosion.DisplayName: Sirius Explosion SiriusMinion.DisplayName: Sirius SkeletalDragonChild.DisplayName: Skeletal Child diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson index bbc2a2bede..4521bdd13e 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson @@ -172,4 +172,4 @@ YellowLabSeeker.DisplayName: Seeking Mechanism VoidofExtinctionCrit.DisplayName: Void of Extinction Crit XykDeathAnim.DisplayName: Xyk Death Animation XykWings.DisplayName: Xyk Wings -StratusBlackHole.DisplayName: Stratus Black Hole +StratusBlackHole.DisplayName: Stratus Singularity diff --git a/Projectiles/Magic/AlphaDraconisStar.cs b/Projectiles/Magic/AlphaDraconisStar.cs index 394505f1fd..a54c132ee8 100644 --- a/Projectiles/Magic/AlphaDraconisStar.cs +++ b/Projectiles/Magic/AlphaDraconisStar.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Particles; +using CalamityMod.Utilities.Daybreak; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -122,10 +123,12 @@ namespace CalamityMod.Projectiles.Magic public override bool PreDraw(ref Color lightColor) { - Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => + using (Main.spriteBatch.Scope()) { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); CalamityUtils.DrawAfterimagesCentered(Projectile, 1, Color.White, shrink: true); - }); + Main.spriteBatch.End(); + } return false; } } diff --git a/Projectiles/Magic/DracoConstellation.cs b/Projectiles/Magic/DracoConstellation.cs index 21373ae996..c71ee5fa60 100644 --- a/Projectiles/Magic/DracoConstellation.cs +++ b/Projectiles/Magic/DracoConstellation.cs @@ -82,7 +82,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.timeLeft > 60) { Main.player[Projectile.owner].Calamity().StratusStarburst--; - Main.player[Projectile.owner].Calamity().HasStratusItemCooldown = (int)MathHelper.Max(Main.player[Projectile.owner].Calamity().HasStratusItemCooldown, 240); + Main.player[Projectile.owner].Calamity().StratusStarburstResetTimer = (int)MathHelper.Max(Main.player[Projectile.owner].Calamity().StratusStarburstResetTimer, 240); } if (Segments.Count <= 0) { diff --git a/Projectiles/Melee/CrescentMoonFlail.cs b/Projectiles/Melee/CrescentMoonFlail.cs index 140f092601..df9de73172 100644 --- a/Projectiles/Melee/CrescentMoonFlail.cs +++ b/Projectiles/Melee/CrescentMoonFlail.cs @@ -5,6 +5,7 @@ using CalamityMod.DataStructures; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Projectiles.Summon; +using CalamityMod.Systems.Mechanic; using Microsoft.Build.Evaluation; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -196,7 +197,7 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { - var startPos = Main.player[Projectile.owner].Center + Main.player[Projectile.owner].DirectionTo(Projectile.Center) * 20f;// + Main.OffsetsPlayerOnhand[Main.player[Projectile.owner].bodyFrame.Y / 56] * 2f; + var startPos = Main.player[Projectile.owner].Center + Main.player[Projectile.owner].DirectionTo(Projectile.Center) * 20f; var endPos = Projectile.Center; var rotation = Projectile.DirectionFrom(startPos).ToRotation() - MathHelper.PiOver2; var tex = TextureAssets.Projectile[Type].Value; diff --git a/Projectiles/Melee/ScorpiusConstellation.cs b/Projectiles/Melee/ScorpiusConstellation.cs index 4cfde6c038..e79122c6fa 100644 --- a/Projectiles/Melee/ScorpiusConstellation.cs +++ b/Projectiles/Melee/ScorpiusConstellation.cs @@ -2,6 +2,7 @@ using System; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Particles; +using CalamityMod.Utilities.Daybreak; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -97,8 +98,9 @@ namespace CalamityMod.Projectiles.Melee CalamityUtils.DrawLineBetter(Main.spriteBatch, SiriusPos + point1.RotatedBy(Projectile.rotation) * Projectile.scale, SiriusPos + point2.RotatedBy(Projectile.rotation) * Projectile.scale, color * Projectile.Opacity, 3); } //Order is back of tail to front. Last four are the head - Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => + using (Main.spriteBatch.Scope()) { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); ConnectStars(new Vector2(-255, 77), new Vector2(-176, 71)); ConnectStars(new Vector2(-176, 71), new Vector2(-236, 142)); ConnectStars(new Vector2(-236, 142), new Vector2(-188, 197)); @@ -110,7 +112,8 @@ namespace CalamityMod.Projectiles.Melee ConnectStars(new Vector2(99, -166), new Vector2(243, -237)); ConnectStars(new Vector2(99, -166), new Vector2(243, -163)); ConnectStars(new Vector2(99, -166), new Vector2(246, -97)); - }); + Main.spriteBatch.End(); + } return false; } diff --git a/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs b/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs index c25efac800..6131ada730 100644 --- a/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs +++ b/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs @@ -5,6 +5,7 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Sounds; +using CalamityMod.Utilities.Daybreak; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -75,10 +76,14 @@ namespace CalamityMod.Projectiles.Melee.Shortswords { var tex = ModContent.Request("CalamityMod/Particles/GlowBlade").Value; var sparkAngle = angle.RotatedBy(MathHelper.Pi); - Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => + + using (Main.spriteBatch.Scope()) { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); Main.spriteBatch.Draw(tex, Projectile.Center + sparkAngle * -10 - Main.screenPosition, null, Color.SkyBlue * 0.75f, sparkAngle.ToRotation() + MathHelper.PiOver2, new Vector2(tex.Width * 0.5f,tex.Height), new Vector2(0.85f, MathHelper.Lerp(0.1f, 1.4f, SwingCompletion)) * Projectile.scale * 0.04f, SpriteEffects.None, 1); - }); + + Main.spriteBatch.End(); + } var tex2 = TextureAssets.Projectile[Type].Value; Main.spriteBatch.Draw(tex2, Projectile.Center + new Vector2(0, Projectile.gfxOffY) - Main.screenPosition, null, Color.SkyBlue * 1f, Projectile.rotation, tex2.Size() * 0.5f, Projectile.scale, Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 1); @@ -88,10 +93,12 @@ namespace CalamityMod.Projectiles.Melee.Shortswords public override void PostDraw(Color lightColor) { var tex2 = ModContent.Request("CalamityMod/Projectiles/Melee/GalileoGladiusGlow").Value; - Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => + using (Main.spriteBatch.Scope()) { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); Main.spriteBatch.Draw(tex2, Projectile.Center + new Vector2(0, Projectile.gfxOffY) - Main.screenPosition, null, Color.SkyBlue * 0.75f, Projectile.rotation, tex2.Size() * 0.5f, Projectile.scale, Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 1); - }); + Main.spriteBatch.End(); + } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { diff --git a/Projectiles/Melee/Shortswords/GalileoGladiusThrown.cs b/Projectiles/Melee/Shortswords/GalileoGladiusThrown.cs index cc54bcac0a..1f660375a7 100644 --- a/Projectiles/Melee/Shortswords/GalileoGladiusThrown.cs +++ b/Projectiles/Melee/Shortswords/GalileoGladiusThrown.cs @@ -8,6 +8,7 @@ using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Projectiles.Pets; using CalamityMod.Projectiles.Rogue; using CalamityMod.Sounds; +using CalamityMod.Utilities.Daybreak; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -240,15 +241,17 @@ namespace CalamityMod.Projectiles.Melee.Shortswords float size = intensity/32f; intensity *= intensitymult; var color = Color.SkyBlue * 0.75f * ((MathF.Sin(Main.GlobalTimeWrappedHourly) + 1) * 0.25f + 0.5f); - Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => + using (Main.spriteBatch.Scope()) { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); for (var i = 1; i < offsets.Count; i++) { var p1 = Vector2.Lerp(point1, point2, i / (float)(offsets.Count - 1)) + new Vector2(0, intensity).RotatedBy(point1.DirectionTo(point2).ToRotation()) * MathF.Sin(Projectile.ai[2] * 0.01f * offsets[i].Item2 + offsets[i].Item1); var p2 = Vector2.Lerp(point1, point2, (i - 1) / (float)(offsets.Count - 1)) + new Vector2(0, intensity).RotatedBy(point1.DirectionTo(point2).ToRotation()) * MathF.Sin(Projectile.ai[2] * 0.01f * offsets[i - 1].Item2 + offsets[i - 1].Item1); CalamityUtils.DrawLineBetter(Main.spriteBatch, p1, p2, color, 2 * size); } - }); + Main.spriteBatch.End(); + } return base.PreDraw(ref lightColor); } diff --git a/Projectiles/Rogue/LyraConstellation.cs b/Projectiles/Rogue/LyraConstellation.cs index cf9b5d4247..323b89b4f3 100644 --- a/Projectiles/Rogue/LyraConstellation.cs +++ b/Projectiles/Rogue/LyraConstellation.cs @@ -2,6 +2,7 @@ using System; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Particles; +using CalamityMod.Utilities.Daybreak; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using rail; @@ -84,8 +85,9 @@ namespace CalamityMod.Projectiles.Rogue var color = Color.SkyBlue * 0.75f * ((MathF.Sin(Main.GlobalTimeWrappedHourly) + 1) * 0.25f + 0.5f); CalamityUtils.DrawLineBetter(Main.spriteBatch, SiriusPos + point1.RotatedBy(Projectile.rotation) * Projectile.scale - (Owner.oldVelocity * Math.Clamp(point1.Length() * 0.001f, 0, 1)), SiriusPos + point2.RotatedBy(Projectile.rotation) * Projectile.scale - (Owner.oldVelocity * Math.Clamp(point2.Length() * 0.001f, 0, 1)), color, 3); } - Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => + using (Main.spriteBatch.Scope()) { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); ConnectStars(new Vector2(0f, 0f), new Vector2(75, -60)); //Center - Vega ConnectStars(new Vector2(0f, 0f), new Vector2(3, -102)); //Center - Top ConnectStars(new Vector2(0f, 0f), new Vector2(-96, 35)); //Center - Left @@ -93,7 +95,8 @@ namespace CalamityMod.Projectiles.Rogue ConnectStars(new Vector2(75, -60), new Vector2(3, -102)); //Vega - Top ConnectStars(new Vector2(-144, 239), new Vector2(-96, 35)); //Bottom L - Left ConnectStars(new Vector2(-144, 239), new Vector2(-52, 207)); //Bottom L - Bottom R - }); + Main.spriteBatch.End(); + } return false; } diff --git a/Projectiles/Rogue/VegaProjectile.cs b/Projectiles/Rogue/VegaProjectile.cs index fb23d28c37..7d0b91d0cc 100644 --- a/Projectiles/Rogue/VegaProjectile.cs +++ b/Projectiles/Rogue/VegaProjectile.cs @@ -1,6 +1,7 @@ using System; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.CalPlayer; +using CalamityMod.Systems.Mechanic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -99,7 +100,7 @@ namespace CalamityMod.Projectiles.Rogue { Main.player[Projectile.owner].Calamity().StratusStarburst++; if (Main.player[Projectile.owner].Calamity().StratusStarburst <= CalamityPlayer.MaxStratusStarburst) - Main.player[Projectile.owner].Calamity().StarburstEntities.Add(new DataStructures.StarburstEntity(Projectile.Center)); + Main.player[Projectile.owner].Calamity().StarburstEntities.Add(new StarburstEntity(Projectile.Center)); } } diff --git a/Projectiles/Summon/SiriusMinion.cs b/Projectiles/Summon/SiriusMinion.cs index 272788dddc..17621d6251 100644 --- a/Projectiles/Summon/SiriusMinion.cs +++ b/Projectiles/Summon/SiriusMinion.cs @@ -6,6 +6,7 @@ using CalamityMod.DataStructures; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Particles; using CalamityMod.Systems.Graphic.PixelationSystem; +using CalamityMod.Systems.Mechanic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using rail; @@ -74,7 +75,7 @@ namespace CalamityMod.Projectiles.Summon if (target is not null && Owner.miscCounter % 30 == 0) { if (moddedOwner.StratusStarburst <= CalamityPlayer.MaxStratusStarburst) - moddedOwner.StarburstEntities.Add(new DataStructures.StarburstEntity(Projectile.Center)); + moddedOwner.StarburstEntities.Add(new StarburstEntity(Projectile.Center)); moddedOwner.StratusStarburst++; } Lighting.AddLight(Projectile.Center, 0.5f, 0.5f, 1f); // Passively makes blue light. @@ -129,7 +130,7 @@ namespace CalamityMod.Projectiles.Summon if (moddedOwner.sirius) { Projectile.timeLeft = 2; - moddedOwner.HasStratusItemCooldown = (int)MathHelper.Max(moddedOwner.HasStratusItemCooldown, 60); + moddedOwner.StratusStarburstResetTimer = (int)MathHelper.Max(moddedOwner.StratusStarburstResetTimer, 60); } } } @@ -210,7 +211,7 @@ namespace CalamityMod.Projectiles.Summon { Vector2 velocity = Projectile.Center.DirectionTo(target.Center) * 10; float damageMod = 40; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + velocity, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * damageMod), Projectile.knockBack, Projectile.owner, 1); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + velocity, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * damageMod), Projectile.knockBack, Projectile.owner, 1); } moddedOwner.StratusStarburst -= 50; Projectile.ai[2] = 0; diff --git a/Projectiles/Summon/SiriusQuazar.cs b/Projectiles/Summon/SiriusQuasar.cs similarity index 97% rename from Projectiles/Summon/SiriusQuazar.cs rename to Projectiles/Summon/SiriusQuasar.cs index e72d20e52f..2a543f3297 100644 --- a/Projectiles/Summon/SiriusQuazar.cs +++ b/Projectiles/Summon/SiriusQuasar.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class SiriusQuazar : ModProjectile, ILocalizedModType + public class SiriusQuasar : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Summon"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - //Sirius Quazar AI + //Sirius Quasar AI Projectile.rotation = Projectile.velocity.ToRotation(); Time++; diff --git a/Projectiles/Typeless/StratusBlackHole.cs b/Projectiles/Typeless/StratusBlackHole.cs index 5f15c79566..7e35411ecb 100644 --- a/Projectiles/Typeless/StratusBlackHole.cs +++ b/Projectiles/Typeless/StratusBlackHole.cs @@ -1,6 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Accessories; using CalamityMod.Systems.Graphic.PixelationSystem; +using CalamityMod.Systems.Mechanic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -61,8 +62,8 @@ namespace CalamityMod.Projectiles.Typeless { player.Calamity().StratusStarburst++; if (player.Calamity().StratusStarburst <= CalamityPlayer.MaxStratusStarburst) - player.Calamity().StarburstEntities.Add(new DataStructures.StarburstEntity(Projectile.Center)); - player.Calamity().HasStratusItemCooldown = (int)MathHelper.Max(player.Calamity().HasStratusItemCooldown, 180); + player.Calamity().StarburstEntities.Add(new StarburstEntity(Projectile.Center)); + player.Calamity().StratusStarburstResetTimer = (int)MathHelper.Max(player.Calamity().StratusStarburstResetTimer, 180); } } } diff --git a/Systems/Mechanic/StratusStarburstSystem.cs b/Systems/Mechanic/StratusStarburstSystem.cs new file mode 100644 index 0000000000..5439831916 --- /dev/null +++ b/Systems/Mechanic/StratusStarburstSystem.cs @@ -0,0 +1,165 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer.DrawLayers; +using CalamityMod.DataStructures; +using CalamityMod.Projectiles.Magic; +using CalamityMod.Systems.Graphic.PixelationSystem; +using CalamityMod.Utilities.Daybreak; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Systems.Mechanic +{ + public class StarburstEntity + { + private sealed class StarburstManager : ModPlayer + { + //Done with a ref to CalamityPlayer so that it's easy for other code to get this value with Player.Calamity() + public ref List StarburstEntities => ref Player.Calamity().StarburstEntities; + public override void PostUpdate() + { + + for (var i = 0; i < StarburstEntities.Count; i++) + { + StarburstEntity star = StarburstEntities[i]; + star.AI(Player, i); + star.UpdatePosition(); + star.UpdateAnimation(); + var safeStarLooper = star.MergeChildren.ToList(); + foreach (var ministar in safeStarLooper) + { + ministar.AI(Player, i); + ministar.UpdatePosition(); + ministar.UpdateAnimation(); + } + } + } + public override void DrawEffects(PlayerDrawSet drawInfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright) + { + if (StarburstEntities.Count > 0 && drawInfo.shadow == 0f) + { + using (Main.spriteBatch.Scope()) + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + //This uses the same star and glow textures that the constellations use, so we're just getting the static textures Draco uses to prevent needless requests + var tex = TextureAssets.Projectile[ModContent.ProjectileType()].Value; + var glowTex = DracoConstellation.GetGlowTex(); + for (var i = 0; i < StarburstEntities.Count; i++) + { + StarburstEntity star = StarburstEntities[i]; + var color = star.color; + var value = star.value; + value -= star.MergeChildren.Count; + var ScaleMod = MathHelper.Lerp(0.4f, 0.8f, value / 10f); + + Main.spriteBatch.Draw(glowTex, star.Center - Main.screenPosition, null, star.color * 0.66f, 0, glowTex.Size() * 0.5f, 0.2f * star.scale * ScaleMod, SpriteEffects.None, 1); + Main.spriteBatch.Draw(tex, star.Center - Main.screenPosition, null, star.color * 0.66f, MathHelper.WrapAngle(Main.GlobalTimeWrappedHourly + i), tex.Size() * 0.5f, 0.75f * star.scale * ScaleMod, SpriteEffects.None, 1); + for (var i2 = 0; i2 < star.MergeChildren.Count; i2++) + { + var ministar = star.MergeChildren[i2]; + ScaleMod = MathHelper.Lerp(0.4f, 0.8f, ministar.value / 10f); + Main.spriteBatch.Draw(glowTex, ministar.Center - Main.screenPosition, null, ministar.color * 0.66f, 0, glowTex.Size() * 0.5f, 0.2f * ministar.scale * ScaleMod, SpriteEffects.None, 1); + Main.spriteBatch.Draw(tex, ministar.Center - Main.screenPosition, null, ministar.color * 0.66f, MathHelper.WrapAngle(Main.GlobalTimeWrappedHourly + i), tex.Size() * 0.5f, 0.75f * ministar.scale * ScaleMod, SpriteEffects.None, 1); + } + } + Main.spriteBatch.End(); + } + } + } + } + + public Vector2 Center = Vector2.Zero; + public Vector2 Velocity = Vector2.Zero; + /// + /// How long before the starburst resumes normal following AI + /// + public int AICooldown = 0; + public int frameCounter = 0; + public int frame = 0; + public int value = 1; + public float scale = 1f; + public float opacity = 1; + public Color color = Color.Black; + public StarburstEntity MergeTarget = null; + public List MergeChildren = new(); + public bool ShouldRemoveFromList = false; + + public StarburstEntity(Vector2 position, bool shouldRandomize = true) + { + Center = position; + if (shouldRandomize) + { + Velocity = Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi) * 3; + } + switch (Main.rand.Next(1, 7)) + { + case 1: + color = Color.HotPink; + break; + case 2: + color = Color.Yellow; + break; + case 3: + color = Color.LimeGreen; + break; + case 4: + color = Color.SkyBlue; + break; + case 5: + color = Color.Lavender; + break; + case 6: + color = Color.White; + break; + } + color = Color.Lerp(Color.White, color, 0.5f); + } + public void AI(Player owner, int index = 0) + { + if (AICooldown > 0) + { + MergeChildren = new(); + AICooldown--; + return; + } + if (MergeTarget != null) + { + Velocity += Center.DirectionTo(MergeTarget.Center) * 2.5f; + Velocity *= 0.925f; + if (Center.Distance(MergeTarget.Center) < 12) + MergeTarget.MergeChildren.Remove(this); + return; + } + if (Center.Distance(owner.Center) > 100) + { + Velocity += Center.DirectionTo(owner.Center + new Vector2(16, 0).RotatedBy(index)).RotatedByRandom(0.3f); + Velocity *= 0.95f; + } + } + + public void UpdatePosition() + { + Center += Velocity; + } + + public void UpdateAnimation() + { + frameCounter++; + if (frameCounter > 6) + { + frame++; + frameCounter = 0; + } + if (frame > 5) + frame = 0; + } + } +}