diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index 7c4d79aaee..484eff3b3a 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.Alcohol; +using CalamityMod.Buffs.Alcohol; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; using CalamityMod.Projectiles.Ranged; @@ -809,7 +809,7 @@ namespace CalamityMod.CalPlayer if (BloomStoneRegen) { float dayTimeCompletion = !Main.dayTime ? 1f : (float)(Main.time / Main.dayLength); - float regenBenefitFactor = MathHelper.SmoothStep(0.25f, 1f, Utils.InverseLerp(0f, 0.24f, dayTimeCompletion, true) * Utils.InverseLerp(1f, 0.76f, dayTimeCompletion, true)); + float regenBenefitFactor = MathHelper.SmoothStep(0.25f, 1f, Utils.GetLerpValue(0f, 0.24f, dayTimeCompletion, true) * Utils.GetLerpValue(1f, 0.76f, dayTimeCompletion, true)); Player.lifeRegen += (int)MathHelper.Lerp(2f, 6f, regenBenefitFactor); Player.lifeRegenTime += (int)MathHelper.Lerp(1f, 3f, regenBenefitFactor); diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index e02623586b..39e06f15d5 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -679,7 +679,7 @@ namespace CalamityMod.CalPlayer // Otherwise, if the intensity is too weak, but still presernt, cause the player to release holy cinders. else if (providenceBurnIntensity > 0f) { - int cinderCount = (int)MathHelper.Lerp(1f, 4f, Utils.InverseLerp(0f, 0.45f, providenceBurnIntensity, true)); + int cinderCount = (int)MathHelper.Lerp(1f, 4f, Utils.GetLerpValue(0f, 0.45f, providenceBurnIntensity, true)); for (int i = 0; i < cinderCount; i++) { if (!Main.rand.NextBool(3)) @@ -1143,7 +1143,7 @@ namespace CalamityMod.CalPlayer int auricDyeCount = Player.dye.Count(dyeItem => dyeItem.type == ModContent.ItemType()); if (auricDyeCount > 0) { - int sparkCreationChance = (int)MathHelper.Lerp(15f, 50f, Utils.InverseLerp(4f, 1f, auricDyeCount, true)); + int sparkCreationChance = (int)MathHelper.Lerp(15f, 50f, Utils.GetLerpValue(4f, 1f, auricDyeCount, true)); if (Main.rand.NextBool(sparkCreationChance)) { Dust spark = Dust.NewDustDirect(Player.position, Player.width, Player.height, 267); diff --git a/Events/BossRushEvent.cs b/Events/BossRushEvent.cs index b409367ca6..dd280ae7b5 100644 --- a/Events/BossRushEvent.cs +++ b/Events/BossRushEvent.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; using CalamityMod.NPCs.AquaticScourge; using CalamityMod.NPCs.AstrumAureus; @@ -468,7 +468,7 @@ namespace CalamityMod.Events } if (EndTimer > 0) - BossRushSky.CurrentInterest = MathHelper.Lerp(0.5f, 0.75f, Utils.InverseLerp(5f, 145f, EndTimer, true)); + BossRushSky.CurrentInterest = MathHelper.Lerp(0.5f, 0.75f, Utils.GetLerpValue(5f, 145f, EndTimer, true)); BossRushSky.CurrentInterestMin = MathHelper.Lerp(0f, 0.5f, (float)Math.Pow(BossRushStage / (float)Bosses.Count, 5D)); } diff --git a/Events/BossRushSky.cs b/Events/BossRushSky.cs index 140c35f3e9..51f49cf024 100644 --- a/Events/BossRushSky.cs +++ b/Events/BossRushSky.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; @@ -68,7 +68,7 @@ namespace CalamityMod.Events return 1f; float fadeRatio = BossRushEvent.StartTimer / (float)BossRushEvent.StartEffectTotalTime; - return Utils.InverseLerp(0.57f, 1f, fadeRatio, true); + return Utils.GetLerpValue(0.57f, 1f, fadeRatio, true); } public override Color OnTileColor(Color inColor) => new Color(Vector4.Lerp(GeneralColor.ToVector4() * 0.5f, inColor.ToVector4(), 1f - GetIntensity())); @@ -89,8 +89,8 @@ namespace CalamityMod.Events { Texture2D whiteTexture = ModContent.Request("CalamityMod/ExtraTextures/XerocLight"); Vector2 screenCenter = new Vector2(Main.screenWidth, Main.screenHeight) * 0.5f; - float fadeToWhite = Utils.InverseLerp(110f, 140f, BossRushEvent.EndTimer, true); - fadeToWhite *= Utils.InverseLerp(BossRushEvent.EndVisualEffectTime - 5f, BossRushEvent.EndVisualEffectTime - 25f, BossRushEvent.EndTimer, true); + float fadeToWhite = Utils.GetLerpValue(110f, 140f, BossRushEvent.EndTimer, true); + fadeToWhite *= Utils.GetLerpValue(BossRushEvent.EndVisualEffectTime - 5f, BossRushEvent.EndVisualEffectTime - 25f, BossRushEvent.EndTimer, true); float backScale = MathHelper.Lerp(0.01f, 8f, fadeToWhite); Color backFadeColor = Color.White * fadeToWhite * 0.64f; diff --git a/Items/Accessories/DaawnlightSpiritOrigin.cs b/Items/Accessories/DaawnlightSpiritOrigin.cs index bc6230709f..9f36ac4838 100644 --- a/Items/Accessories/DaawnlightSpiritOrigin.cs +++ b/Items/Accessories/DaawnlightSpiritOrigin.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Accessories // Factor in the critical strike chance the player isn't getting to use. float convertedCritBonus = StoredCritConversionRatio * mp.spiritOriginConvertedCrit; - float useTimeInterpolant = Utils.InverseLerp(MinUseTimeForSlowBonus, MaxSlowBonusUseTime, p.ActiveItem().useTime, true); + float useTimeInterpolant = Utils.GetLerpValue(MinUseTimeForSlowBonus, MaxSlowBonusUseTime, p.ActiveItem().useTime, true); float slowWeaponBonus = MathHelper.Lerp(0f, MaxSlowWeaponBonus, useTimeInterpolant); return baseCritMult * (1f + convertedCritBonus + slowWeaponBonus); } diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 2d4f97e447..0e5ea8d024 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.Potions; +using CalamityMod.Buffs.Potions; using CalamityMod.Buffs.StatBuffs; using CalamityMod.CalPlayer; using CalamityMod.Events; @@ -1671,7 +1671,7 @@ namespace CalamityMod.Items float currentPower = 0f; int calamitasNPCIndex = NPC.FindFirstNPC(ModContent.NPCType()); if (calamitasNPCIndex != -1) - currentPower = Utils.InverseLerp(11750f, 1000f, Main.LocalPlayer.Distance(Main.npc[calamitasNPCIndex].Center), true); + currentPower = Utils.GetLerpValue(11750f, 1000f, Main.LocalPlayer.Distance(Main.npc[calamitasNPCIndex].Center), true); Vector2 particleDrawCenter = position + new Vector2(12f, 16f) * Main.inventoryScale; diff --git a/Items/VanillaArmorChanges/CobaltArmorSetChange.cs b/Items/VanillaArmorChanges/CobaltArmorSetChange.cs index a61ef4a13c..c83a69f0f4 100644 --- a/Items/VanillaArmorChanges/CobaltArmorSetChange.cs +++ b/Items/VanillaArmorChanges/CobaltArmorSetChange.cs @@ -1,4 +1,4 @@ -using System; +using System; using Terraria; using Terraria.ID; @@ -36,7 +36,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public static float CalculateMovementSpeedInterpolant(Player player) { float milesPerHour = player.velocity.Length() * 225f / 44f; - float movementSpeedInterpolant = Utils.InverseLerp(0f, MovementSpeedBoostMphThreshold, milesPerHour, true); + float movementSpeedInterpolant = Utils.GetLerpValue(0f, MovementSpeedBoostMphThreshold, milesPerHour, true); return (float)Math.Pow(movementSpeedInterpolant, 5D / 3D); } diff --git a/NPCs/AcidRain/GammaSlime.cs b/NPCs/AcidRain/GammaSlime.cs index 8fec78a15b..ee56a5c76f 100644 --- a/NPCs/AcidRain/GammaSlime.cs +++ b/NPCs/AcidRain/GammaSlime.cs @@ -1,4 +1,4 @@ -using CalamityMod.Dusts; +using CalamityMod.Dusts; using CalamityMod.Items.Accessories; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Buffs.StatDebuffs; @@ -18,7 +18,7 @@ namespace CalamityMod.NPCs.AcidRain public float DustAngleMultiplier1; public float DustAngleMultiplier2; public Player Target => Main.player[NPC.target]; - public float LaserTelegraphPower => Utils.InverseLerp(540f, 480f, LaserShootCountdown, true); + public float LaserTelegraphPower => Utils.GetLerpValue(540f, 480f, LaserShootCountdown, true); public float LaserTelegraphLength => MathHelper.Lerp(20f, 550f, LaserTelegraphPower); public float LaserTelegraphOpacity => MathHelper.Lerp(0.3f, 0.9f, LaserTelegraphPower); public ref float GammaAcidShootTimer => ref NPC.ai[0]; diff --git a/NPCs/AcidRain/Mauler.cs b/NPCs/AcidRain/Mauler.cs index 825076db46..edbaea3ba2 100644 --- a/NPCs/AcidRain/Mauler.cs +++ b/NPCs/AcidRain/Mauler.cs @@ -127,7 +127,7 @@ namespace CalamityMod.NPCs.AcidRain // Roar prior to releasing bubbles. if (AttackTimer <= roarDelay) - CurrentFrame = (int)Math.Round(Utils.InverseLerp(0f, roarDelay, AttackTimer, true) * 5f); + CurrentFrame = (int)Math.Round(Utils.GetLerpValue(0f, roarDelay, AttackTimer, true) * 5f); // Animate as usual a bit after roaring. else if (AttackTimer >= roarDelay + shootDelay) diff --git a/NPCs/AcidRain/WaterLeech.cs b/NPCs/AcidRain/WaterLeech.cs index 142bf76157..f962ecc8f3 100644 --- a/NPCs/AcidRain/WaterLeech.cs +++ b/NPCs/AcidRain/WaterLeech.cs @@ -1,4 +1,4 @@ -using CalamityMod.Dusts; +using CalamityMod.Dusts; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Weapons.Magic; using CalamityMod.World; @@ -163,7 +163,7 @@ namespace CalamityMod.NPCs.AcidRain } Vector2 destination = (Target.gravDir == 1f ? Target.Top : Target.Bottom) + Target.direction * Vector2.UnitX * 4f; - float speed = MathHelper.Lerp(7f, 23f, Utils.InverseLerp(10f, ChaseMaxDistance, NPC.Distance(destination), true)); + float speed = MathHelper.Lerp(7f, 23f, Utils.GetLerpValue(10f, ChaseMaxDistance, NPC.Distance(destination), true)); NPC.velocity = NPC.SafeDirectionTo(destination) * speed; if (NPC.WithinRange(destination, 45f)) diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index 22dc2bc24f..575c87f37e 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -777,7 +777,7 @@ namespace CalamityMod.NPCs if (npc.ai[0] != 4f) { // Inverse lerp returns the percentage of progress between A and B - float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); + float lerpValue = Utils.GetLerpValue(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); // Min velocity float minVelocity = distanceFromDestination.Length(); @@ -1529,7 +1529,7 @@ namespace CalamityMod.NPCs if (npc.ai[1] == 0f || npc.ai[1] == 1f || npc.ai[1] == 4f || calamityGlobalNPC.newAI[2] > 0f) { // Inverse lerp returns the percentage of progress between A and B - float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); + float lerpValue = Utils.GetLerpValue(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); // Min velocity float minVelocity = distanceFromDestination.Length(); diff --git a/NPCs/CalamityGlobalAI.cs b/NPCs/CalamityGlobalAI.cs index 56b21a73fe..62d0e5728f 100644 --- a/NPCs/CalamityGlobalAI.cs +++ b/NPCs/CalamityGlobalAI.cs @@ -1,4 +1,4 @@ -using CalamityMod.NPCs.Astral; +using CalamityMod.NPCs.Astral; using CalamityMod.NPCs.Crags; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.PlagueEnemies; @@ -9886,7 +9886,7 @@ namespace CalamityMod.NPCs else if (npc.ai[1] == 1f) { fadeOutTimer++; - npc.scale = MathHelper.Lerp(1f, 0.05f, Utils.InverseLerp(500f, 600f, fadeOutTimer, true)); + npc.scale = MathHelper.Lerp(1f, 0.05f, Utils.GetLerpValue(500f, 600f, fadeOutTimer, true)); // Reset the idle play sound if it didn't get activated before for some reason. if (Main.GetActiveSound(SlotId.FromFloat(idlePlaySoundId)) == null) diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 73a12a43d4..607a00affa 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs; +using CalamityMod.Buffs; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.StatDebuffs; @@ -5630,7 +5630,7 @@ namespace CalamityMod.NPCs public static void SmoothMovement(NPC npc, float movementDistanceGateValue, Vector2 distanceFromDestination, float baseVelocity) { // Inverse lerp returns the percentage of progress between A and B - float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); + float lerpValue = Utils.GetLerpValue(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); // Min velocity float minVelocity = distanceFromDestination.Length(); diff --git a/NPCs/DevourerofGods/DevourerofGodsBody.cs b/NPCs/DevourerofGods/DevourerofGodsBody.cs index c27a58a044..f86e066e81 100644 --- a/NPCs/DevourerofGods/DevourerofGodsBody.cs +++ b/NPCs/DevourerofGods/DevourerofGodsBody.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.World; @@ -208,7 +208,7 @@ namespace CalamityMod.NPCs.DevourerofGods if (Main.netMode != NetmodeID.MultiplayerClient) { Projectile portal = Main.projectile[Main.npc[(int)NPC.ai[2]].ModNPC().PortalIndex]; - float newOpacity = 1f - Utils.InverseLerp(270f, 100f, NPC.Distance(portal.Center), true); + float newOpacity = 1f - Utils.GetLerpValue(270f, 100f, NPC.Distance(portal.Center), true); if (newOpacity > 0f && NPC.Opacity > newOpacity) { NPC.Opacity = newOpacity; diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index 793247ba44..e1017fc650 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -481,7 +481,7 @@ namespace CalamityMod.NPCs.DevourerofGods float idealFlySpeed = 14f; float oldVelocity = NPC.velocity.Length(); - float horizontalInterpolant = Utils.InverseLerp(1200f, 600f, NPC.Center.Y, true); + float horizontalInterpolant = Utils.GetLerpValue(1200f, 600f, NPC.Center.Y, true); Vector2 idealDirection = NPC.velocity.SafeNormalize(-Vector2.UnitY); idealDirection = Vector2.Lerp(idealDirection, Vector2.UnitX * Math.Sign(idealDirection.X), horizontalInterpolant); NPC.velocity = idealDirection * MathHelper.Lerp(oldVelocity, idealFlySpeed, 0.1f); @@ -490,7 +490,7 @@ namespace CalamityMod.NPCs.DevourerofGods if (PortalIndex != -1) { Projectile portal = Main.projectile[PortalIndex]; - float newOpacity = 1f - Utils.InverseLerp(200f, 130f, NPC.Distance(portal.Center), true); + float newOpacity = 1f - Utils.GetLerpValue(200f, 130f, NPC.Distance(portal.Center), true); if (Main.netMode != NetmodeID.MultiplayerClient && newOpacity > 0f && NPC.Opacity > newOpacity) { NPC.Opacity = newOpacity; @@ -2103,7 +2103,7 @@ namespace CalamityMod.NPCs.DevourerofGods } // Slow down but maintain a specific direction. - float idealSpeed = MathHelper.Lerp(8.4f, 4f, Utils.InverseLerp(15f, 210f, DeathAnimationTimer, true)); + float idealSpeed = MathHelper.Lerp(8.4f, 4f, Utils.GetLerpValue(15f, 210f, DeathAnimationTimer, true)); if (NPC.velocity.Length() != idealSpeed) NPC.velocity = NPC.velocity.SafeNormalize(Vector2.UnitY) * MathHelper.Lerp(NPC.velocity.Length(), idealSpeed, 0.08f); @@ -2115,7 +2115,7 @@ namespace CalamityMod.NPCs.DevourerofGods if (DeathAnimationTimer >= 120f && DeathAnimationTimer < 370f && DeathAnimationTimer % 3f == 0f) { - int segmentToDestroy = (int)(Utils.InverseLerp(120f, 370f, DeathAnimationTimer, true) * 60f); + int segmentToDestroy = (int)(Utils.GetLerpValue(120f, 370f, DeathAnimationTimer, true) * 60f); destroySegment(segmentToDestroy, ref DestroyedSegmentCount); } @@ -2143,11 +2143,11 @@ namespace CalamityMod.NPCs.DevourerofGods if (DeathAnimationTimer >= 410f && DeathAnimationTimer < 470f && DeathAnimationTimer % 2f == 0f) { - int segmentToDestroy = (int)(Utils.InverseLerp(410f, 470f, DeathAnimationTimer, true) * 10f) + 60; + int segmentToDestroy = (int)(Utils.GetLerpValue(410f, 470f, DeathAnimationTimer, true) * 10f) + 60; destroySegment(segmentToDestroy, ref DeathAnimationTimer); } - float light = Utils.InverseLerp(430f, 465f, DeathAnimationTimer, true); + float light = Utils.GetLerpValue(430f, 465f, DeathAnimationTimer, true); MoonlordDeathDrama.RequestLight(light, Main.LocalPlayer.Center); if (DeathAnimationTimer >= 485f) diff --git a/NPCs/DevourerofGods/DevourerofGodsTail.cs b/NPCs/DevourerofGods/DevourerofGodsTail.cs index bcaf5b6481..980ee97049 100644 --- a/NPCs/DevourerofGods/DevourerofGodsTail.cs +++ b/NPCs/DevourerofGods/DevourerofGodsTail.cs @@ -229,7 +229,7 @@ namespace CalamityMod.NPCs.DevourerofGods if (Main.netMode != NetmodeID.MultiplayerClient) { Projectile portal = Main.projectile[Main.npc[(int)NPC.ai[2]].ModNPC().PortalIndex]; - float newOpacity = 1f - Utils.InverseLerp(270f, 100f, NPC.Distance(portal.Center), true); + float newOpacity = 1f - Utils.GetLerpValue(270f, 100f, NPC.Distance(portal.Center), true); if (newOpacity > 0f && NPC.Opacity > newOpacity) { NPC.Opacity = newOpacity; diff --git a/NPCs/ExoMechs/Apollo/Apollo.cs b/NPCs/ExoMechs/Apollo/Apollo.cs index d4920b696d..5163465c7b 100644 --- a/NPCs/ExoMechs/Apollo/Apollo.cs +++ b/NPCs/ExoMechs/Apollo/Apollo.cs @@ -1401,14 +1401,14 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo public float RibbonTrailWidthFunction(float completionRatio) { - float baseWidth = Utils.InverseLerp(1f, 0.54f, completionRatio, true) * 5f; - float endTipWidth = CalamityUtils.Convert01To010(Utils.InverseLerp(0.96f, 0.89f, completionRatio, true)) * 2.4f; + float baseWidth = Utils.GetLerpValue(1f, 0.54f, completionRatio, true) * 5f; + float endTipWidth = CalamityUtils.Convert01To010(Utils.GetLerpValue(0.96f, 0.89f, completionRatio, true)) * 2.4f; return baseWidth + endTipWidth; } public Color FlameTrailColorFunction(float completionRatio) { - float trailOpacity = Utils.InverseLerp(0.8f, 0.27f, completionRatio, true) * Utils.InverseLerp(0f, 0.067f, completionRatio, true); + float trailOpacity = Utils.GetLerpValue(0.8f, 0.27f, completionRatio, true) * Utils.GetLerpValue(0f, 0.067f, completionRatio, true); Color startingColor = Color.Lerp(Color.White, Color.Cyan, 0.27f); Color middleColor = Color.Lerp(Color.Orange, Color.ForestGreen, 0.74f); Color endColor = Color.Lime; @@ -1417,7 +1417,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo public Color FlameTrailColorFunctionBig(float completionRatio) { - float trailOpacity = Utils.InverseLerp(0.8f, 0.27f, completionRatio, true) * Utils.InverseLerp(0f, 0.067f, completionRatio, true) * 0.56f; + float trailOpacity = Utils.GetLerpValue(0.8f, 0.27f, completionRatio, true) * Utils.GetLerpValue(0f, 0.067f, completionRatio, true) * 0.56f; Color startingColor = Color.Lerp(Color.White, Color.Cyan, 0.25f); Color middleColor = Color.Lerp(Color.Blue, Color.White, 0.35f); Color endColor = Color.Lerp(Color.DarkBlue, Color.White, 0.47f); @@ -1495,8 +1495,8 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo // Add a sinusoidal offset that goes based on time and completion ratio to create a waving-flag-like effect. // This is dampened for the first few points to prevent weird offsets. It is also dampened by high velocity. float sinusoidalRotationOffset = (float)Math.Sin(ribbonCompletionRatio * 2.22f + Main.GlobalTimeWrappedHourly * 3.4f) * 1.36f; - float sinusoidalRotationOffsetFactor = Utils.InverseLerp(0f, 0.37f, ribbonCompletionRatio, true) * direction * 24f; - sinusoidalRotationOffsetFactor *= Utils.InverseLerp(24f, 16f, NPC.velocity.Length(), true); + float sinusoidalRotationOffsetFactor = Utils.GetLerpValue(0f, 0.37f, ribbonCompletionRatio, true) * direction * 24f; + sinusoidalRotationOffsetFactor *= Utils.GetLerpValue(24f, 16f, NPC.velocity.Length(), true); Vector2 sinusoidalOffset = Vector2.UnitY.RotatedBy(NPC.rotation + sinusoidalRotationOffset) * sinusoidalRotationOffsetFactor; Vector2 ribbonSegmentOffset = Vector2.UnitY.RotatedBy(currentSegmentRotation) * ribbonCompletionRatio * 540f + sinusoidalOffset; diff --git a/NPCs/ExoMechs/Artemis/Artemis.cs b/NPCs/ExoMechs/Artemis/Artemis.cs index db1329e1da..a73d8b4c3a 100644 --- a/NPCs/ExoMechs/Artemis/Artemis.cs +++ b/NPCs/ExoMechs/Artemis/Artemis.cs @@ -1207,14 +1207,14 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis public float RibbonTrailWidthFunction(float completionRatio) { - float baseWidth = Utils.InverseLerp(1f, 0.54f, completionRatio, true) * 5f; - float endTipWidth = CalamityUtils.Convert01To010(Utils.InverseLerp(0.96f, 0.89f, completionRatio, true)) * 2.4f; + float baseWidth = Utils.GetLerpValue(1f, 0.54f, completionRatio, true) * 5f; + float endTipWidth = CalamityUtils.Convert01To010(Utils.GetLerpValue(0.96f, 0.89f, completionRatio, true)) * 2.4f; return baseWidth + endTipWidth; } public Color FlameTrailColorFunction(float completionRatio) { - float trailOpacity = Utils.InverseLerp(0.8f, 0.27f, completionRatio, true) * Utils.InverseLerp(0f, 0.067f, completionRatio, true); + float trailOpacity = Utils.GetLerpValue(0.8f, 0.27f, completionRatio, true) * Utils.GetLerpValue(0f, 0.067f, completionRatio, true); Color startingColor = Color.Lerp(Color.White, Color.Cyan, 0.27f); Color middleColor = Color.Lerp(Color.Orange, Color.Yellow, 0.31f); Color endColor = Color.OrangeRed; @@ -1223,7 +1223,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis public Color FlameTrailColorFunctionBig(float completionRatio) { - float trailOpacity = Utils.InverseLerp(0.8f, 0.27f, completionRatio, true) * Utils.InverseLerp(0f, 0.067f, completionRatio, true) * 0.56f; + float trailOpacity = Utils.GetLerpValue(0.8f, 0.27f, completionRatio, true) * Utils.GetLerpValue(0f, 0.067f, completionRatio, true) * 0.56f; Color startingColor = Color.Lerp(Color.White, Color.Cyan, 0.25f); Color middleColor = Color.Lerp(Color.Blue, Color.White, 0.35f); Color endColor = Color.Lerp(Color.DarkBlue, Color.White, 0.47f); @@ -1301,8 +1301,8 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis // Add a sinusoidal offset that goes based on time and completion ratio to create a waving-flag-like effect. // This is dampened for the first few points to prevent weird offsets. It is also dampened by high velocity. float sinusoidalRotationOffset = (float)Math.Sin(ribbonCompletionRatio * 2.22f + Main.GlobalTimeWrappedHourly * 3.4f) * 1.36f; - float sinusoidalRotationOffsetFactor = Utils.InverseLerp(0f, 0.37f, ribbonCompletionRatio, true) * direction * 24f; - sinusoidalRotationOffsetFactor *= Utils.InverseLerp(24f, 16f, NPC.velocity.Length(), true); + float sinusoidalRotationOffsetFactor = Utils.GetLerpValue(0f, 0.37f, ribbonCompletionRatio, true) * direction * 24f; + sinusoidalRotationOffsetFactor *= Utils.GetLerpValue(24f, 16f, NPC.velocity.Length(), true); Vector2 sinusoidalOffset = Vector2.UnitY.RotatedBy(NPC.rotation + sinusoidalRotationOffset) * sinusoidalRotationOffsetFactor; Vector2 ribbonSegmentOffset = Vector2.UnitY.RotatedBy(currentSegmentRotation) * ribbonCompletionRatio * 540f + sinusoidalOffset; diff --git a/NPCs/ExoMechs/Draedon.cs b/NPCs/ExoMechs/Draedon.cs index 60715136ac..bceaef10fa 100644 --- a/NPCs/ExoMechs/Draedon.cs +++ b/NPCs/ExoMechs/Draedon.cs @@ -155,7 +155,7 @@ namespace CalamityMod.NPCs.ExoMechs if (TalkTimer <= HologramFadeinTime) { HologramEffectTimer = TalkTimer; - NPC.Opacity = Utils.InverseLerp(0f, 8f, TalkTimer, true); + NPC.Opacity = Utils.GetLerpValue(0f, 8f, TalkTimer, true); } // Play the stand up animation after teleportation. @@ -228,8 +228,8 @@ namespace CalamityMod.NPCs.ExoMechs // Make the screen rumble and summon the exo mechs. if (TalkTimer > ExoMechChooseDelay + 8f && TalkTimer < ExoMechPhaseDialogueTime) { - Main.LocalPlayer.Calamity().GeneralScreenShakePower = Utils.InverseLerp(4200f, 1400f, Main.LocalPlayer.Distance(PlayerToFollow.Center), true) * 18f; - Main.LocalPlayer.Calamity().GeneralScreenShakePower *= Utils.InverseLerp(ExoMechChooseDelay + 5f, ExoMechPhaseDialogueTime, TalkTimer, true); + Main.LocalPlayer.Calamity().GeneralScreenShakePower = Utils.GetLerpValue(4200f, 1400f, Main.LocalPlayer.Distance(PlayerToFollow.Center), true) * 18f; + Main.LocalPlayer.Calamity().GeneralScreenShakePower *= Utils.GetLerpValue(ExoMechChooseDelay + 5f, ExoMechPhaseDialogueTime, TalkTimer, true); } // Summon the selected exo mech. @@ -416,7 +416,7 @@ namespace CalamityMod.NPCs.ExoMechs { NPC.velocity *= 0.96f; - float moveSpeed = MathHelper.Lerp(2f, 8f, Utils.InverseLerp(45f, 275f, NPC.Distance(hoverDestination), true)); + float moveSpeed = MathHelper.Lerp(2f, 8f, Utils.GetLerpValue(45f, 275f, NPC.Distance(hoverDestination), true)); NPC.Center = NPC.Center.MoveTowards(hoverDestination, moveSpeed); } else @@ -525,7 +525,7 @@ namespace CalamityMod.NPCs.ExoMechs public override Color? GetAlpha(Color drawColor) { - float teleportFade = Utils.InverseLerp(0f, HologramFadeinTime, HologramEffectTimer, true); + float teleportFade = Utils.GetLerpValue(0f, HologramFadeinTime, HologramEffectTimer, true); Color color = Color.Lerp(drawColor, Color.Cyan, 1f - (float)Math.Pow(teleportFade, 5D)); color.A = (byte)(int)(teleportFade * 255f); diff --git a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs index 068f8cfc4b..1f77c72284 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs @@ -1054,8 +1054,8 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos // A general factor for the aura. // Used to cause fade-ins/outs as the attack starts/stops. - float auraGeneralPower = Utils.InverseLerp(0f, deathrayTelegraphDuration * 0.333f, NPC.Calamity().newAI[2], true); - auraGeneralPower *= Utils.InverseLerp(deathrayTelegraphDuration + deathrayDuration, deathrayTelegraphDuration + deathrayDuration, NPC.Calamity().newAI[2], true); + float auraGeneralPower = Utils.GetLerpValue(0f, deathrayTelegraphDuration * 0.333f, NPC.Calamity().newAI[2], true); + auraGeneralPower *= Utils.GetLerpValue(deathrayTelegraphDuration + deathrayDuration, deathrayTelegraphDuration + deathrayDuration, NPC.Calamity().newAI[2], true); // Determine the characteristics of the aura. This requires intermediate computations to determine if Thanatos is in its final phase as well as for pulsing. bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); @@ -1089,7 +1089,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos // The reticle fades away and moves farther away from the target the closer they are to the aura. // Once far away, the reticle will flash between red and white as an indicator. float targetHeadDistance = NPC.Distance(target.Center); - float reticleOpacity = Utils.InverseLerp(auraRadius * 0.5f - 40f, auraRadius * 0.5f + 100f, targetHeadDistance, true); + float reticleOpacity = Utils.GetLerpValue(auraRadius * 0.5f - 40f, auraRadius * 0.5f + 100f, targetHeadDistance, true); float reticleOffsetDistance = MathHelper.SmoothStep(300f, 0f, reticleOpacity); float reticleFadeToWhite = ((float)Math.Cos(Main.GlobalTimeWrappedHourly * 6.8f) * 0.5f + 0.5f) * reticleOpacity * 0.67f; Color reticleBaseColor = new Color(255, 0, 0, 127) * reticleOpacity; diff --git a/NPCs/NormalNPCs/ThiccWaifu.cs b/NPCs/NormalNPCs/ThiccWaifu.cs index 811db319a9..0bb4c3da25 100644 --- a/NPCs/NormalNPCs/ThiccWaifu.cs +++ b/NPCs/NormalNPCs/ThiccWaifu.cs @@ -175,7 +175,7 @@ namespace CalamityMod.NPCs.NormalNPCs // Fade out and release some gaseous particles. if (AttackTimer <= teleportFadeoutTime) { - float fadeoutCompletion = Utils.InverseLerp(0f, teleportFadeoutTime, AttackTimer, true); + float fadeoutCompletion = Utils.GetLerpValue(0f, teleportFadeoutTime, AttackTimer, true); float particleSpawnRate = MathHelper.Clamp(fadeoutCompletion + 0.6f, 0.5f, 1f); NPC.Opacity = MathHelper.Lerp(1f, 0f, fadeoutCompletion); @@ -203,7 +203,7 @@ namespace CalamityMod.NPCs.NormalNPCs // Fade in and release some particles. if (AttackTimer > teleportFadeoutTime && AttackTimer <= teleportFadeoutTime + teleportFadeinTime) { - float fadeinCompletion = Utils.InverseLerp(teleportFadeoutTime, teleportFadeoutTime + teleportFadeinTime, AttackTimer, true); + float fadeinCompletion = Utils.GetLerpValue(teleportFadeoutTime, teleportFadeoutTime + teleportFadeinTime, AttackTimer, true); float particleSpawnRate = MathHelper.Clamp(fadeinCompletion + 0.6f, 0.5f, 1f); NPC.Opacity = fadeinCompletion; diff --git a/NPCs/NormalNPCs/WulfrumHovercraft.cs b/NPCs/NormalNPCs/WulfrumHovercraft.cs index 337e4f8d66..5ad953cbb0 100644 --- a/NPCs/NormalNPCs/WulfrumHovercraft.cs +++ b/NPCs/NormalNPCs/WulfrumHovercraft.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Accessories; +using CalamityMod.Items.Accessories; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using Microsoft.Xna.Framework; @@ -221,11 +221,11 @@ namespace CalamityMod.NPCs.NormalNPCs SubphaseTime++; if (SubphaseTime < swoopSlowdownTime) { - swoopVelocity *= MathHelper.Lerp(1f, 0.75f, Utils.InverseLerp(45f, 0f, SubphaseTime)); + swoopVelocity *= MathHelper.Lerp(1f, 0.75f, Utils.GetLerpValue(45f, 0f, SubphaseTime)); } if (SubphaseTime >= swoopType - swoopSlowdownTime) { - swoopVelocity *= MathHelper.Lerp(1f, 0.75f, Utils.InverseLerp(swoopType - 45f, swoopType, SubphaseTime)); + swoopVelocity *= MathHelper.Lerp(1f, 0.75f, Utils.GetLerpValue(swoopType - 45f, swoopType, SubphaseTime)); } swoopVelocity.Y *= 0.5f; diff --git a/NPCs/Other/CalamitasEnchantDemon.cs b/NPCs/Other/CalamitasEnchantDemon.cs index 3c4ae56334..ebb2c0f34a 100644 --- a/NPCs/Other/CalamitasEnchantDemon.cs +++ b/NPCs/Other/CalamitasEnchantDemon.cs @@ -1,4 +1,4 @@ -using CalamityMod.Projectiles.Healing; +using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -66,7 +66,7 @@ namespace CalamityMod.NPCs.Other public void FadeAway() { NPC.dontTakeDamage = true; - NPC.Opacity = Utils.InverseLerp(50f, 0f, FadeAwayTimer, true); + NPC.Opacity = Utils.GetLerpValue(50f, 0f, FadeAwayTimer, true); // Become inactive after fading away completely. if (NPC.Opacity <= 0f) diff --git a/NPCs/Other/DemonPortal.cs b/NPCs/Other/DemonPortal.cs index 2af947b8e9..aeb0cdcd1a 100644 --- a/NPCs/Other/DemonPortal.cs +++ b/NPCs/Other/DemonPortal.cs @@ -37,7 +37,7 @@ namespace CalamityMod.NPCs.Other public override void AI() { NPC.rotation += 0.18f; - NPC.Opacity = Utils.InverseLerp(0f, 30f, Time, true) * Utils.InverseLerp(420f, 390f, Time, true); + NPC.Opacity = Utils.GetLerpValue(0f, 30f, Time, true) * Utils.GetLerpValue(420f, 390f, Time, true); NPC.velocity = Vector2.Zero; NPC.scale = NPC.Opacity; diff --git a/NPCs/Other/ExhumedHeart.cs b/NPCs/Other/ExhumedHeart.cs index 6ee81fd38a..3c80359030 100644 --- a/NPCs/Other/ExhumedHeart.cs +++ b/NPCs/Other/ExhumedHeart.cs @@ -50,7 +50,7 @@ namespace CalamityMod.NPCs.Other public override void AI() { - NPC.Opacity = Utils.InverseLerp(0f, 25f, Time, true); + NPC.Opacity = Utils.GetLerpValue(0f, 25f, Time, true); NPC.Center = Owner.Center + (MathHelper.TwoPi * Time / 540f).ToRotationVector2() * 350f; NPC.velocity = Vector2.Zero; @@ -68,7 +68,7 @@ namespace CalamityMod.NPCs.Other public float PrimitiveWidthFunction(float completionRatio) { - float widthInterpolant = Utils.InverseLerp(0f, 0.16f, completionRatio, true) * Utils.InverseLerp(1f, 0.84f, completionRatio, true); + float widthInterpolant = Utils.GetLerpValue(0f, 0.16f, completionRatio, true) * Utils.GetLerpValue(1f, 0.84f, completionRatio, true); widthInterpolant = (float)Math.Pow(widthInterpolant, 8D); float baseWidth = MathHelper.Lerp(4f, 1f, widthInterpolant); float pulseWidth = MathHelper.Lerp(0f, 3.2f, (float)Math.Pow(Math.Sin(Main.GlobalTimeWrappedHourly * 2.6f + NPC.whoAmI * 1.3f + completionRatio), 16D)); @@ -77,7 +77,7 @@ namespace CalamityMod.NPCs.Other public Color PrimitiveColorFunction(float completionRatio) { - float colorInterpolant = MathHelper.SmoothStep(0f, 1f, Utils.InverseLerp(0f, 0.34f, completionRatio, true) * Utils.InverseLerp(1.07f, 0.66f, completionRatio, true)); + float colorInterpolant = MathHelper.SmoothStep(0f, 1f, Utils.GetLerpValue(0f, 0.34f, completionRatio, true) * Utils.GetLerpValue(1.07f, 0.66f, completionRatio, true)); return Color.Lerp(Color.DarkRed * 0.7f, Color.Red, colorInterpolant) * 0.425f; } diff --git a/NPCs/Other/LecherousOrb.cs b/NPCs/Other/LecherousOrb.cs index 3cd97e4c81..22d5b4dbea 100644 --- a/NPCs/Other/LecherousOrb.cs +++ b/NPCs/Other/LecherousOrb.cs @@ -47,7 +47,7 @@ namespace CalamityMod.NPCs.Other public override void AI() { - NPC.Opacity = Utils.InverseLerp(0f, 15f, Time, true); + NPC.Opacity = Utils.GetLerpValue(0f, 15f, Time, true); NPC.velocity = Vector2.Zero; if (Main.myPlayer == NPC.target) @@ -176,7 +176,7 @@ namespace CalamityMod.NPCs.Other public override void NPCLoot() { - int heartsToGive = (int)MathHelper.Lerp(0f, 7f, Utils.InverseLerp(45f, 540f, Time, true)); + int heartsToGive = (int)MathHelper.Lerp(0f, 7f, Utils.GetLerpValue(45f, 540f, Time, true)); for (int i = 0; i < heartsToGive; i++) DropHelper.DropItem(NPC, ItemID.Heart); } diff --git a/NPCs/Perforator/PerforatorHive.cs b/NPCs/Perforator/PerforatorHive.cs index 7abe6247fe..0672a0022b 100644 --- a/NPCs/Perforator/PerforatorHive.cs +++ b/NPCs/Perforator/PerforatorHive.cs @@ -392,7 +392,7 @@ namespace CalamityMod.NPCs.Perforator Vector2 distanceFromDestination = destination - NPC.Center; // Inverse lerp returns the percentage of progress between A and B - float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); + float lerpValue = Utils.GetLerpValue(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); // Min velocity float minVelocity = distanceFromDestination.Length(); diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index b844be33b8..9cbc95139f 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -734,7 +734,7 @@ namespace CalamityMod.NPCs.Providence int dustAmt = (int)MathHelper.Lerp(4f, 8f, calamityGlobalNPC.newAI[3] / spawnAnimationTime); for (int m = 0; m < dustAmt; m++) { - float fade = MathHelper.Lerp(1.3f, 0.7f, NPC.Opacity) * Utils.InverseLerp(0f, 120f, calamityGlobalNPC.newAI[3], clamped: true); + float fade = MathHelper.Lerp(1.3f, 0.7f, NPC.Opacity) * Utils.GetLerpValue(0f, 120f, calamityGlobalNPC.newAI[3], clamped: true); Color newColor = Main.hslToRgb(calamityGlobalNPC.newAI[3] / 180f, 1f, 0.5f); if (!nightTime) @@ -1371,7 +1371,7 @@ namespace CalamityMod.NPCs.Providence } // Idly release harmless cindiers. - int shootRate = (int)MathHelper.Lerp(12f, 5f, Utils.InverseLerp(0f, 250f, DeathAnimationTimer, true)); + int shootRate = (int)MathHelper.Lerp(12f, 5f, Utils.GetLerpValue(0f, 250f, DeathAnimationTimer, true)); if (DeathAnimationTimer % shootRate == shootRate - 1f) { for (int i = 0; i < 3; i++) @@ -1424,7 +1424,7 @@ namespace CalamityMod.NPCs.Providence // A factor which measures how much of the distance shortening shave-off should be taken into account. // It is determined based on how much time has elapsed during the attack thus far, specifically for the two cocoon attacks. // This shave-off does not happen when guardians are present. - float shorterDistanceFade = Utils.InverseLerp(0f, 120f, aiTimer, true); + float shorterDistanceFade = Utils.GetLerpValue(0f, 120f, aiTimer, true); if (!guardianAlive) { maxDistance = baseDistance; @@ -1433,7 +1433,7 @@ namespace CalamityMod.NPCs.Providence } float drawFireDistanceStart = maxDistance - 800f; - return Utils.InverseLerp(drawFireDistanceStart, maxDistance, distanceToTarget, true); + return Utils.GetLerpValue(drawFireDistanceStart, maxDistance, distanceToTarget, true); } private void DespawnSpecificProjectiles(bool dying = false) @@ -1718,7 +1718,7 @@ namespace CalamityMod.NPCs.Providence spriteBatch.Draw(textureGlow2, vector43, NPC.frame, color42, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); } - float burnIntensity = Utils.InverseLerp(0f, 45f, DeathAnimationTimer, true); + float burnIntensity = Utils.GetLerpValue(0f, 45f, DeathAnimationTimer, true); int totalProvidencesToDraw = (int)MathHelper.Lerp(1f, 30f, burnIntensity); for (int i = 0; i < totalProvidencesToDraw; i++) { diff --git a/NPCs/SupremeCalamitas/BrimstoneHeart.cs b/NPCs/SupremeCalamitas/BrimstoneHeart.cs index 1af8d85c2e..faba72df9c 100644 --- a/NPCs/SupremeCalamitas/BrimstoneHeart.cs +++ b/NPCs/SupremeCalamitas/BrimstoneHeart.cs @@ -84,7 +84,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas public float PrimitiveWidthFunction(float completionRatio) { - float widthInterpolant = Utils.InverseLerp(0f, 0.16f, completionRatio, true) * Utils.InverseLerp(1f, 0.84f, completionRatio, true); + float widthInterpolant = Utils.GetLerpValue(0f, 0.16f, completionRatio, true) * Utils.GetLerpValue(1f, 0.84f, completionRatio, true); widthInterpolant = (float)Math.Pow(widthInterpolant, 8D); float baseWidth = MathHelper.Lerp(4f, 1f, widthInterpolant); float pulseWidth = MathHelper.Lerp(0f, 3.2f, (float)Math.Pow(Math.Sin(Main.GlobalTimeWrappedHourly * 2.6f + NPC.whoAmI * 1.3f + completionRatio), 16D)); @@ -93,7 +93,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas public Color PrimitiveColorFunction(float completionRatio) { - float colorInterpolant = MathHelper.SmoothStep(0f, 1f, Utils.InverseLerp(0f, 0.34f, completionRatio, true) * Utils.InverseLerp(1.07f, 0.66f, completionRatio, true)); + float colorInterpolant = MathHelper.SmoothStep(0f, 1f, Utils.GetLerpValue(0f, 0.34f, completionRatio, true) * Utils.GetLerpValue(1.07f, 0.66f, completionRatio, true)); return Color.Lerp(Color.DarkRed * 0.7f, Color.Red, colorInterpolant) * 0.425f; } diff --git a/NPCs/SupremeCalamitas/SCalWormArm.cs b/NPCs/SupremeCalamitas/SCalWormArm.cs index d9f31392a7..d5ef3a9f59 100644 --- a/NPCs/SupremeCalamitas/SCalWormArm.cs +++ b/NPCs/SupremeCalamitas/SCalWormArm.cs @@ -119,8 +119,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.TargetClosest(false); Vector2 idealMovePosition = SegmentToAttachTo.Center; - float sideFactor = MathHelper.Lerp(200f, 18f, Utils.InverseLerp(-0.51f, -0.06f, NPC.rotation, true)); - float aheadFactor = MathHelper.Lerp(284f, 680f, Utils.InverseLerp(-0.51f, -0.06f, NPC.rotation, true)); + float sideFactor = MathHelper.Lerp(200f, 18f, Utils.GetLerpValue(-0.51f, -0.06f, NPC.rotation, true)); + float aheadFactor = MathHelper.Lerp(284f, 680f, Utils.GetLerpValue(-0.51f, -0.06f, NPC.rotation, true)); idealMovePosition += (SegmentToAttachTo.rotation + NPC.rotation * NPC.direction - MathHelper.PiOver2).ToRotationVector2() * NPC.scale * aheadFactor; idealMovePosition += (SegmentToAttachTo.rotation + NPC.rotation * NPC.direction - MathHelper.PiOver2 + MathHelper.PiOver2 * NPC.direction).ToRotationVector2() * NPC.scale * sideFactor; NPC.Center = idealMovePosition; diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index c34296fc7e..5dcf4c40f7 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -571,7 +571,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.Opacity = MathHelper.Lerp(NPC.Opacity, 0f, 0.065f); NPC.velocity = Vector2.Lerp(Vector2.UnitY * -4f, Vector2.Zero, (float)Math.Sin(MathHelper.Pi * NPC.Opacity)); - forcefieldOpacity = Utils.InverseLerp(0.1f, 0.6f, NPC.Opacity, true); + forcefieldOpacity = Utils.GetLerpValue(0.1f, 0.6f, NPC.Opacity, true); if (NPC.alpha >= 230) { if (DownedBossSystem.downedSCal && !BossRushEvent.BossRushActive) @@ -2493,7 +2493,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas heartSpawnPositions.Add(new Vector2(spawnX2 - spawnXAdd * i - 50, tempSpawnY + spawnYAdd * i)); } - float castCompletion = Utils.InverseLerp(sepulcherSpawnCastTime - 25f, 0f, attackCastDelay, true); + float castCompletion = Utils.GetLerpValue(sepulcherSpawnCastTime - 25f, 0f, attackCastDelay, true); Vector2 armPosition = NPC.Center + Vector2.UnitX * NPC.spriteDirection * -8f; // Emit dust at the arm position as a sort of magic effect. @@ -2586,7 +2586,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas // Draw some magic dust much like the sandstorm elemental cast that approaches where the brothers will spawn. if (attackCastDelay < brothersSpawnCastTime - 45f && attackCastDelay >= 60f) { - float castCompletion = Utils.InverseLerp(brothersSpawnCastTime - 45f, 60f, attackCastDelay); + float castCompletion = Utils.GetLerpValue(brothersSpawnCastTime - 45f, 60f, attackCastDelay); Vector2 leftDustPosition = Vector2.CatmullRom(leftOfCircle + Vector2.UnitY * 1000f, leftOfCircle, catastropheSpawnPosition, catastropheSpawnPosition + Vector2.UnitY * 1000f, castCompletion); Vector2 rightDustPosition = Vector2.CatmullRom(rightOfCircle + Vector2.UnitY * 1000f, rightOfCircle, cataclysmSpawnPosition, cataclysmSpawnPosition + Vector2.UnitY * 1000f, castCompletion); @@ -2604,7 +2604,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas // Make some magic effects at where the bros will spawn. if (attackCastDelay < 60f) { - float burnPower = Utils.InverseLerp(60f, 20f, attackCastDelay); + float burnPower = Utils.GetLerpValue(60f, 20f, attackCastDelay); if (attackCastDelay == 0f) burnPower = 4f; @@ -2824,9 +2824,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (FrameType == FrameAnimationType.BlastPunchCast && (NPC.localAI[1] > shootRate - 18 || NPC.localAI[1] <= 15f)) { if (NPC.localAI[1] > shootRate - 18) - NPC.frame.Y = (int)MathHelper.Lerp(0, 3, Utils.InverseLerp(shootRate - 18, shootRate, NPC.localAI[1], true)); + NPC.frame.Y = (int)MathHelper.Lerp(0, 3, Utils.GetLerpValue(shootRate - 18, shootRate, NPC.localAI[1], true)); else - NPC.frame.Y = (int)MathHelper.Lerp(3, 5, Utils.InverseLerp(0f, 15f, NPC.localAI[1], true)); + NPC.frame.Y = (int)MathHelper.Lerp(3, 5, Utils.GetLerpValue(0f, 15f, NPC.localAI[1], true)); NPC.frame.Y += (int)FrameType * 6; } else diff --git a/NPCs/SupremeCalamitas/SupremeCataclysm.cs b/NPCs/SupremeCalamitas/SupremeCataclysm.cs index 0a9ba2e0dc..80b9ef3d14 100644 --- a/NPCs/SupremeCalamitas/SupremeCataclysm.cs +++ b/NPCs/SupremeCalamitas/SupremeCataclysm.cs @@ -70,7 +70,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void FindFrame(int frameHeight) { - float punchInterpolant = Utils.InverseLerp(10f, PunchCounterLimit * 2f, PunchCounter + (PunchingFromRight ? 0f : PunchCounterLimit), true); + float punchInterpolant = Utils.GetLerpValue(10f, PunchCounterLimit * 2f, PunchCounter + (PunchingFromRight ? 0f : PunchCounterLimit), true); if (AttackDelayTimer < 120f) { NPC.frameCounter += 0.15f; diff --git a/NPCs/SupremeCalamitas/SupremeCatastrophe.cs b/NPCs/SupremeCalamitas/SupremeCatastrophe.cs index 9e4b92262a..31d3cda307 100644 --- a/NPCs/SupremeCalamitas/SupremeCatastrophe.cs +++ b/NPCs/SupremeCalamitas/SupremeCatastrophe.cs @@ -72,7 +72,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void FindFrame(int frameHeight) { float slashCounter = SlashCounter + (SlashingFromRight ? 0f : SlashCounterLimit); - float slashInterpolant = Utils.InverseLerp(0f, SlashCounterLimit * 2f, slashCounter, true); + float slashInterpolant = Utils.GetLerpValue(0f, SlashCounterLimit * 2f, slashCounter, true); if (AttackDelayTimer < 120f) { NPC.frameCounter += 0.15f; diff --git a/Particles/BloodParticle.cs b/Particles/BloodParticle.cs index c9438f0b9f..987df72c89 100644 --- a/Particles/BloodParticle.cs +++ b/Particles/BloodParticle.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Particles public override void CustomDraw(SpriteBatch spriteBatch) { - float verticalStretch = Utils.InverseLerp(0f, 24f, Math.Abs(Velocity.Y), true) * 0.84f; + float verticalStretch = Utils.GetLerpValue(0f, 24f, Math.Abs(Velocity.Y), true) * 0.84f; float brightness = (float)Math.Pow(Lighting.Brightness((int)(Position.X / 16f), (int)(Position.Y / 16f)), 0.15); Vector2 scale = new Vector2(1f, verticalStretch + 1f) * Scale * 0.1f; Texture2D texture = ModContent.Request(Texture); diff --git a/Particles/DeathAshParticle.cs b/Particles/DeathAshParticle.cs index e39f057ddb..2280aba230 100644 --- a/Particles/DeathAshParticle.cs +++ b/Particles/DeathAshParticle.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; @@ -229,8 +229,8 @@ namespace CalamityMod.Particles Time++; Scale = MathHelper.Clamp(Scale - (brightness < 0.1f ? 0.08f : 0.008f), 0f, 1f); - float dissipationFactor = Utils.InverseLerp(6f, 16f, Velocity.Length(), true); - float velocityInterpolant = Utils.InverseLerp(25f - dissipationFactor * 10f, 80f - dissipationFactor * 45f, Time, true); + float dissipationFactor = Utils.GetLerpValue(6f, 16f, Velocity.Length(), true); + float velocityInterpolant = Utils.GetLerpValue(25f - dissipationFactor * 10f, 80f - dissipationFactor * 45f, Time, true); Vector2 idealVelocity = new Vector2(Main.windSpeed * MathHelper.Lerp(0.8f, 1.2f, (float)Math.Sin(Center.Y / 50f + ID)) * 20f, (float)Math.Sin(Main.time / 20f + ID * 0.01f) * 3f - 1f); Velocity = Vector2.Lerp(Velocity, idealVelocity, velocityInterpolant * 0.16f); Center += Velocity; diff --git a/Particles/EnchantedParticle.cs b/Particles/EnchantedParticle.cs index 4e7f206b39..816ec55fbc 100644 --- a/Particles/EnchantedParticle.cs +++ b/Particles/EnchantedParticle.cs @@ -30,13 +30,13 @@ namespace CalamityMod.Particles public override void Update() { float distanceToCenter = RelativeOffset.Length(); - Scale = MathHelper.SmoothStep(0.05f, 0.125f, Utils.InverseLerp(EdgeOffset, 6f, distanceToCenter, true)); - Scale *= Utils.InverseLerp(Lifetime, Lifetime - 10f, Time, true); + Scale = MathHelper.SmoothStep(0.05f, 0.125f, Utils.GetLerpValue(EdgeOffset, 6f, distanceToCenter, true)); + Scale *= Utils.GetLerpValue(Lifetime, Lifetime - 10f, Time, true); if (distanceToCenter > 4.5f) RelativeOffset = Vector2.Lerp(RelativeOffset, Vector2.Zero, InterpolationSpeed); - Color = Color.Lerp(EdgeColor, CenterColor, Utils.InverseLerp(0f, 0.67f, LifetimeCompletion, true)); + Color = Color.Lerp(EdgeColor, CenterColor, Utils.GetLerpValue(0f, 0.67f, LifetimeCompletion, true)); Color.A = 50; } } diff --git a/Particles/FireParticle.cs b/Particles/FireParticle.cs index 6ab15c7b70..02bb1e0a40 100644 --- a/Particles/FireParticle.cs +++ b/Particles/FireParticle.cs @@ -32,9 +32,9 @@ namespace CalamityMod.Particles RelativeOffset.Y -= RelativePower * 3f; Color = Color.Lerp(BrightColor, DarkColor, LifetimeCompletion); - Color = Color.Lerp(Color, Color.SaddleBrown, Utils.InverseLerp(0.95f, 0.7f, LifetimeCompletion, true)); - Color = Color.Lerp(Color, Color.White, Utils.InverseLerp(0.1f, 0.25f, LifetimeCompletion, true) * Utils.InverseLerp(0.4f, 0.25f, LifetimeCompletion, true) * 0.7f); - Color *= Utils.InverseLerp(0f, 0.15f, LifetimeCompletion, true) * Utils.InverseLerp(1f, 0.8f, LifetimeCompletion, true) * 0.6f; + Color = Color.Lerp(Color, Color.SaddleBrown, Utils.GetLerpValue(0.95f, 0.7f, LifetimeCompletion, true)); + Color = Color.Lerp(Color, Color.White, Utils.GetLerpValue(0.1f, 0.25f, LifetimeCompletion, true) * Utils.GetLerpValue(0.4f, 0.25f, LifetimeCompletion, true) * 0.7f); + Color *= Utils.GetLerpValue(0f, 0.15f, LifetimeCompletion, true) * Utils.GetLerpValue(1f, 0.8f, LifetimeCompletion, true) * 0.6f; Color.A = 50; } } diff --git a/Particles/HeavySmoke.cs b/Particles/HeavySmoke.cs index 62dd4bcf47..8a5c3a927e 100644 --- a/Particles/HeavySmoke.cs +++ b/Particles/HeavySmoke.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Particles Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f); Velocity *= 0.85f; - float opacity = Utils.InverseLerp(1f, 0.85f, LifetimeCompletion, true); + float opacity = Utils.GetLerpValue(1f, 0.85f, LifetimeCompletion, true); Color *= opacity; } diff --git a/Particles/RancorGroundLavaParticleSet.cs b/Particles/RancorGroundLavaParticleSet.cs index 38bbb1b061..befe8caeb6 100644 --- a/Particles/RancorGroundLavaParticleSet.cs +++ b/Particles/RancorGroundLavaParticleSet.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System.Collections.Generic; using System.Linq; @@ -44,7 +44,7 @@ namespace CalamityMod.Particles Vector2 drawPosition = particle.Center - Main.screenPosition; Vector2 origin = fusableParticleBase.Size() * 0.5f; Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size() * new Vector2(1f, 0.5f); - Color drawColor = Color.Lerp(BorderColor, new Color(0f, 0f, 1f), Utils.InverseLerp(120f, 135f, particle.Size, true) * 0.1f) * 1.4f; + Color drawColor = Color.Lerp(BorderColor, new Color(0f, 0f, 1f), Utils.GetLerpValue(120f, 135f, particle.Size, true) * 0.1f) * 1.4f; Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); } } diff --git a/Particles/ThanatosSmokeParticle.cs b/Particles/ThanatosSmokeParticle.cs index 04317d2cbc..6caf2f7f57 100644 --- a/Particles/ThanatosSmokeParticle.cs +++ b/Particles/ThanatosSmokeParticle.cs @@ -31,10 +31,10 @@ namespace CalamityMod.Particles RelativeOffset -= (BaseMoveRotation + Main.rand.NextFloat(-0.18f, 0.18f)).ToRotationVector2() * RelativePower * 4.5f; Color = Color.DarkRed; - Color = Color.Lerp(Color, new Color(154, 139, 138), (float)Math.Pow(Utils.InverseLerp(0f, 0.57f, LifetimeCompletion, true), 2D) * 0.5f + 0.5f); + Color = Color.Lerp(Color, new Color(154, 139, 138), (float)Math.Pow(Utils.GetLerpValue(0f, 0.57f, LifetimeCompletion, true), 2D) * 0.5f + 0.5f); Color.A = 92; - float opacity = Utils.InverseLerp(1f, 0.85f, LifetimeCompletion, true); + float opacity = Utils.GetLerpValue(1f, 0.85f, LifetimeCompletion, true); Color *= opacity; } diff --git a/Projectiles/BaseProjectiles/BaseMassiveExplosionProjectile.cs b/Projectiles/BaseProjectiles/BaseMassiveExplosionProjectile.cs index 375570ed43..361323f01e 100644 --- a/Projectiles/BaseProjectiles/BaseMassiveExplosionProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseMassiveExplosionProjectile.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; @@ -25,14 +25,14 @@ namespace CalamityMod.Projectiles.BaseProjectiles { if (UsesScreenshake) { - float screenShakePower = GetScreenshakePower(Projectile.timeLeft / (float)Lifetime) * Utils.InverseLerp(1300f, 0f, Projectile.Distance(Main.LocalPlayer.Center), true); + float screenShakePower = GetScreenshakePower(Projectile.timeLeft / (float)Lifetime) * Utils.GetLerpValue(1300f, 0f, Projectile.Distance(Main.LocalPlayer.Center), true); if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < screenShakePower) Main.LocalPlayer.Calamity().GeneralScreenShakePower = screenShakePower; } // Expand outward. CurrentRadius = MathHelper.Lerp(CurrentRadius, MaxRadius, 0.25f); - Projectile.scale = MathHelper.Lerp(1.2f, 5f, Utils.InverseLerp(Lifetime, 0f, Projectile.timeLeft, true)); + Projectile.scale = MathHelper.Lerp(1.2f, 5f, Utils.GetLerpValue(Lifetime, 0f, Projectile.timeLeft, true)); // Adjust the hitbox. CalamityGlobalProjectile.ExpandHitboxBy(Projectile, (int)(CurrentRadius * Projectile.scale), (int)(CurrentRadius * Projectile.scale)); @@ -43,7 +43,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles Main.spriteBatch.End(); Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix); - float pulseCompletionRatio = Utils.InverseLerp(Lifetime, 0f, Projectile.timeLeft, true); + float pulseCompletionRatio = Utils.GetLerpValue(Lifetime, 0f, Projectile.timeLeft, true); Vector2 scale = new Vector2(1.5f, 1f); Vector2 drawPosition = Projectile.Center - Main.screenPosition + Projectile.Size * scale * 0.5f; Rectangle drawArea = new Rectangle(0, 0, Projectile.width, Projectile.height); diff --git a/Projectiles/Boss/ApolloChargeTelegraph.cs b/Projectiles/Boss/ApolloChargeTelegraph.cs index ee3ab23c90..9b39327dc7 100644 --- a/Projectiles/Boss/ApolloChargeTelegraph.cs +++ b/Projectiles/Boss/ApolloChargeTelegraph.cs @@ -1,4 +1,4 @@ -using CalamityMod.Events; +using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -82,7 +82,7 @@ namespace CalamityMod.Projectiles.Boss // Determine opacity float telegraphTotalTime = malice ? 30f : death ? 40f : revenge ? 45f : expertMode ? 50f : 60f; - Projectile.Opacity = Utils.InverseLerp(0f, 6f, Projectile.timeLeft, true) * Utils.InverseLerp(telegraphTotalTime, telegraphTotalTime - 6f, Projectile.timeLeft, true); + Projectile.Opacity = Utils.GetLerpValue(0f, 6f, Projectile.timeLeft, true) * Utils.GetLerpValue(telegraphTotalTime, telegraphTotalTime - 6f, Projectile.timeLeft, true); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Boss/AresTeslaOrb.cs b/Projectiles/Boss/AresTeslaOrb.cs index 2d15d8751f..f30d0e83e1 100644 --- a/Projectiles/Boss/AresTeslaOrb.cs +++ b/Projectiles/Boss/AresTeslaOrb.cs @@ -1,4 +1,4 @@ -using CalamityMod.Events; +using CalamityMod.Events; using CalamityMod.NPCs; using CalamityMod.NPCs.ExoMechs.Ares; using CalamityMod.World; @@ -185,7 +185,7 @@ namespace CalamityMod.Projectiles.Boss float completionRatio = i / (float)points.Count; // Noise offsets should taper off at the ends of the line. - float offsetMuffleFactor = Utils.InverseLerp(0.12f, 0.25f, completionRatio, true) * Utils.InverseLerp(0.88f, 0.75f, completionRatio, true); + float offsetMuffleFactor = Utils.GetLerpValue(0.12f, 0.25f, completionRatio, true) * Utils.GetLerpValue(0.88f, 0.75f, completionRatio, true); // Give a sense of time for the noise on the vertical axis. This is achieved via a 0-1 constricted sinusoid. float noiseY = (float)Math.Cos(completionRatio * 17.2f + Main.GlobalTimeWrappedHourly * 10.7f) * 0.5f + 0.5f; diff --git a/Projectiles/Boss/ArtemisChargeTelegraph.cs b/Projectiles/Boss/ArtemisChargeTelegraph.cs index ff46ecb59c..29c3f2be37 100644 --- a/Projectiles/Boss/ArtemisChargeTelegraph.cs +++ b/Projectiles/Boss/ArtemisChargeTelegraph.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System.IO; using Terraria; @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.Center = ThingToAttachTo.Center + Projectile.velocity * 50f; // Determine opacity - Projectile.Opacity = Utils.InverseLerp(0f, 8f, Projectile.timeLeft, true); + Projectile.Opacity = Utils.GetLerpValue(0f, 8f, Projectile.timeLeft, true); } public override Color? GetAlpha(Color lightColor) @@ -75,14 +75,14 @@ namespace CalamityMod.Projectiles.Boss public Color TelegraphPrimitiveColor(float completionRatio) { float colorInterpolant = (completionRatio * 1.2f + Main.GlobalTimeWrappedHourly * 0.26f) % 1f; - float opacity = MathHelper.Lerp(0.2f, 0.425f, Projectile.Opacity) * Utils.InverseLerp(30f, 24f, Projectile.timeLeft, true); + float opacity = MathHelper.Lerp(0.2f, 0.425f, Projectile.Opacity) * Utils.GetLerpValue(30f, 24f, Projectile.timeLeft, true); return CalamityUtils.MulticolorLerp(colorInterpolant, Color.Orange, Color.Red, Color.Crimson, Color.Red) * opacity; } public float TelegraphPrimitiveWidth(float completionRatio) { // Used to determine the degree to which the ends of the telegraph should smoothen away. - float endSmoothenFactor = Utils.InverseLerp(1f, 0.995f, completionRatio, true); + float endSmoothenFactor = Utils.GetLerpValue(1f, 0.995f, completionRatio, true); return endSmoothenFactor * Projectile.Opacity * 22f; } diff --git a/Projectiles/Boss/DoGP1EndPortal.cs b/Projectiles/Boss/DoGP1EndPortal.cs index 35abbdeedb..365ea9e119 100644 --- a/Projectiles/Boss/DoGP1EndPortal.cs +++ b/Projectiles/Boss/DoGP1EndPortal.cs @@ -1,4 +1,4 @@ -using CalamityMod.World; +using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System.Collections.Generic; @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Boss TimeCountdown--; } else - Projectile.scale = Utils.InverseLerp(60000f, 59945f, Projectile.timeLeft, true) * Utils.InverseLerp(60f, 115f, CalamityWorld.DoGSecondStageCountdown, true); + Projectile.scale = Utils.GetLerpValue(60000f, 59945f, Projectile.timeLeft, true) * Utils.GetLerpValue(60f, 115f, CalamityWorld.DoGSecondStageCountdown, true); if ((CalamityWorld.DoGSecondStageCountdown < 60f && TimeCountdown == 0f) || NPCs.CalamityGlobalNPC.DoGHead == -1 || TimeCountdown == 1f) Projectile.Kill(); diff --git a/Projectiles/Boss/DoGTeleportRift.cs b/Projectiles/Boss/DoGTeleportRift.cs index e1b8c2a5cf..7a9edae351 100644 --- a/Projectiles/Boss/DoGTeleportRift.cs +++ b/Projectiles/Boss/DoGTeleportRift.cs @@ -1,4 +1,4 @@ -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { - float lerpMult = Utils.InverseLerp(15f, 30f, Projectile.timeLeft, clamped: true) * Utils.InverseLerp(240f, 200f, Projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f / 0.5f * (MathHelper.Pi * 2f) * 3f)) * 0.8f; + float lerpMult = Utils.GetLerpValue(15f, 30f, Projectile.timeLeft, clamped: true) * Utils.GetLerpValue(240f, 200f, Projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f / 0.5f * (MathHelper.Pi * 2f) * 3f)) * 0.8f; Texture2D texture = ModContent.Request(Texture).Value; Vector2 drawPos = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); diff --git a/Projectiles/Boss/DraedonSummonLaser.cs b/Projectiles/Boss/DraedonSummonLaser.cs index 6f287d6c21..add4e4c0f0 100644 --- a/Projectiles/Boss/DraedonSummonLaser.cs +++ b/Projectiles/Boss/DraedonSummonLaser.cs @@ -60,12 +60,12 @@ namespace CalamityMod.Projectiles.Boss } Lighting.AddLight(Projectile.Center, Color.White.ToVector3()); - Projectile.scale = Utils.InverseLerp(-1f, 15f, Projectile.timeLeft, true) * Utils.InverseLerp(Lifetime + 1f, Lifetime - 15f, Projectile.timeLeft, true); + Projectile.scale = Utils.GetLerpValue(-1f, 15f, Projectile.timeLeft, true) * Utils.GetLerpValue(Lifetime + 1f, Lifetime - 15f, Projectile.timeLeft, true); } private float PrimitiveWidthFunction(float completionRatio) { - return Utils.InverseLerp(1f, 0.96f, completionRatio, true) * Utils.InverseLerp(0f, 0.016f, completionRatio, true) * Projectile.scale * 20f; + return Utils.GetLerpValue(1f, 0.96f, completionRatio, true) * Utils.GetLerpValue(0f, 0.016f, completionRatio, true) * Projectile.scale * 20f; } private Color PrimitiveColorFunction(float completionRatio) diff --git a/Projectiles/Boss/DyingSun.cs b/Projectiles/Boss/DyingSun.cs index cd46d88b08..19f1fd5273 100644 --- a/Projectiles/Boss/DyingSun.cs +++ b/Projectiles/Boss/DyingSun.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Boss { Projectile.scale += 0.08f; Radius = Projectile.scale * 42f; - Projectile.Opacity = Utils.InverseLerp(8f, 42f, Projectile.timeLeft, true); + Projectile.Opacity = Utils.GetLerpValue(8f, 42f, Projectile.timeLeft, true); Time++; } diff --git a/Projectiles/Boss/HolyAura.cs b/Projectiles/Boss/HolyAura.cs index d82aaabcf7..8d00b4c876 100644 --- a/Projectiles/Boss/HolyAura.cs +++ b/Projectiles/Boss/HolyAura.cs @@ -39,9 +39,9 @@ namespace CalamityMod.Projectiles.Boss float[] hue = new float[drawnAmt]; float[] size = new float[drawnAmt]; int totalTime = 210; - float colorChangeAmt = Utils.InverseLerp(0f, 60f, Projectile.timeLeft, true) * Utils.InverseLerp(totalTime, totalTime - 60, Projectile.timeLeft, true); - float colorChangeAmt2 = Utils.InverseLerp(0f, 60f, Projectile.timeLeft, true) * Utils.InverseLerp(totalTime, 90f, Projectile.timeLeft, true); - colorChangeAmt2 = Utils.InverseLerp(0.2f, 0.5f, colorChangeAmt2, true); + float colorChangeAmt = Utils.GetLerpValue(0f, 60f, Projectile.timeLeft, true) * Utils.GetLerpValue(totalTime, totalTime - 60, Projectile.timeLeft, true); + float colorChangeAmt2 = Utils.GetLerpValue(0f, 60f, Projectile.timeLeft, true) * Utils.GetLerpValue(totalTime, 90f, Projectile.timeLeft, true); + colorChangeAmt2 = Utils.GetLerpValue(0.2f, 0.5f, colorChangeAmt2, true); float sizeScale = 0.8f; float sizeScalar = (1f - sizeScale) / drawnAmt; float yPosOffset = 60f; diff --git a/Projectiles/Boss/HolyBurnOrb.cs b/Projectiles/Boss/HolyBurnOrb.cs index e676b5b394..f7033f555a 100644 --- a/Projectiles/Boss/HolyBurnOrb.cs +++ b/Projectiles/Boss/HolyBurnOrb.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; using CalamityMod.Dusts; using CalamityMod.World; @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { - float lerpMult = Utils.InverseLerp(15f, 30f, Projectile.timeLeft, clamped: true) * Utils.InverseLerp(240f, 200f, Projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f / 0.5f * (MathHelper.Pi * 2f) * 3f)) * 0.8f; + float lerpMult = Utils.GetLerpValue(15f, 30f, Projectile.timeLeft, clamped: true) * Utils.GetLerpValue(240f, 200f, Projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f / 0.5f * (MathHelper.Pi * 2f) * 3f)) * 0.8f; Texture2D texture = ModContent.Request(Texture).Value; Vector2 drawPos = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); diff --git a/Projectiles/Boss/HolyLight.cs b/Projectiles/Boss/HolyLight.cs index 31b23e7c89..1c38d16473 100644 --- a/Projectiles/Boss/HolyLight.cs +++ b/Projectiles/Boss/HolyLight.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; @@ -70,14 +70,14 @@ namespace CalamityMod.Projectiles.Boss Color color34 = color33; Vector2 origin5 = value.Size() / 2f; Color color35 = color33 * 0.5f; - float num162 = Utils.InverseLerp(15f, 30f, Projectile.timeLeft, clamped: true) * Utils.InverseLerp(240f, 200f, Projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f / 0.5f * ((float)Math.PI * 2f) * 3f)) * 0.8f; + float num162 = Utils.GetLerpValue(15f, 30f, Projectile.timeLeft, clamped: true) * Utils.GetLerpValue(240f, 200f, Projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f / 0.5f * ((float)Math.PI * 2f) * 3f)) * 0.8f; Vector2 vector29 = new Vector2(0.5f, 1f) * num162; Vector2 vector30 = new Vector2(0.5f, 1f) * num162; color34 *= num162; color35 *= num162; int num163 = 0; - Vector2 position3 = vector28 + Projectile.velocity.SafeNormalize(Vector2.Zero) * Utils.InverseLerp(0.5f, 1f, Projectile.localAI[0] / 60f, clamped: true) * num163; + Vector2 position3 = vector28 + Projectile.velocity.SafeNormalize(Vector2.Zero) * Utils.GetLerpValue(0.5f, 1f, Projectile.localAI[0] / 60f, clamped: true) * num163; SpriteEffects spriteEffects = SpriteEffects.None; if (Projectile.spriteDirection == -1) diff --git a/Projectiles/Boss/HolySpear.cs b/Projectiles/Boss/HolySpear.cs index 71ff34f200..99b3814448 100644 --- a/Projectiles/Boss/HolySpear.cs +++ b/Projectiles/Boss/HolySpear.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -139,7 +139,7 @@ namespace CalamityMod.Projectiles.Boss Color color34 = color33; Vector2 origin5 = value.Size() / 2f; Color color35 = color33 * 0.5f; - float num162 = Utils.InverseLerp(15f, 30f, Projectile.timeLeft, clamped: true) * Utils.InverseLerp(240f, 200f, Projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f / 0.5f * ((float)Math.PI * 2f) * 3f)) * 0.8f; + float num162 = Utils.GetLerpValue(15f, 30f, Projectile.timeLeft, clamped: true) * Utils.GetLerpValue(240f, 200f, Projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f / 0.5f * ((float)Math.PI * 2f) * 3f)) * 0.8f; Vector2 vector29 = new Vector2(1f, 1.5f) * num162; Vector2 vector30 = new Vector2(0.5f, 1f) * num162; color34 *= num162; diff --git a/Projectiles/Boss/LeviathanSpawner.cs b/Projectiles/Boss/LeviathanSpawner.cs index d0aeed33ea..b44a6d2eff 100644 --- a/Projectiles/Boss/LeviathanSpawner.cs +++ b/Projectiles/Boss/LeviathanSpawner.cs @@ -34,8 +34,8 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.Opacity > 1f) Projectile.Opacity = 1f; - Main.LocalPlayer.Calamity().GeneralScreenShakePower = (float)Math.Pow(Utils.InverseLerp(180f, 290f, Time, true), 0.3D) * 6f; - Main.LocalPlayer.Calamity().GeneralScreenShakePower += CalamityUtils.Convert01To010((float)Math.Pow(Utils.InverseLerp(300f, 440f, Time, true), 0.5D)) * 10f; + Main.LocalPlayer.Calamity().GeneralScreenShakePower = (float)Math.Pow(Utils.GetLerpValue(180f, 290f, Time, true), 0.3D) * 6f; + Main.LocalPlayer.Calamity().GeneralScreenShakePower += CalamityUtils.Convert01To010((float)Math.Pow(Utils.GetLerpValue(300f, 440f, Time, true), 0.5D)) * 10f; if (Projectile.timeLeft == 45) { diff --git a/Projectiles/Boss/MajesticSparkle.cs b/Projectiles/Boss/MajesticSparkle.cs index 4584ac3058..df4c9cf9c6 100644 --- a/Projectiles/Boss/MajesticSparkle.cs +++ b/Projectiles/Boss/MajesticSparkle.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; @@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Boss // Go 33% across the color spectrum throughout the sparkle's lifetime instead of using a static color. ColorSpectrumHue = (ColorSpectrumHue + 0.333f / Lifetime) % 0.999f; - Projectile.Opacity = Utils.InverseLerp(0f, FadeinTime, Time, true) * Utils.InverseLerp(Lifetime, Lifetime - FadeoutTime, Time, true); + Projectile.Opacity = Utils.GetLerpValue(0f, FadeinTime, Time, true) * Utils.GetLerpValue(Lifetime, Lifetime - FadeoutTime, Time, true); Projectile.velocity = Projectile.velocity.RotatedBy(Math.Sin(Time / 30f) * 0.0125f); Time++; @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Boss Color sparkleColor = Main.hslToRgb(ColorSpectrumHue, 1f, 0.5f) * Projectile.Opacity * 0.5f; sparkleColor.A = 0; - sparkleColor *= MathHelper.Lerp(1f, 1.5f, Utils.InverseLerp(Lifetime * 0.5f - 15f, Lifetime * 0.5f + 15f, Time, true)); + sparkleColor *= MathHelper.Lerp(1f, 1.5f, Utils.GetLerpValue(Lifetime * 0.5f - 15f, Lifetime * 0.5f + 15f, Time, true)); Color orthogonalSparkleColor = Color.Lerp(sparkleColor, Color.White, 0.5f) * 0.5f; diff --git a/Projectiles/Boss/SCalRitualDrama.cs b/Projectiles/Boss/SCalRitualDrama.cs index 1d492b4c0f..a7377498fd 100644 --- a/Projectiles/Boss/SCalRitualDrama.cs +++ b/Projectiles/Boss/SCalRitualDrama.cs @@ -31,9 +31,9 @@ namespace CalamityMod.Projectiles.Boss // If SCal is already present, this does not happen. if (!NPC.AnyNPCs(ModContent.NPCType())) { - SCalSky.OverridingIntensity = Utils.InverseLerp(90f, TotalRitualTime - 25f, Time, true); - Main.LocalPlayer.Calamity().GeneralScreenShakePower = Utils.InverseLerp(90f, TotalRitualTime - 25f, Time, true); - Main.LocalPlayer.Calamity().GeneralScreenShakePower *= Utils.InverseLerp(3400f, 1560f, Main.LocalPlayer.Distance(Projectile.Center), true) * 4f; + SCalSky.OverridingIntensity = Utils.GetLerpValue(90f, TotalRitualTime - 25f, Time, true); + Main.LocalPlayer.Calamity().GeneralScreenShakePower = Utils.GetLerpValue(90f, TotalRitualTime - 25f, Time, true); + Main.LocalPlayer.Calamity().GeneralScreenShakePower *= Utils.GetLerpValue(3400f, 1560f, Main.LocalPlayer.Distance(Projectile.Center), true) * 4f; } // Summon SCal right before the ritual effect ends. @@ -76,7 +76,7 @@ namespace CalamityMod.Projectiles.Boss SoundEngine.PlaySound(SoundLoader.GetLegacySoundSlot(Mod, "Sounds/Custom/SupremeCalamitasSpawn"), Projectile.Center); // Make a sudden screen shake. - Main.LocalPlayer.Calamity().GeneralScreenShakePower = Utils.InverseLerp(3400f, 1560f, Main.LocalPlayer.Distance(Projectile.Center), true) * 16f; + Main.LocalPlayer.Calamity().GeneralScreenShakePower = Utils.GetLerpValue(3400f, 1560f, Main.LocalPlayer.Distance(Projectile.Center), true) * 16f; // Generate a dust explosion at the ritual's position. float burstDirectionVariance = 3; diff --git a/Projectiles/Boss/SupremeCataclysmFist.cs b/Projectiles/Boss/SupremeCataclysmFist.cs index d844b8a535..238d504d34 100644 --- a/Projectiles/Boss/SupremeCataclysmFist.cs +++ b/Projectiles/Boss/SupremeCataclysmFist.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.frame = Projectile.frameCounter / 5 % Main.projFrames[Projectile.type]; // Fade in and handle visuals. - Projectile.Opacity = Utils.InverseLerp(0f, 12f, Projectile.timeLeft, true) * Utils.InverseLerp(1200f, 1188f, Projectile.timeLeft, true); + Projectile.Opacity = Utils.GetLerpValue(0f, 12f, Projectile.timeLeft, true) * Utils.GetLerpValue(1200f, 1188f, Projectile.timeLeft, true); Projectile.spriteDirection = (Projectile.velocity.X > 0f).ToDirectionInt(); Time++; diff --git a/Projectiles/Boss/SupremeCatastropheSlash.cs b/Projectiles/Boss/SupremeCatastropheSlash.cs index 9bd7967a85..03939accf4 100644 --- a/Projectiles/Boss/SupremeCatastropheSlash.cs +++ b/Projectiles/Boss/SupremeCatastropheSlash.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.frame = Projectile.frameCounter / 7 % Main.projFrames[Projectile.type]; // Fade in and handle visuals. - Projectile.Opacity = Utils.InverseLerp(0f, 8f, Projectile.timeLeft, true) * Utils.InverseLerp(1500f, 1492f, Projectile.timeLeft, true); + Projectile.Opacity = Utils.GetLerpValue(0f, 8f, Projectile.timeLeft, true) * Utils.GetLerpValue(1500f, 1492f, Projectile.timeLeft, true); Projectile.spriteDirection = (Projectile.velocity.X > 0f).ToDirectionInt(); Time++; diff --git a/Projectiles/Boss/ThanatosBeamTelegraph.cs b/Projectiles/Boss/ThanatosBeamTelegraph.cs index 1403740d63..6f10b4302d 100644 --- a/Projectiles/Boss/ThanatosBeamTelegraph.cs +++ b/Projectiles/Boss/ThanatosBeamTelegraph.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System.IO; using Terraria; @@ -11,7 +11,7 @@ namespace CalamityMod.Projectiles.Boss public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public NPC ThingToAttachTo => Main.npc.IndexInRange((int)Projectile.ai[0]) ? Main.npc[(int)Projectile.ai[0]] : null; - public float ConvergenceRatio => MathHelper.SmoothStep(0f, 1f, Utils.InverseLerp(25f, 120f, Time, true)); + public float ConvergenceRatio => MathHelper.SmoothStep(0f, 1f, Utils.GetLerpValue(25f, 120f, Time, true)); public ref float StartingRotationalOffset => ref Projectile.ai[1]; public ref float ConvergenceAngle => ref Projectile.localAI[0]; public ref float Time => ref Projectile.localAI[1]; @@ -73,14 +73,14 @@ namespace CalamityMod.Projectiles.Boss { Texture2D laserTelegraph = ModContent.Request("CalamityMod/ExtraTextures/LaserWallTelegraphBeam"); - float verticalScale = Utils.InverseLerp(0f, 20f, Time, true) * Utils.InverseLerp(0f, 16f, Projectile.timeLeft, true) * 4f; + float verticalScale = Utils.GetLerpValue(0f, 20f, Time, true) * Utils.GetLerpValue(0f, 16f, Projectile.timeLeft, true) * 4f; Vector2 origin = laserTelegraph.Size() * new Vector2(0f, 0.5f); Vector2 scaleInner = new Vector2(TelegraphWidth / laserTelegraph.Width, verticalScale); Vector2 scaleOuter = scaleInner * new Vector2(1f, 2.2f); Color colorOuter = Color.Lerp(Color.Red, Color.Crimson, Time / Lifetime * 2f % 1f); // Iterate through crimson and red twice and then flash. - colorOuter = Color.Lerp(colorOuter, Color.White, Utils.InverseLerp(40f, 0f, Projectile.timeLeft, true) * 0.8f); + colorOuter = Color.Lerp(colorOuter, Color.White, Utils.GetLerpValue(40f, 0f, Projectile.timeLeft, true) * 0.8f); Color colorInner = Color.Lerp(colorOuter, Color.White, 0.5f); colorInner *= 0.85f; diff --git a/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs b/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs index 0942f7c609..d25ea913fe 100644 --- a/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs +++ b/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal if (potentialTarget != null) { float oldSpeed = Projectile.velocity.Length(); - float inertia = MathHelper.Lerp(15f, 4f, Utils.InverseLerp(Lifetime, Lifetime - 60f, Projectile.timeLeft, true)); + float inertia = MathHelper.Lerp(15f, 4f, Utils.GetLerpValue(Lifetime, Lifetime - 60f, Projectile.timeLeft, true)); Projectile.velocity = (Projectile.velocity * inertia + Projectile.SafeDirectionTo(potentialTarget.Center, -Vector2.UnitY) * oldSpeed) / (inertia + 1f); Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * oldSpeed; } diff --git a/Projectiles/DraedonsArsenal/GalvanizingGlaiveProjectile.cs b/Projectiles/DraedonsArsenal/GalvanizingGlaiveProjectile.cs index 3473902a7a..46df1facf2 100644 --- a/Projectiles/DraedonsArsenal/GalvanizingGlaiveProjectile.cs +++ b/Projectiles/DraedonsArsenal/GalvanizingGlaiveProjectile.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; @@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { Player player = Main.player[Projectile.owner]; float animationRatio = player.itemAnimation / (float)player.itemAnimationMax; - DelegateMethods.f_1 = Utils.InverseLerp(0f, 0.4f, animationRatio, true) * Utils.InverseLerp(1f, 0.6f, animationRatio, true); + DelegateMethods.f_1 = Utils.GetLerpValue(0f, 0.4f, animationRatio, true) * Utils.GetLerpValue(1f, 0.6f, animationRatio, true); DelegateMethods.c_1 = Color.White; List oldPositions = new List() { diff --git a/Projectiles/DraedonsArsenal/GaussPistolShot.cs b/Projectiles/DraedonsArsenal/GaussPistolShot.cs index 1529d9fe89..da37b78e32 100644 --- a/Projectiles/DraedonsArsenal/GaussPistolShot.cs +++ b/Projectiles/DraedonsArsenal/GaussPistolShot.cs @@ -66,8 +66,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Projectile.netUpdate = true; } - float energyRadius = MathHelper.Lerp(MaxChargeRadius * 0.333f, MaxChargeRadius, Utils.InverseLerp(0f, ChargeTime, Time, true)); - float energySphereSpeedMax = MathHelper.Lerp(MaxEnergyParticleSpeed, MinEnergyParticleSpeed, Utils.InverseLerp(0f, ChargeTime, Time, true)); + float energyRadius = MathHelper.Lerp(MaxChargeRadius * 0.333f, MaxChargeRadius, Utils.GetLerpValue(0f, ChargeTime, Time, true)); + float energySphereSpeedMax = MathHelper.Lerp(MaxEnergyParticleSpeed, MinEnergyParticleSpeed, Utils.GetLerpValue(0f, ChargeTime, Time, true)); // Charge up dust. if (Projectile.velocity.Length() == 0f && !Main.dedServ) diff --git a/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs b/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs index 09b8e1b208..af7b566fac 100644 --- a/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs +++ b/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs @@ -130,7 +130,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { // The distance ratio ranges from 0 (your mouse is directly on the player) to 1 (your mouse is at the max range considered, or any further distance). float mouseDistance = Projectile.Distance(Main.MouseWorld); - float distRatio = Utils.InverseLerp(0f, MaximumMouseRange, mouseDistance, true); + float distRatio = Utils.GetLerpValue(0f, MaximumMouseRange, mouseDistance, true); // This formula ensures that the sword has a sudden and extremely harsh responsiveness penalty when the mouse is close to the player. // Otherwise it controls perfectly fine. @@ -225,9 +225,9 @@ namespace CalamityMod.Projectiles.DraedonsArsenal // Idle lightning frames. if (adjustFrameCounter >= 50 && adjustFrameCounter <= 78) - Projectile.frame = (int)MathHelper.Lerp(1, 9, Utils.InverseLerp(50, 75, adjustFrameCounter, true)); + Projectile.frame = (int)MathHelper.Lerp(1, 9, Utils.GetLerpValue(50, 75, adjustFrameCounter, true)); if (adjustFrameCounter >= 90 && adjustFrameCounter <= 120) - Projectile.frame = (int)MathHelper.Lerp(10, 18, Utils.InverseLerp(90, 117, adjustFrameCounter, true)); + Projectile.frame = (int)MathHelper.Lerp(10, 18, Utils.GetLerpValue(90, 117, adjustFrameCounter, true)); // Fadeout frames. if (FadeoutTime > 5) @@ -274,9 +274,9 @@ namespace CalamityMod.Projectiles.DraedonsArsenal float averageRotation = Projectile.oldRot.Take(20).Average(angle => MathHelper.WrapAngle(angle) + MathHelper.Pi); float deltaAngle = Math.Abs(averageRotation - (MathHelper.WrapAngle(Projectile.rotation) + MathHelper.Pi)); float opacity = Projectile.Opacity; - opacity *= Utils.InverseLerp(StandardSwingSpeed * 0.7f, StandardSwingSpeed, AngularDamageFactor, true); - opacity *= (float)Math.Pow(Utils.InverseLerp(1f, 0.45f, completionRatio, true), 4D); - opacity *= (float)Math.Pow(Utils.InverseLerp(0.9f, 1.1f, deltaAngle, true), 2D); + opacity *= Utils.GetLerpValue(StandardSwingSpeed * 0.7f, StandardSwingSpeed, AngularDamageFactor, true); + opacity *= (float)Math.Pow(Utils.GetLerpValue(1f, 0.45f, completionRatio, true), 4D); + opacity *= (float)Math.Pow(Utils.GetLerpValue(0.9f, 1.1f, deltaAngle, true), 2D); float rotationAdjusted = MathHelper.WrapAngle(Projectile.rotation) + MathHelper.Pi; float oldRotationAdjusted = MathHelper.WrapAngle(Projectile.oldRot[1]) + MathHelper.Pi; diff --git a/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs b/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs index 970a598c1f..cf9fe8c9ab 100644 --- a/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs +++ b/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs @@ -1,4 +1,4 @@ -using CalamityMod.DataStructures; +using CalamityMod.DataStructures; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -76,7 +76,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal if (Projectile.timeLeft >= Lifetime - ChargeTime) { - float time = Utils.InverseLerp(Lifetime, Lifetime - ChargeTime, Projectile.timeLeft, true); + float time = Utils.GetLerpValue(Lifetime, Lifetime - ChargeTime, Projectile.timeLeft, true); float offsetAngle = MathHelper.Lerp(-1.1f, 1.5f, time); // Set the range of the offset to -1.8 and 1.8 based off of the time. offsetAngle *= Projectile.localAI[0]; // Incorporate direction into the offset angle. @@ -154,7 +154,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { Vector2 offset = Vector2.UnitX * -SwingDirection; offset *= Outwardness * (float)Math.Sin(i / 20f * MathHelper.Pi); - offset *= Utils.InverseLerp(0f, 300f, Owner.Distance(Vector2.Lerp(mountedCenter, Projectile.Center, i / 20f) + offset), true); + offset *= Utils.GetLerpValue(0f, 300f, Owner.Distance(Vector2.Lerp(mountedCenter, Projectile.Center, i / 20f) + offset), true); bezierPoints.Add(Vector2.Lerp(mountedCenter, Projectile.Center, i / 20f) + offset); } bezierPoints.Add(Projectile.Center); diff --git a/Projectiles/DraedonsArsenal/PulsePistolShot.cs b/Projectiles/DraedonsArsenal/PulsePistolShot.cs index 60d897fa51..811daa5d7f 100644 --- a/Projectiles/DraedonsArsenal/PulsePistolShot.cs +++ b/Projectiles/DraedonsArsenal/PulsePistolShot.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal angleOffset = MathHelper.Clamp(angleOffset, -0.2f, 0.2f); Projectile.velocity = Projectile.velocity.RotatedBy(angleOffset); } - float radiusFactor = MathHelper.Lerp(0f, 1f, Utils.InverseLerp(10f, 50f, Time, true)); + float radiusFactor = MathHelper.Lerp(0f, 1f, Utils.GetLerpValue(10f, 50f, Time, true)); Dust dust = Dust.NewDustPerfect(Projectile.Center, 234); dust.noGravity = true; diff --git a/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs b/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs index 127bae64b1..fa8fc6c796 100644 --- a/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs +++ b/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs @@ -169,7 +169,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { EyeRotation = Projectile.AngleTo(player.Center); EyeOutwardness = MathHelper.Lerp(EyeOutwardness, 1f, 0.15f); - Projectile.Center = Vector2.SmoothStep(OldCenter, player.Center - Vector2.UnitY * 80f, Utils.InverseLerp(0f, 35f, Time % 150f)); + Projectile.Center = Vector2.SmoothStep(OldCenter, player.Center - Vector2.UnitY * 80f, Utils.GetLerpValue(0f, 35f, Time % 150f)); } else { diff --git a/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs b/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs index 9fac07fa41..4a23849759 100644 --- a/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs +++ b/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs @@ -166,8 +166,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { if (HopCooldown <= 0f && Projectile.oldPosition.Y == Projectile.position.Y) { - float hopXMult = Utils.InverseLerp(50f, 500f, targetPosition.X - Projectile.Center.X, true); - float hopYMult = Utils.InverseLerp(40f, 300f, targetPosition.Y - Projectile.Center.Y, true); + float hopXMult = Utils.GetLerpValue(50f, 500f, targetPosition.X - Projectile.Center.X, true); + float hopYMult = Utils.GetLerpValue(40f, 300f, targetPosition.Y - Projectile.Center.Y, true); float hopSpeedX = MathHelper.Lerp(4f, 17f, hopXMult) * Math.Sign(targetPosition.X - Projectile.Center.X); float hopSpeedY = -1 * MathHelper.Lerp(8f, 23f, hopYMult); diff --git a/Projectiles/DraedonsArsenal/SystemBaneProjectile.cs b/Projectiles/DraedonsArsenal/SystemBaneProjectile.cs index e3d89667a1..4d5d72710a 100644 --- a/Projectiles/DraedonsArsenal/SystemBaneProjectile.cs +++ b/Projectiles/DraedonsArsenal/SystemBaneProjectile.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Graphics; using System; @@ -109,7 +109,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal if (!Projectile.Calamity().stealthStrike) return; int totalCirclePoints = 55; - float generalOpacity = Utils.InverseLerp(0f, 30f, Projectile.timeLeft, true) * Utils.InverseLerp(480f, 450f, Projectile.timeLeft, true); + float generalOpacity = Utils.GetLerpValue(0f, 30f, Projectile.timeLeft, true) * Utils.GetLerpValue(480f, 450f, Projectile.timeLeft, true); Texture2D lightningTexture = ModContent.Request("CalamityMod/Projectiles/LightningProj"); for (int i = 0; i < totalCirclePoints; i++) { diff --git a/Projectiles/DraedonsArsenal/TaserHook.cs b/Projectiles/DraedonsArsenal/TaserHook.cs index faf1693105..337be29e31 100644 --- a/Projectiles/DraedonsArsenal/TaserHook.cs +++ b/Projectiles/DraedonsArsenal/TaserHook.cs @@ -130,7 +130,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { for (int i = 0; i < 50; i++) { - float angle = MathHelper.TwoPi / 50f * i + Utils.InverseLerp(90f, 150f, Time, true) * MathHelper.ToRadians(1080f); + float angle = MathHelper.TwoPi / 50f * i + Utils.GetLerpValue(90f, 150f, Time, true) * MathHelper.ToRadians(1080f); Dust dust = Dust.NewDustPerfect(target.Center + angle.ToRotationVector2() * 10f, 226); dust.velocity = Vector2.Zero; if (Main.rand.NextBool(6)) diff --git a/Projectiles/DraedonsArsenal/UnstableMatter.cs b/Projectiles/DraedonsArsenal/UnstableMatter.cs index 12cc07deeb..d8e2cb67d0 100644 --- a/Projectiles/DraedonsArsenal/UnstableMatter.cs +++ b/Projectiles/DraedonsArsenal/UnstableMatter.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.ModLoader; @@ -55,10 +55,10 @@ namespace CalamityMod.Projectiles.DraedonsArsenal // The faster the projectile itself is, the slower the dust, and the longer it lasts. // This is done to give the projectile a "streak" movement the faster it is versus a expansion. int dustCount = HasCollidedWithATile ? 5 : 12; - float baseSpeedRatio = Utils.InverseLerp(6f, 14f, Projectile.velocity.Length(), true); + float baseSpeedRatio = Utils.GetLerpValue(6f, 14f, Projectile.velocity.Length(), true); float speed = MathHelper.Lerp(6f, 1.8f, (float)Math.Pow(baseSpeedRatio, 3f)); if (!HasCollidedWithATile) - speed += MathHelper.Lerp(-6f, 4f, Utils.InverseLerp(10f, 150f, Time, true)); + speed += MathHelper.Lerp(-6f, 4f, Utils.GetLerpValue(10f, 150f, Time, true)); float persistence = MathHelper.Lerp(0f, 0.8f, baseSpeedRatio); for (int i = 0; i < dustCount; i++) { diff --git a/Projectiles/DraedonsArsenal/VoltageStream.cs b/Projectiles/DraedonsArsenal/VoltageStream.cs index 229170770f..b605a37c0b 100644 --- a/Projectiles/DraedonsArsenal/VoltageStream.cs +++ b/Projectiles/DraedonsArsenal/VoltageStream.cs @@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Projectile.Center = Target.Center; if (Time < 90f) { - float completionRatio = Utils.InverseLerp(0f, 90f, Time, true); + float completionRatio = Utils.GetLerpValue(0f, 90f, Time, true); float offsetRatioOnSprite = (float)Math.Sin(completionRatio * MathHelper.ToRadians(720f)) * 0.5f + 0.5f; Vector2 dustInitialPosition = Vector2.Lerp(Target.Top, Target.Bottom, offsetRatioOnSprite); for (int i = 0; i < 4; i++) @@ -74,8 +74,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { for (int i = 0; i < 50; i++) { - float angle = MathHelper.TwoPi / 50f * i + Utils.InverseLerp(90f, 150f, Time, true) * MathHelper.ToRadians(1080f); - float radius = MathHelper.Lerp(0f, 25f, Utils.InverseLerp(90f, 150f, Time, true)); + float angle = MathHelper.TwoPi / 50f * i + Utils.GetLerpValue(90f, 150f, Time, true) * MathHelper.ToRadians(1080f); + float radius = MathHelper.Lerp(0f, 25f, Utils.GetLerpValue(90f, 150f, Time, true)); Dust dust = Dust.NewDustPerfect(Target.Center + angle.ToRotationVector2() * radius, 226); dust.velocity = Vector2.Zero; if (Main.rand.NextBool(6)) diff --git a/Projectiles/Enemy/CragmawAcidDrop.cs b/Projectiles/Enemy/CragmawAcidDrop.cs index 0b0c1e7c56..7aa55f1ccb 100644 --- a/Projectiles/Enemy/CragmawAcidDrop.cs +++ b/Projectiles/Enemy/CragmawAcidDrop.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Enemy Player target = Main.player[Player.FindClosest(Projectile.Center, 1, 1)]; if (Projectile.WithinRange(target.Center, 1200f) && Projectile.timeLeft < 210) Projectile.velocity = (Projectile.velocity * 59f + Projectile.SafeDirectionTo(target.Center) * homingSpeed) / 60f; - Projectile.Opacity = Utils.InverseLerp(0f, 25f, Projectile.timeLeft, true); + Projectile.Opacity = Utils.GetLerpValue(0f, 25f, Projectile.timeLeft, true); Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; } diff --git a/Projectiles/Enemy/MaulerAcidDrop.cs b/Projectiles/Enemy/MaulerAcidDrop.cs index 92541899f6..e117db71f4 100644 --- a/Projectiles/Enemy/MaulerAcidDrop.cs +++ b/Projectiles/Enemy/MaulerAcidDrop.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Enemy Player target = Main.player[Player.FindClosest(Projectile.Center, 1, 1)]; if (Projectile.WithinRange(target.Center, 1200f) && Projectile.timeLeft < 210) Projectile.velocity = (Projectile.velocity * 59f + Projectile.SafeDirectionTo(target.Center) * homingSpeed) / 60f; - Projectile.Opacity = Utils.InverseLerp(0f, 25f, Projectile.timeLeft, true); + Projectile.Opacity = Utils.GetLerpValue(0f, 25f, Projectile.timeLeft, true); Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; } diff --git a/Projectiles/Magic/AetherfluxCannonHoldout.cs b/Projectiles/Magic/AetherfluxCannonHoldout.cs index 7dc46aab6d..d413ebfeae 100644 --- a/Projectiles/Magic/AetherfluxCannonHoldout.cs +++ b/Projectiles/Magic/AetherfluxCannonHoldout.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Magic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -133,7 +133,7 @@ namespace CalamityMod.Projectiles.Magic { if (Main.myPlayer == Projectile.owner) { - float interpolant = Utils.InverseLerp(5f, 25f, Projectile.Distance(Main.MouseWorld), true); + float interpolant = Utils.GetLerpValue(5f, 25f, Projectile.Distance(Main.MouseWorld), true); Vector2 oldVelocity = Projectile.velocity; Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), interpolant); if (Projectile.velocity != oldVelocity) diff --git a/Projectiles/Magic/ApotheosisEnergy.cs b/Projectiles/Magic/ApotheosisEnergy.cs index 0c369ac8f2..1d51d5be25 100644 --- a/Projectiles/Magic/ApotheosisEnergy.cs +++ b/Projectiles/Magic/ApotheosisEnergy.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Magic // Fade-effects. if (Projectile.timeLeft < 40f) - Projectile.Opacity = Utils.InverseLerp(0f, 40f, Projectile.timeLeft, true); + Projectile.Opacity = Utils.GetLerpValue(0f, 40f, Projectile.timeLeft, true); else Projectile.alpha = Utils.Clamp(Projectile.alpha - 30, 0, 255); @@ -56,7 +56,7 @@ namespace CalamityMod.Projectiles.Magic baseColor = Color.Lerp(baseColor, Color.Fuchsia, (completionRatio - 0.66f) / 0.33f); else { - float whiteFade = (float)Math.Sin(Utils.InverseLerp(0.0f, 0.2f, completionRatio, true) * MathHelper.Pi + Main.GlobalTimeWrappedHourly * 3f) * 0.45f; + float whiteFade = (float)Math.Sin(Utils.GetLerpValue(0.0f, 0.2f, completionRatio, true) * MathHelper.Pi + Main.GlobalTimeWrappedHourly * 3f) * 0.45f; baseColor = Color.Lerp(baseColor, Color.White, whiteFade); } @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Magic if (completionRatio < 0.2f) width = (float)Math.Sin(completionRatio / 0.2f * MathHelper.PiOver2) * maxWidthOutwardness + 0.1f; else - width = MathHelper.Lerp(maxWidthOutwardness, 0f, Utils.InverseLerp(0.2f, 1f, completionRatio, true)); + width = MathHelper.Lerp(maxWidthOutwardness, 0f, Utils.GetLerpValue(0.2f, 1f, completionRatio, true)); return width * Projectile.Opacity; } diff --git a/Projectiles/Magic/ApotheosisWorm.cs b/Projectiles/Magic/ApotheosisWorm.cs index 9e4b4db96d..1436e7163b 100644 --- a/Projectiles/Magic/ApotheosisWorm.cs +++ b/Projectiles/Magic/ApotheosisWorm.cs @@ -160,7 +160,7 @@ namespace CalamityMod.Projectiles.Magic if (Time <= 90f) { - int visibleSegmentIndex = (int)MathHelper.Lerp(0f, Segments.Length, Utils.InverseLerp(15f, 70f, Time, true)); + int visibleSegmentIndex = (int)MathHelper.Lerp(0f, Segments.Length, Utils.GetLerpValue(15f, 70f, Time, true)); if (segmentIndex < visibleSegmentIndex) { Segments[segmentIndex].Alpha -= 17; @@ -308,7 +308,7 @@ namespace CalamityMod.Projectiles.Magic // This is extremely similar to the portal created when DoG teleports. if (Time < 60f) { - float currentFade = Utils.InverseLerp(0f, 8f, Time, true) * Utils.InverseLerp(60f, 52f, Time, true); + float currentFade = Utils.GetLerpValue(0f, 8f, Time, true) * Utils.GetLerpValue(60f, 52f, Time, true); currentFade *= (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f * MathHelper.Pi * 3f)) * 0.8f; Texture2D texture = ModContent.Request("CalamityMod/Projectiles/StarProj"); diff --git a/Projectiles/Magic/ArtAttackStar.cs b/Projectiles/Magic/ArtAttackStar.cs index 5eec707cae..34483b7dcc 100644 --- a/Projectiles/Magic/ArtAttackStar.cs +++ b/Projectiles/Magic/ArtAttackStar.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -110,7 +110,7 @@ namespace CalamityMod.Projectiles.Magic { Vector2 destination = Main.MouseWorld; float distanceFromTarget = Projectile.Distance(destination); - float moveInterpolant = Utils.InverseLerp(0f, 100f, distanceFromTarget, true) * Utils.InverseLerp(600f, 400f, distanceFromTarget, true); + float moveInterpolant = Utils.GetLerpValue(0f, 100f, distanceFromTarget, true) * Utils.GetLerpValue(600f, 400f, distanceFromTarget, true); Vector2 targetCenterOffsetVec = destination - Projectile.Center; float movementSpeed = MathHelper.Min(60f, targetCenterOffsetVec.Length()); Vector2 idealVelocity = targetCenterOffsetVec.SafeNormalize(Vector2.Zero) * movementSpeed; @@ -158,7 +158,7 @@ namespace CalamityMod.Projectiles.Magic public void DoShapeHitAreaChecks(List cleanOldPositions, int shapeEndPoint) { - float damageFactor = MathHelper.Lerp(1f, ArtAttack.MaxDamageBoostFactor, Utils.InverseLerp(0f, ArtAttack.MaxDamageBoostTime, Time, true)); + float damageFactor = MathHelper.Lerp(1f, ArtAttack.MaxDamageBoostFactor, Utils.GetLerpValue(0f, ArtAttack.MaxDamageBoostTime, Time, true)); int damage = (int)(Projectile.damage * damageFactor); for (int i = 0; i < Main.maxNPCs; i++) { @@ -231,16 +231,16 @@ namespace CalamityMod.Projectiles.Magic public Color TrailColor(float completionRatio) { float hue = (Main.GlobalTimeWrappedHourly * -0.62f + completionRatio * 1.5f) % 1f; - float brightness = MathHelper.SmoothStep(0.5f, 1f, Utils.InverseLerp(0.3f, 0f, completionRatio, true)); - float opacity = Utils.InverseLerp(1f, 0.8f, completionRatio, true) * Projectile.Opacity; + float brightness = MathHelper.SmoothStep(0.5f, 1f, Utils.GetLerpValue(0.3f, 0f, completionRatio, true)); + float opacity = Utils.GetLerpValue(1f, 0.8f, completionRatio, true) * Projectile.Opacity; Color color = Main.hslToRgb(hue, 1f, brightness) * opacity; - color.A = (byte)(int)(Utils.InverseLerp(0f, 0.2f, completionRatio) * 128); + color.A = (byte)(int)(Utils.GetLerpValue(0f, 0.2f, completionRatio) * 128); return color; } public float TrailWidth(float completionRatio) { - float widthInterpolant = Utils.InverseLerp(-0.1f, 0.25f, completionRatio, true) * Utils.InverseLerp(1.1f, 0.5f, completionRatio, true); + float widthInterpolant = Utils.GetLerpValue(-0.1f, 0.25f, completionRatio, true) * Utils.GetLerpValue(1.1f, 0.5f, completionRatio, true); return MathHelper.SmoothStep(0f, 20f, widthInterpolant); } diff --git a/Projectiles/Magic/EnormousConsumingVortex.cs b/Projectiles/Magic/EnormousConsumingVortex.cs index f875087c79..85b07d88bc 100644 --- a/Projectiles/Magic/EnormousConsumingVortex.cs +++ b/Projectiles/Magic/EnormousConsumingVortex.cs @@ -57,8 +57,8 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { Projectile.rotation += MathHelper.ToRadians(8f); // Spin 2 win. - Projectile.alpha = (int)MathHelper.Lerp(255, 0, Utils.InverseLerp(0f, 20f, Time, true)); // Fade in completely after 20 frames. - Projectile.scale = MathHelper.Lerp(StartingScale, IdealScale, Utils.InverseLerp(0f, 30f, Time, true)); // Expand completely after 30 frames. + Projectile.alpha = (int)MathHelper.Lerp(255, 0, Utils.GetLerpValue(0f, 20f, Time, true)); // Fade in completely after 20 frames. + Projectile.scale = MathHelper.Lerp(StartingScale, IdealScale, Utils.GetLerpValue(0f, 30f, Time, true)); // Expand completely after 30 frames. // Determine the ideal scale in the first frame. if (IdealScale == 0f) diff --git a/Projectiles/Magic/EternityBook.cs b/Projectiles/Magic/EternityBook.cs index d53d02f27e..e1f8152bf4 100644 --- a/Projectiles/Magic/EternityBook.cs +++ b/Projectiles/Magic/EternityBook.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Magic } // Switch frames at a linearly increasing rate to make it look like the player is flipping pages quickly. - if (Projectile.frameCounter++ >= (int)MathHelper.Lerp(10f, 1f, Utils.InverseLerp(0f, 200f, Time, true))) + if (Projectile.frameCounter++ >= (int)MathHelper.Lerp(10f, 1f, Utils.GetLerpValue(0f, 200f, Time, true))) { Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Projectile.type]; Projectile.frameCounter = 0; diff --git a/Projectiles/Magic/EternityHex.cs b/Projectiles/Magic/EternityHex.cs index 93ed72dacc..d49c6dfc65 100644 --- a/Projectiles/Magic/EternityHex.cs +++ b/Projectiles/Magic/EternityHex.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Magic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -114,7 +114,7 @@ namespace CalamityMod.Projectiles.Magic float effectRate = MathHelper.Lerp(0.4f, 1f, Time / (Lifetime * Projectile.MaxUpdates - 40)); float random = Main.rand.NextFloat(); - Projectile.Opacity = Utils.InverseLerp(Lifetime * Projectile.MaxUpdates, (Lifetime - 60f) * Projectile.MaxUpdates, Time, true); + Projectile.Opacity = Utils.GetLerpValue(Lifetime * Projectile.MaxUpdates, (Lifetime - 60f) * Projectile.MaxUpdates, Time, true); // Spawn a bunch of swirling dust and do damage. if (random <= effectRate) @@ -168,7 +168,7 @@ namespace CalamityMod.Projectiles.Magic // This value causes the lemniscate to smoothen out and look better. float scale = 2f / (3f - (float)Math.Cos(2 * LemniscateAngle)); - float outwardMultiplier = MathHelper.Lerp(4f, 220f, Utils.InverseLerp(0f, 120f, Time, true)); + float outwardMultiplier = MathHelper.Lerp(4f, 220f, Utils.GetLerpValue(0f, 120f, Time, true)); Vector2 lemniscateOffset = scale * new Vector2((float)Math.Cos(LemniscateAngle), (float)Math.Sin(2f * LemniscateAngle) / 2f); Projectile.Center = target.Center + lemniscateOffset * outwardMultiplier; @@ -222,7 +222,7 @@ namespace CalamityMod.Projectiles.Magic Color headColor = Color.Lerp(Color.Black, Color.Magenta, 0.1f); Color tailColor = Color.Lerp(Color.Magenta, Color.Cyan, completionRatio * 0.5f + leftoverTimeScale); - float opacity = (float)Math.Pow(Utils.InverseLerp(1f, 0.61f, completionRatio, true), 0.4) * Projectile.Opacity; + float opacity = (float)Math.Pow(Utils.GetLerpValue(1f, 0.61f, completionRatio, true), 0.4) * Projectile.Opacity; float fadeToMagenta = MathHelper.SmoothStep(0f, 1f, (float)Math.Pow(completionRatio, 0.6D)); return Color.Lerp(headColor, tailColor, fadeToMagenta) * opacity; @@ -230,7 +230,7 @@ namespace CalamityMod.Projectiles.Magic public float PrimitiveWidthFunction(float completionRatio) { - float widthInterpolant = Utils.InverseLerp(0f, 0.12f, completionRatio, true); + float widthInterpolant = Utils.GetLerpValue(0f, 0.12f, completionRatio, true); return MathHelper.SmoothStep(1f, 10f, widthInterpolant); } diff --git a/Projectiles/Magic/FabBolt.cs b/Projectiles/Magic/FabBolt.cs index 50e2c96f64..a334eb8df6 100644 --- a/Projectiles/Magic/FabBolt.cs +++ b/Projectiles/Magic/FabBolt.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; @@ -58,14 +58,14 @@ namespace CalamityMod.Projectiles.Magic internal Color ColorFunction(float completionRatio) { float fadeToEnd = MathHelper.Lerp(0.25f, 0.5f, (float)Math.Cos(-Main.GlobalTimeWrappedHourly * 3f) * 0.5f + 0.5f); - fadeToEnd *= 1f - Utils.InverseLerp(0.35f, 0f, completionRatio, true); + fadeToEnd *= 1f - Utils.GetLerpValue(0.35f, 0f, completionRatio, true); Color endColor = Color.Lerp(Color.Cyan, Color.HotPink, Projectile.identity % 2); return Color.Lerp(Color.White, endColor, fadeToEnd) * Projectile.Opacity * 0.7f; } internal float WidthFunction(float completionRatio) { - float expansionCompletion = 1f - (float)Math.Pow(1f - Utils.InverseLerp(0f, 0.2f, completionRatio, true), 2D); + float expansionCompletion = 1f - (float)Math.Pow(1f - Utils.GetLerpValue(0f, 0.2f, completionRatio, true), 2D); return MathHelper.Lerp(0f, 22f, expansionCompletion) * Projectile.Opacity; } diff --git a/Projectiles/Magic/FabRay.cs b/Projectiles/Magic/FabRay.cs index 82d4b6e98c..4f4e686879 100644 --- a/Projectiles/Magic/FabRay.cs +++ b/Projectiles/Magic/FabRay.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Magic { Lighting.AddLight(Projectile.Center, 0.2f, 0.01f, 0.1f); Projectile.ai[0] += 1f; - Projectile.Opacity = Utils.InverseLerp(0f, 10f * Projectile.MaxUpdates, Projectile.timeLeft, true); + Projectile.Opacity = Utils.GetLerpValue(0f, 10f * Projectile.MaxUpdates, Projectile.timeLeft, true); int shootRate = Projectile.npcProj ? 40 : 12; if (Projectile.owner == Main.myPlayer && Projectile.ai[0] % shootRate == 0f) @@ -68,14 +68,14 @@ namespace CalamityMod.Projectiles.Magic internal Color ColorFunction(float completionRatio) { float fadeToEnd = MathHelper.Lerp(0.65f, 1f, (float)Math.Cos(-Main.GlobalTimeWrappedHourly * 3f) * 0.5f + 0.5f); - float fadeOpacity = Utils.InverseLerp(1f, 0.64f, completionRatio, true) * Projectile.Opacity; + float fadeOpacity = Utils.GetLerpValue(1f, 0.64f, completionRatio, true) * Projectile.Opacity; Color endColor = Color.Lerp(Color.Cyan, Color.HotPink, (float)Math.Sin(completionRatio * MathHelper.Pi * 1.6f - Main.GlobalTimeWrappedHourly * 4f) * 0.5f + 0.5f); return Color.Lerp(Color.White, endColor, fadeToEnd) * fadeOpacity; } internal float WidthFunction(float completionRatio) { - float expansionCompletion = 1f - (float)Math.Pow(1f - Utils.InverseLerp(0f, 0.3f, completionRatio, true), 2D); + float expansionCompletion = 1f - (float)Math.Pow(1f - Utils.GetLerpValue(0f, 0.3f, completionRatio, true), 2D); return MathHelper.Lerp(0f, 32f * Projectile.Opacity, expansionCompletion); } diff --git a/Projectiles/Magic/HeresyProj.cs b/Projectiles/Magic/HeresyProj.cs index aabcac9758..33ce7ffa27 100644 --- a/Projectiles/Magic/HeresyProj.cs +++ b/Projectiles/Magic/HeresyProj.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; @@ -12,7 +12,7 @@ namespace CalamityMod.Projectiles.Magic public class HeresyProj : ModProjectile { public Player Owner => Main.player[Projectile.owner]; - public float ShootIntensity => MathHelper.SmoothStep(0f, 1f, Utils.InverseLerp(0f, 275f, Time, true)); + public float ShootIntensity => MathHelper.SmoothStep(0f, 1f, Utils.GetLerpValue(0f, 275f, Time, true)); public ref float Time => ref Projectile.ai[0]; public ref float AttackTimer => ref Projectile.ai[1]; public override void SetStaticDefaults() @@ -43,12 +43,12 @@ namespace CalamityMod.Projectiles.Magic return; } - if (AttackTimer >= Main.rand.Next(20, 28) - (int)MathHelper.Lerp(0f, 16f, Utils.InverseLerp(0f, 120f, Time, true))) + if (AttackTimer >= Main.rand.Next(20, 28) - (int)MathHelper.Lerp(0f, 16f, Utils.GetLerpValue(0f, 120f, Time, true))) ReleaseThings(); // Switch frames at a linearly increasing rate to make it look like the player is flipping pages quickly. Projectile.frameCounter++; - if (Projectile.frameCounter >= (int)MathHelper.Lerp(10f, 2f, Utils.InverseLerp(0f, 180f, Time, true))) + if (Projectile.frameCounter >= (int)MathHelper.Lerp(10f, 2f, Utils.GetLerpValue(0f, 180f, Time, true))) { Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Projectile.type]; Projectile.frameCounter = 0; @@ -106,7 +106,7 @@ namespace CalamityMod.Projectiles.Magic public override bool PreDraw(ref Color lightColor) { - float glowOutwardness = MathHelper.SmoothStep(0f, 4f, Utils.InverseLerp(90f, 270f, Time, true)); + float glowOutwardness = MathHelper.SmoothStep(0f, 4f, Utils.GetLerpValue(90f, 270f, Time, true)); Texture2D bookTexture = ModContent.Request(Texture).Value; Rectangle frame = bookTexture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); Vector2 drawPosition; diff --git a/Projectiles/Magic/ManaMonster.cs b/Projectiles/Magic/ManaMonster.cs index d735a2003f..706231b4e2 100644 --- a/Projectiles/Magic/ManaMonster.cs +++ b/Projectiles/Magic/ManaMonster.cs @@ -1,4 +1,4 @@ -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Magic { if (Time < NPCAttackTime) { - Projectile.Opacity = Utils.InverseLerp(0f, 30f, Time, true); + Projectile.Opacity = Utils.GetLerpValue(0f, 30f, Time, true); if (Projectile.velocity.Length() < 27f) Projectile.velocity *= 1.05f; } @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.velocity *= 1.04f; // Fade out. - Projectile.Opacity = Utils.InverseLerp(0f, 15f, Projectile.timeLeft, true); + Projectile.Opacity = Utils.GetLerpValue(0f, 15f, Projectile.timeLeft, true); } Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; diff --git a/Projectiles/Magic/NanoPurgeHoldout.cs b/Projectiles/Magic/NanoPurgeHoldout.cs index 4d47166186..8d829e83d9 100644 --- a/Projectiles/Magic/NanoPurgeHoldout.cs +++ b/Projectiles/Magic/NanoPurgeHoldout.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Magic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -109,7 +109,7 @@ namespace CalamityMod.Projectiles.Magic { if (Main.myPlayer == Projectile.owner) { - float interpolant = Utils.InverseLerp(5f, 25f, Projectile.Distance(Main.MouseWorld), true); + float interpolant = Utils.GetLerpValue(5f, 25f, Projectile.Distance(Main.MouseWorld), true); Vector2 oldVelocity = Projectile.velocity; Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), interpolant); if (Projectile.velocity != oldVelocity) diff --git a/Projectiles/Magic/PartySparkle.cs b/Projectiles/Magic/PartySparkle.cs index 38424b3ef5..f6b0396005 100644 --- a/Projectiles/Magic/PartySparkle.cs +++ b/Projectiles/Magic/PartySparkle.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Magic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Magic ColorSpectrumHue = (ColorSpectrumHue + 0.333f / Lifetime) % 0.999f; // Go 33% across the color spectrum throughout the sparkle's life instead of using a static sprite. - Projectile.Opacity = Utils.InverseLerp(0f, FadeinTime, Time, true) * Utils.InverseLerp(Lifetime, Lifetime - FadeoutTime, Time, true); + Projectile.Opacity = Utils.GetLerpValue(0f, FadeinTime, Time, true) * Utils.GetLerpValue(Lifetime, Lifetime - FadeoutTime, Time, true); Projectile.velocity = Projectile.velocity.RotatedBy(Math.Sin(Time / 30f) * 0.0125f); } public override bool PreDraw(ref Color lightColor) @@ -69,7 +69,7 @@ namespace CalamityMod.Projectiles.Magic Color sparkleColor = CalamityUtils.MulticolorLerp(ColorSpectrumHue, RainbowPartyCannon.ColorSet) * Projectile.Opacity * 0.5f; sparkleColor.A = 0; - sparkleColor *= MathHelper.Lerp(1f, 1.5f, Utils.InverseLerp(Lifetime * 0.5f - 15f, Lifetime * 0.5f + 15f, Time, true)); + sparkleColor *= MathHelper.Lerp(1f, 1.5f, Utils.GetLerpValue(Lifetime * 0.5f - 15f, Lifetime * 0.5f + 15f, Time, true)); Color orthogonalsparkleColor = Color.Lerp(sparkleColor, Color.White, 0.5f) * 0.5f; diff --git a/Projectiles/Magic/PrinceFlameLarge.cs b/Projectiles/Magic/PrinceFlameLarge.cs index 5faecf29fa..9e141827ed 100644 --- a/Projectiles/Magic/PrinceFlameLarge.cs +++ b/Projectiles/Magic/PrinceFlameLarge.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Magic; using Microsoft.Xna.Framework; @@ -70,7 +70,7 @@ namespace CalamityMod.Projectiles.Magic // Dissipate at the end of the projectile's lifetime. if (dissipating) { - Projectile.frame = (int)Math.Round(MathHelper.Lerp(4f, 7f, Utils.InverseLerp(FadeoutTime, 0f, Projectile.timeLeft, true))); + Projectile.frame = (int)Math.Round(MathHelper.Lerp(4f, 7f, Utils.GetLerpValue(FadeoutTime, 0f, Projectile.timeLeft, true))); Projectile.velocity *= 0.95f; return; } diff --git a/Projectiles/Magic/PrinceFlameSmall.cs b/Projectiles/Magic/PrinceFlameSmall.cs index cfe0b2161b..8093b6916f 100644 --- a/Projectiles/Magic/PrinceFlameSmall.cs +++ b/Projectiles/Magic/PrinceFlameSmall.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.frameCounter++; Projectile.frame = Projectile.frameCounter / 5 % Main.projFrames[Projectile.type]; Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; - Projectile.Opacity = Utils.InverseLerp(0f, 15f, Projectile.timeLeft, true); + Projectile.Opacity = Utils.GetLerpValue(0f, 15f, Projectile.timeLeft, true); if (Time > AttackDelay) CalamityGlobalProjectile.HomeInOnNPC(Projectile, false, 600f, 14f, 32f); diff --git a/Projectiles/Magic/RainbowComet.cs b/Projectiles/Magic/RainbowComet.cs index 23581829d1..6bf949d2d3 100644 --- a/Projectiles/Magic/RainbowComet.cs +++ b/Projectiles/Magic/RainbowComet.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { Time++; - Projectile.Opacity = Utils.InverseLerp(0f, 20f, Time, true); + Projectile.Opacity = Utils.GetLerpValue(0f, 20f, Time, true); Projectile.velocity = Projectile.velocity.RotatedBy(Math.Sin(Time / 30f) * 0.0125f); Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; diff --git a/Projectiles/Magic/RainbowRocket.cs b/Projectiles/Magic/RainbowRocket.cs index 17e9ed8d53..438b04adde 100644 --- a/Projectiles/Magic/RainbowRocket.cs +++ b/Projectiles/Magic/RainbowRocket.cs @@ -1,4 +1,4 @@ -using CalamityMod.DataStructures; +using CalamityMod.DataStructures; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -129,7 +129,7 @@ namespace CalamityMod.Projectiles.Magic if (completionRatio < 0.1f) width = (float)Math.Sin(completionRatio / 0.1f * MathHelper.PiOver2) * maxWidthOutwardness + 0.1f; else - width = MathHelper.Lerp(maxWidthOutwardness, 0f, Utils.InverseLerp(0.1f, 1f, completionRatio, true)); + width = MathHelper.Lerp(maxWidthOutwardness, 0f, Utils.GetLerpValue(0.1f, 1f, completionRatio, true)); return width * Projectile.Opacity; } diff --git a/Projectiles/Magic/RancorArm.cs b/Projectiles/Magic/RancorArm.cs index f3e5bc57e3..b80ab51424 100644 --- a/Projectiles/Magic/RancorArm.cs +++ b/Projectiles/Magic/RancorArm.cs @@ -1,4 +1,4 @@ -using CalamityMod.World; +using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -108,8 +108,8 @@ namespace CalamityMod.Projectiles.Magic // Rise from underneath the ideal position and fade in. // At the end of the projectile's lifetime the arm sinks back into the ground and withers away. - float descendCompletion = Utils.InverseLerp(0f, 24f, Projectile.timeLeft, true); - float riseCompletion = Utils.InverseLerp(0f, 30f, Time, true); + float descendCompletion = Utils.GetLerpValue(0f, 24f, Projectile.timeLeft, true); + float riseCompletion = Utils.GetLerpValue(0f, 30f, Time, true); float heightOffset = -58f; if (Projectile.height > 90f) heightOffset += 22f; diff --git a/Projectiles/Magic/RancorFog.cs b/Projectiles/Magic/RancorFog.cs index 3e05cb7832..80787c9456 100644 --- a/Projectiles/Magic/RancorFog.cs +++ b/Projectiles/Magic/RancorFog.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Magic // Without this, it may render over the fullblack that the game renders for obscured tiles. float lightPowerBelow = Lighting.GetColor((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16 + 6).ToVector3().Length() / (float)Math.Sqrt(3D); LightPower = MathHelper.Lerp(LightPower, lightPowerBelow, 0.15f); - Projectile.Opacity = Utils.InverseLerp(210f, 195f, Projectile.timeLeft, true) * Utils.InverseLerp(0f, 90f, Projectile.timeLeft, true); + Projectile.Opacity = Utils.GetLerpValue(210f, 195f, Projectile.timeLeft, true) * Utils.GetLerpValue(0f, 90f, Projectile.timeLeft, true); Projectile.rotation += Projectile.velocity.X * 0.004f; Projectile.velocity *= 0.985f; } @@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Magic Texture2D texture = ModContent.Request(Texture).Value; Vector2 origin = texture.Size() * 0.5f; Vector2 drawPosition = Projectile.Center - Main.screenPosition; - float opacity = Utils.InverseLerp(0f, 0.08f, LightPower, true) * Projectile.Opacity * 0.5f; + float opacity = Utils.GetLerpValue(0f, 0.08f, LightPower, true) * Projectile.Opacity * 0.5f; Color drawColor = new Color(236, 0, 68) * opacity; Vector2 scale = Projectile.Size / texture.Size() * Projectile.scale; Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, Projectile.rotation, origin, scale, SpriteEffects.None, 0); diff --git a/Projectiles/Magic/RancorLargeCinder.cs b/Projectiles/Magic/RancorLargeCinder.cs index a1a85be991..fe3c9aa0f9 100644 --- a/Projectiles/Magic/RancorLargeCinder.cs +++ b/Projectiles/Magic/RancorLargeCinder.cs @@ -1,4 +1,4 @@ -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Magic // Calculate the scale of the cinder. else { - Projectile.scale = Utils.InverseLerp(0f, 20f, Time, true) * Utils.InverseLerp(Lifetime, Lifetime - 20f, Time, true); + Projectile.scale = Utils.GetLerpValue(0f, 20f, Time, true) * Utils.GetLerpValue(Lifetime, Lifetime - 20f, Time, true); Projectile.scale *= MathHelper.Lerp(0.5f, 1f, Projectile.identity % 6f / 6f); } diff --git a/Projectiles/Magic/RancorLaserbeam.cs b/Projectiles/Magic/RancorLaserbeam.cs index 23866f8484..c96e28c7fc 100644 --- a/Projectiles/Magic/RancorLaserbeam.cs +++ b/Projectiles/Magic/RancorLaserbeam.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs; +using CalamityMod.Buffs; using CalamityMod.Particles; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -158,9 +158,9 @@ namespace CalamityMod.Projectiles.Magic private Color PrimitiveColorFunction(float completionRatio) { Color vibrantColor = Color.Lerp(Color.Blue, Color.Red, (float)Math.Cos(Main.GlobalTimeWrappedHourly * 0.67f - completionRatio / LaserLength * 29f) * 0.5f + 0.5f); - float opacity = Projectile.Opacity * Utils.InverseLerp(0.97f, 0.9f, completionRatio, true) * - Utils.InverseLerp(0f, MathHelper.Clamp(15f / LaserLength, 0f, 0.5f), completionRatio, true) * - (float)Math.Pow(Utils.InverseLerp(60f, 270f, LaserLength, true), 3D); + float opacity = Projectile.Opacity * Utils.GetLerpValue(0.97f, 0.9f, completionRatio, true) * + Utils.GetLerpValue(0f, MathHelper.Clamp(15f / LaserLength, 0f, 0.5f), completionRatio, true) * + (float)Math.Pow(Utils.GetLerpValue(60f, 270f, LaserLength, true), 3D); return Color.Lerp(vibrantColor, Color.White, 0.5f) * opacity * 2f; } diff --git a/Projectiles/Magic/RancorMagicCircle.cs b/Projectiles/Magic/RancorMagicCircle.cs index 67fa95c687..e660e0d6e3 100644 --- a/Projectiles/Magic/RancorMagicCircle.cs +++ b/Projectiles/Magic/RancorMagicCircle.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Utilities; using System; @@ -83,7 +83,7 @@ namespace CalamityMod.Projectiles.Magic public void AdjustVisualValues() { - Projectile.scale = Utils.InverseLerp(0f, 35f, Time, true) * 1.4f; + Projectile.scale = Utils.GetLerpValue(0f, 35f, Time, true) * 1.4f; Projectile.Opacity = (float)Math.Pow(Projectile.scale / 1.4f, 2D); Projectile.rotation -= MathHelper.ToRadians(Projectile.scale * 4f); } diff --git a/Projectiles/Magic/RancorSmallCinder.cs b/Projectiles/Magic/RancorSmallCinder.cs index e2fb22f50e..5ae889b12f 100644 --- a/Projectiles/Magic/RancorSmallCinder.cs +++ b/Projectiles/Magic/RancorSmallCinder.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -43,7 +43,7 @@ namespace CalamityMod.Projectiles.Magic // Calculate scale of the cinder. else { - Projectile.scale = Utils.InverseLerp(0f, 20f, Time, true) * Utils.InverseLerp(Lifetime, Lifetime - 20f, Time, true); + Projectile.scale = Utils.GetLerpValue(0f, 20f, Time, true) * Utils.GetLerpValue(Lifetime, Lifetime - 20f, Time, true); Projectile.scale *= MathHelper.Lerp(0.5f, 1f, Projectile.identity % 6f / 6f); } diff --git a/Projectiles/Magic/RedirectingFire.cs b/Projectiles/Magic/RedirectingFire.cs index c310c53552..2baf69f644 100644 --- a/Projectiles/Magic/RedirectingFire.cs +++ b/Projectiles/Magic/RedirectingFire.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.ID; @@ -32,7 +32,7 @@ namespace CalamityMod.Projectiles.Magic if (potentialTarget != null) HomeInOnTarget(potentialTarget); - float accelerationFactor = MathHelper.SmoothStep(1.025f, 1.015f, Utils.InverseLerp(6f, 24f, Projectile.velocity.Length(), true)); + float accelerationFactor = MathHelper.SmoothStep(1.025f, 1.015f, Utils.GetLerpValue(6f, 24f, Projectile.velocity.Length(), true)); if (Projectile.velocity.Length() < 24f) Projectile.velocity *= accelerationFactor; } @@ -43,12 +43,12 @@ namespace CalamityMod.Projectiles.Magic public void HomeInOnTarget(NPC target) { float oldSpeed = Projectile.velocity.Length(); - float delayFactor = Utils.InverseLerp(20f, 35f, Time, true); + float delayFactor = Utils.GetLerpValue(20f, 35f, Time, true); float homeSpeed = MathHelper.Lerp(0f, 0.075f, delayFactor); Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(target.Center) * 16f, homeSpeed); Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * oldSpeed; - Projectile.position += (target.Center - Projectile.Center).SafeNormalize(Vector2.Zero) * MathHelper.Lerp(25f, 1f, Utils.InverseLerp(100f, 360f, Projectile.Distance(target.Center), true)) * delayFactor; + Projectile.position += (target.Center - Projectile.Center).SafeNormalize(Vector2.Zero) * MathHelper.Lerp(25f, 1f, Utils.GetLerpValue(100f, 360f, Projectile.Distance(target.Center), true)) * delayFactor; } public Dust CreateDustInstance() diff --git a/Projectiles/Magic/RedirectingGildedSoul.cs b/Projectiles/Magic/RedirectingGildedSoul.cs index 080cfb7843..23444035da 100644 --- a/Projectiles/Magic/RedirectingGildedSoul.cs +++ b/Projectiles/Magic/RedirectingGildedSoul.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; @@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.Magic for (int j = 0; j < Projectile.oldPos.Length / 2; j++) { Color drawColor = Projectile.GetAlpha(lightColor); - drawColor = Color.Lerp(drawColor, Color.White * Projectile.Opacity, 2f * j / Projectile.oldPos.Length) * (float)Math.Pow(1f - Utils.InverseLerp(0f, Projectile.oldPos.Length / 2, j, true), 2D); + drawColor = Color.Lerp(drawColor, Color.White * Projectile.Opacity, 2f * j / Projectile.oldPos.Length) * (float)Math.Pow(1f - Utils.GetLerpValue(0f, Projectile.oldPos.Length / 2, j, true), 2D); Vector2 drawPosition = Projectile.oldPos[j] + Projectile.Size * 0.5f + (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 0.5f - Main.screenPosition; float rotation = Projectile.oldRot[j]; diff --git a/Projectiles/Magic/RedirectingLostSoul.cs b/Projectiles/Magic/RedirectingLostSoul.cs index c7f66ccac3..5c35e0e726 100644 --- a/Projectiles/Magic/RedirectingLostSoul.cs +++ b/Projectiles/Magic/RedirectingLostSoul.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; @@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Magic for (int j = 0; j < Projectile.oldPos.Length / 2; j++) { - float fade = (float)Math.Pow(1f - Utils.InverseLerp(0f, Projectile.oldPos.Length / 2, j, true), 2D); + float fade = (float)Math.Pow(1f - Utils.GetLerpValue(0f, Projectile.oldPos.Length / 2, j, true), 2D); Color drawColor = Projectile.GetAlpha(lightColor) * fade; Vector2 drawPosition = Projectile.oldPos[j] + Projectile.Size * 0.5f - Main.screenPosition; float rotation = Projectile.oldRot[j]; diff --git a/Projectiles/Magic/RedirectingVengefulSoul.cs b/Projectiles/Magic/RedirectingVengefulSoul.cs index a573a55b8e..ef6204e236 100644 --- a/Projectiles/Magic/RedirectingVengefulSoul.cs +++ b/Projectiles/Magic/RedirectingVengefulSoul.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; @@ -41,11 +41,11 @@ namespace CalamityMod.Projectiles.Magic if (potentialTarget != null) HomeInOnTarget(projectile, potentialTarget, time); - float accelerationFactor = MathHelper.SmoothStep(1.03f, 1.015f, Utils.InverseLerp(6f, 24f, projectile.velocity.Length(), true)); + float accelerationFactor = MathHelper.SmoothStep(1.03f, 1.015f, Utils.GetLerpValue(6f, 24f, projectile.velocity.Length(), true)); if (projectile.velocity.Length() < 21f + soulPower * 2f) projectile.velocity *= accelerationFactor; } - projectile.Opacity = Utils.InverseLerp(0f, 15f, time, true); + projectile.Opacity = Utils.GetLerpValue(0f, 15f, time, true); projectile.frameCounter++; if (projectile.frameCounter % 5f == 4f) projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Magic public static void HomeInOnTarget(Projectile projectile, NPC target, float time) { float oldSpeed = projectile.velocity.Length(); - float delayFactor = Utils.InverseLerp(20f, 35f, time, true); + float delayFactor = Utils.GetLerpValue(20f, 35f, time, true); float homeSpeed = MathHelper.Lerp(0f, 0.075f, delayFactor); projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.SafeDirectionTo(target.Center) * 16f, homeSpeed); @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Magic { for (int j = 0; j < Projectile.oldPos.Length / 2; j++) { - float fade = (float)Math.Pow(1f - Utils.InverseLerp(0f, Projectile.oldPos.Length / 2, j, true), 2D); + float fade = (float)Math.Pow(1f - Utils.GetLerpValue(0f, Projectile.oldPos.Length / 2, j, true), 2D); Color drawColor = Color.Lerp(Projectile.GetAlpha(lightColor), Color.White * Projectile.Opacity, j / Projectile.oldPos.Length) * fade; Vector2 drawPosition = Projectile.oldPos[j] + Projectile.Size * 0.5f + (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 1.5f - Main.screenPosition; float rotation = Projectile.oldRot[j];