Potion seller. Your best easings, please
This commit is contained in:
1 parent
a2e660a0b6
commit
79efda87af
5 files changed
+52
-53
No files matched your search
@@ -76,7 +76,7 @@ float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
|
||||
color = lerp(color, float4(uSecondaryColor, 1), darkColorWeight);
|
||||
|
||||
// Create a fire streak.
|
||||
float fireColorWeight = InverseLerp(0.3, 0, coords.y) * pow(1 - coords.x, 2);
|
||||
float fireColorWeight = InverseLerp(0.3, 0, coords.y) * pow(1 - coords.x, 0.5);
|
||||
color = lerp(color, float4(fireColor, 1), fireColorWeight);
|
||||
|
||||
float4 noiseColor = color * opacity * (noise3 * 2.4 + 2.4);
|
||||
|
||||
Binary file not shown.
@@ -31,8 +31,8 @@ namespace CalamityMod.Items.Weapons.Melee
|
||||
Item.height = 114;
|
||||
Item.damage = 900;
|
||||
Item.useStyle = ItemUseStyleID.Swing;
|
||||
Item.useTime = 35;
|
||||
Item.useAnimation = 35;
|
||||
Item.useTime = 49;
|
||||
Item.useAnimation = 49;
|
||||
Item.useTurn = true;
|
||||
Item.DamageType = DamageClass.Melee;
|
||||
Item.knockBack = 9f;
|
||||
|
||||
@@ -12,6 +12,7 @@ using Terraria.Audio;
|
||||
using System.Collections.Generic;
|
||||
using CalamityMod.DataStructures;
|
||||
using System.Linq;
|
||||
using static CalamityMod.CalamityUtils;
|
||||
|
||||
namespace CalamityMod.Projectiles.Melee
|
||||
{
|
||||
@@ -44,6 +45,16 @@ namespace CalamityMod.Projectiles.Melee
|
||||
|
||||
public const float StartingSwingRotation = -0.72f;
|
||||
public const float EndingSwingRotation = StartingSwingRotation + MathHelper.TwoPi - 0.33f;
|
||||
|
||||
// Starts at 0.125 and reels back.
|
||||
public static CurveSegment Anticipation => new(EasingType.PolyInOut, 0f, 0.27f, -0.27f);
|
||||
|
||||
public static CurveSegment SlashWait => new(EasingType.Linear, 0.37f, 0f, 0f);
|
||||
|
||||
// After reeling back, a powerful slash happens.
|
||||
public static CurveSegment Slash => new(EasingType.PolyOut, 0.51f, 0f, 1f);
|
||||
|
||||
public static CurveSegment HoldBladeInPlace => new(EasingType.Linear, 0.7f, 1f, 0f);
|
||||
|
||||
public override string Texture => "CalamityMod/Items/Weapons/Melee/Exoblade";
|
||||
|
||||
@@ -135,35 +146,27 @@ namespace CalamityMod.Projectiles.Melee
|
||||
{
|
||||
// Decide the swing direction.
|
||||
if (Owner.itemAnimation == Owner.itemAnimationMax)
|
||||
{
|
||||
if (SwingDirection == 0f)
|
||||
SwingDirection = Main.rand.NextBool().ToDirectionInt();
|
||||
SwingDirection *= -1f;
|
||||
}
|
||||
SwingDirection = 1f;
|
||||
|
||||
float exactSwingCompletion = 1f - Owner.itemAnimation / (float)Owner.itemAnimationMax;
|
||||
float directionalSwingCompletion = exactSwingCompletion;
|
||||
if (SwingDirection == -1f)
|
||||
directionalSwingCompletion = 1f - directionalSwingCompletion;
|
||||
|
||||
directionalSwingCompletion = MathHelper.Clamp(directionalSwingCompletion, 0f, 1f);
|
||||
|
||||
directionalSwingCompletion = MathHelper.Clamp(directionalSwingCompletion, 0f, 1f);
|
||||
|
||||
// TODO -- Make this better.
|
||||
// Hi Iban! Good luck :)
|
||||
float swingCompletion;
|
||||
if (directionalSwingCompletion < 0.3f)
|
||||
swingCompletion = Utils.Remap(directionalSwingCompletion, 0f, 0.3f, 0.12f, 0f);
|
||||
else if (directionalSwingCompletion < 0.54f)
|
||||
swingCompletion = (float)Math.Pow(Utils.GetLerpValue(0.3f, 0.54f, directionalSwingCompletion, true), 0.75);
|
||||
else
|
||||
swingCompletion = 1f;
|
||||
float swingCompletion = PiecewiseAnimation(directionalSwingCompletion, Anticipation, SlashWait, Slash, HoldBladeInPlace);
|
||||
|
||||
// Clear the rotation cache after enough time has passed.
|
||||
if (directionalSwingCompletion >= 0.74f)
|
||||
if (directionalSwingCompletion < 0.45f)
|
||||
Projectile.oldRot = new float[Projectile.oldRot.Length];
|
||||
|
||||
// Decide the swing direction.
|
||||
Projectile.rotation = MathHelper.Lerp(StartingSwingRotation, EndingSwingRotation, swingCompletion) * Direction - MathHelper.PiOver4;
|
||||
Projectile.rotation = MathHelper.Lerp(StartingSwingRotation, EndingSwingRotation, swingCompletion);
|
||||
Projectile.rotation = Projectile.rotation.AngleLerp(MathHelper.Lerp(StartingSwingRotation, EndingSwingRotation, 0.27f), Utils.GetLerpValue(0.8f, 1f, directionalSwingCompletion, true));
|
||||
Projectile.rotation = Projectile.rotation * Direction - MathHelper.PiOver4;
|
||||
if (Direction == -1)
|
||||
Projectile.rotation -= MathHelper.PiOver2;
|
||||
|
||||
VerticalStretchFactor = Utils.Remap(swingCompletion, 0f, 0.5f, 0f, 0.4f);
|
||||
|
||||
@@ -173,12 +176,13 @@ namespace CalamityMod.Projectiles.Melee
|
||||
Projectile.scale = Utils.GetLerpValue(0f, 0.2f, exactSwingCompletion, true) * Utils.GetLerpValue(1f, 0.8f, exactSwingCompletion, true);
|
||||
|
||||
// Create a bunch of homing beams.
|
||||
int beamShootRate = (Projectile.MaxUpdates * 3);
|
||||
if (Main.myPlayer == Projectile.owner && Projectile.timeLeft % beamShootRate == 0 && directionalSwingCompletion < 0.33f)
|
||||
int beamShootRate = Projectile.MaxUpdates * 2;
|
||||
if (Main.myPlayer == Projectile.owner && Projectile.timeLeft % beamShootRate == 0 && swingCompletion > 0.2f && swingCompletion < 0.9f)
|
||||
{
|
||||
int boltDamage = Projectile.damage / 2;
|
||||
Vector2 boltVelocity = (Projectile.rotation + MathHelper.PiOver4).ToRotationVector2();
|
||||
boltVelocity = Vector2.Lerp(boltVelocity, Projectile.SafeDirectionTo(Main.MouseWorld), 0.6f).SafeNormalize(Vector2.UnitY) * 9f;
|
||||
boltVelocity = Vector2.Lerp(boltVelocity, Vector2.UnitX * Direction, 0.8f).SafeNormalize(Vector2.UnitY);
|
||||
boltVelocity *= 9f;
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center + boltVelocity * 5f, boltVelocity, ModContent.ProjectileType<Exobeam>(), boltDamage, Projectile.knockBack / 3f, Projectile.owner);
|
||||
}
|
||||
|
||||
@@ -213,7 +217,7 @@ namespace CalamityMod.Projectiles.Melee
|
||||
|
||||
public float SlashWidthFunction(float completionRatio) => Projectile.scale * 43.5f;
|
||||
|
||||
public Color SlashColorFunction(float completionRatio) => Color.Lime * Utils.GetLerpValue(1f, 0.6f, completionRatio, true) * Projectile.Opacity;
|
||||
public Color SlashColorFunction(float completionRatio) => Color.Lime * Utils.GetLerpValue(0.9f, 0.4f, completionRatio, true) * Projectile.Opacity;
|
||||
|
||||
public IEnumerable<Vector2> GenerateSlashPoints()
|
||||
{
|
||||
@@ -265,7 +269,7 @@ namespace CalamityMod.Projectiles.Melee
|
||||
Main.spriteBatch.EnterShaderRegion();
|
||||
|
||||
var texture = ModContent.Request<Texture2D>(Texture).Value;
|
||||
CalamityUtils.CalculatePerspectiveMatricies(out Matrix viewMatrix, out Matrix projectionMatrix);
|
||||
CalculatePerspectiveMatricies(out Matrix viewMatrix, out Matrix projectionMatrix);
|
||||
GameShaders.Misc["CalamityMod:LinearTransformation"].UseColor(Main.hslToRgb(0.95f, 0.85f, 0.5f));
|
||||
GameShaders.Misc["CalamityMod:LinearTransformation"].UseOpacity(0f);
|
||||
GameShaders.Misc["CalamityMod:LinearTransformation"].Shader.Parameters["uWorldViewProjection"].SetValue(viewMatrix * projectionMatrix);
|
||||
|
||||
@@ -206,16 +206,16 @@ namespace CalamityMod
|
||||
/// <summary>
|
||||
/// This indicates when the segment starts on the animation
|
||||
/// </summary>
|
||||
public float originX;
|
||||
public float startingX;
|
||||
/// <summary>
|
||||
/// This indicates what the starting height of the segment is
|
||||
/// </summary>
|
||||
public float originY;
|
||||
public float startingHeight;
|
||||
/// <summary>
|
||||
/// This represents the elevation shift that will happen during the segment. Set this to 0 to turn the segment into a flat line.
|
||||
/// Usually this elevation shift is fully applied at the end of a segment, but the sinebump easing type makes it be reached at the apex of its curve.
|
||||
/// </summary>
|
||||
public float displacement;
|
||||
public float elevationShift;
|
||||
/// <summary>
|
||||
/// This is the degree of the polynomial, if the easing mode chosen is a polynomial one
|
||||
/// </summary>
|
||||
@@ -224,22 +224,17 @@ namespace CalamityMod
|
||||
/// <summary>
|
||||
/// Legacy constructor
|
||||
/// </summary>
|
||||
public CurveSegment(EasingType MODE, float ORGX, float ORGY, float DISP, int DEG = 1)
|
||||
{
|
||||
easing = EasingTypeToFunction[(int)MODE];
|
||||
originX = ORGX;
|
||||
originY = ORGY;
|
||||
displacement = DISP;
|
||||
degree = DEG;
|
||||
}
|
||||
public CurveSegment(EasingType MODE, float startX, float startHeight, float elevationShift, int degree = 1) :
|
||||
this(EasingTypeToFunction[(int)MODE], startX, startHeight, elevationShift, degree)
|
||||
{ }
|
||||
|
||||
public CurveSegment(EasingFunction MODE, float ORGX, float ORGY, float DISP, int DEG = 1)
|
||||
public CurveSegment(EasingFunction MODE, float startX, float startHeight, float elevationShift, int degree = 1)
|
||||
{
|
||||
easing = MODE;
|
||||
originX = ORGX;
|
||||
originY = ORGY;
|
||||
displacement = DISP;
|
||||
degree = DEG;
|
||||
startingX = startX;
|
||||
startingHeight = startHeight;
|
||||
this.elevationShift = elevationShift;
|
||||
this.degree = degree;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,13 +245,13 @@ namespace CalamityMod
|
||||
/// <param name="progress">How far along the curve you are. Automatically clamped between 0 and 1</param>
|
||||
/// <param name="segments">An array of curve segments making up the full animation curve</param>
|
||||
/// <returns></returns>
|
||||
public static float PiecewiseAnimation(float progress, CurveSegment[] segments)
|
||||
public static float PiecewiseAnimation(float progress, params CurveSegment[] segments)
|
||||
{
|
||||
if (segments.Length == 0)
|
||||
return 0f;
|
||||
|
||||
if (segments[0].originX != 0) //If for whatever reason you try to not play by the rules, get fucked
|
||||
segments[0].originX = 0;
|
||||
if (segments[0].startingX != 0) //If for whatever reason you try to not play by the rules, get fucked
|
||||
segments[0].startingX = 0;
|
||||
|
||||
progress = MathHelper.Clamp(progress, 0f, 1f); //Clamp the progress
|
||||
float ratio = 0f;
|
||||
@@ -264,29 +259,29 @@ namespace CalamityMod
|
||||
for (int i = 0; i <= segments.Length - 1; i++)
|
||||
{
|
||||
CurveSegment segment = segments[i];
|
||||
float startPoint = segment.originX;
|
||||
float startPoint = segment.startingX;
|
||||
float endPoint = 1f;
|
||||
|
||||
if (progress < segment.originX) //Too early. This should never get reached, since by the time you'd have gotten there you'd have found the appropriate segment and broken out of the for loop
|
||||
if (progress < segment.startingX) //Too early. This should never get reached, since by the time you'd have gotten there you'd have found the appropriate segment and broken out of the for loop
|
||||
continue;
|
||||
|
||||
if (i < segments.Length - 1)
|
||||
{
|
||||
if (segments[i + 1].originX <= progress) //Too late
|
||||
if (segments[i + 1].startingX <= progress) //Too late
|
||||
continue;
|
||||
endPoint = segments[i + 1].originX;
|
||||
endPoint = segments[i + 1].startingX;
|
||||
}
|
||||
|
||||
float segmentLenght = endPoint - startPoint;
|
||||
float segmentProgress = (progress - segment.originX) / segmentLenght; //How far along the specific segment
|
||||
ratio = segment.originY;
|
||||
float segmentProgress = (progress - segment.startingX) / segmentLenght; //How far along the specific segment
|
||||
ratio = segment.startingHeight;
|
||||
|
||||
//Failsafe because somehow it can fail? what
|
||||
if (segment.easing != null)
|
||||
ratio += segment.easing(segmentProgress, segment.degree) * segment.displacement;
|
||||
ratio += segment.easing(segmentProgress, segment.degree) * segment.elevationShift;
|
||||
|
||||
else
|
||||
ratio += LinearEasing(segmentProgress, segment.degree) * segment.displacement;
|
||||
ratio += LinearEasing(segmentProgress, segment.degree) * segment.elevationShift;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user