1 - InverseLerp fixes.

This commit is contained in:
mountaindrew10 committed 2022-04-05 01:48:36 -05:00
1 parent 6009f62e8f
commit 129be0f110
99 files changed
+258 -258

No files matched your search

+2 -2
View File
@@ -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);
+2 -2
View File
@@ -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<AuricDye>());
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);
+2 -2
View File
@@ -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));
}
+4 -4
View File
@@ -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<Texture2D>("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;
+1 -1
View File
@@ -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);
}
+2 -2
View File
@@ -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<WITCH>());
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;
@@ -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);
}
+2 -2
View File
@@ -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];
+1 -1
View File
@@ -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)
+2 -2
View File
@@ -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))
+2 -2
View File
@@ -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();
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -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();
+2 -2
View File
@@ -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<DevourerofGodsHead>().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;
+6 -6
View File
@@ -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)
+1 -1
View File
@@ -229,7 +229,7 @@ namespace CalamityMod.NPCs.DevourerofGods
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Projectile portal = Main.projectile[Main.npc[(int)NPC.ai[2]].ModNPC<DevourerofGodsHead>().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;
+6 -6
View File
@@ -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;
+6 -6
View File
@@ -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;
+5 -5
View File
@@ -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);
+3 -3
View File
@@ -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;
+2 -2
View File
@@ -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;
+3 -3
View File
@@ -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;
+2 -2
View File
@@ -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)
+1 -1
View File
@@ -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;
+3 -3
View File
@@ -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;
}
+2 -2
View File
@@ -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);
}
+1 -1
View File
@@ -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();
+5 -5
View File
@@ -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++)
{
+2 -2
View File
@@ -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;
}
+2 -2
View File
@@ -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;
+6 -6
View File
@@ -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
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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<Texture2D>(Texture);
+3 -3
View File
@@ -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;
+3 -3
View File
@@ -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;
}
}
+3 -3
View File
@@ -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;
}
}
+1 -1
View File
@@ -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;
}
+2 -2
View File
@@ -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);
}
}
+2 -2
View File
@@ -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;
}
@@ -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);
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -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;
+4 -4
View File
@@ -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;
}
+2 -2
View File
@@ -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();
+2 -2
View File
@@ -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<Texture2D>(Texture).Value;
Vector2 drawPos = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY);
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -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++;
}
+3 -3
View File
@@ -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;
+2 -2
View File
@@ -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<Texture2D>(Texture).Value;
Vector2 drawPos = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY);
+3 -3
View File
@@ -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)
+2 -2
View File
@@ -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;
+2 -2
View File
@@ -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)
{
+3 -3
View File
@@ -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;
+4 -4
View File
@@ -31,9 +31,9 @@ namespace CalamityMod.Projectiles.Boss
// If SCal is already present, this does not happen.
if (!NPC.AnyNPCs(ModContent.NPCType<SupremeCalamitas>()))
{
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;
+2 -2
View File
@@ -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++;
+2 -2
View File
@@ -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++;
+4 -4
View File
@@ -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<Texture2D>("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;
@@ -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;
}
@@ -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<Vector2> oldPositions = new List<Vector2>()
{
@@ -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)
@@ -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;
@@ -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);
@@ -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;
@@ -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
{
@@ -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);
@@ -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<Texture2D>("CalamityMod/Projectiles/LightningProj");
for (int i = 0; i < totalCirclePoints; i++)
{
+1 -1
View File
@@ -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))
@@ -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++)
{
+3 -3
View File
@@ -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))
+2 -2
View File
@@ -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;
}
+2 -2
View File
@@ -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;
}
+2 -2
View File
@@ -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)
+4 -4
View File
@@ -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;
}
+2 -2
View File
@@ -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<Texture2D>("CalamityMod/Projectiles/StarProj");
+7 -7
View File
@@ -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<Vector2> 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);
}
+2 -2
View File
@@ -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)
+1 -1
View File
@@ -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;
+5 -5
View File
@@ -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);
}
+3 -3
View File
@@ -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;
}
+4 -4
View File
@@ -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);
}
+5 -5
View File
@@ -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<Texture2D>(Texture).Value;
Rectangle frame = bookTexture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame);
Vector2 drawPosition;
+3 -3
View File
@@ -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;
+2 -2
View File
@@ -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)
+3 -3
View File
@@ -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;
+2 -2
View File
@@ -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;
}
+2 -2
View File
@@ -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);
+1 -1
View File
@@ -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;
+2 -2
View File
@@ -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;
}
+3 -3
View File
@@ -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;
+3 -3
View File
@@ -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<Texture2D>(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);
+2 -2
View File
@@ -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);
}
+4 -4
View File
@@ -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;
}
+2 -2
View File
@@ -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);
}
+2 -2
View File
@@ -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);
}
+4 -4
View File
@@ -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()
+2 -2
View File
@@ -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];
+2 -2
View File
@@ -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];
+5 -5
View File
@@ -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];