mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Add some lerping to the various mana bars
This commit is contained in:
parent
8331906d61
commit
5f8dfe14e9
4 changed files with 37 additions and 12 deletions
|
@ -65,8 +65,8 @@ class ManaRingSlot extends Slot {
|
|||
}
|
||||
|
||||
private double renderRing(MatrixStack matrices, double outerRadius, double innerRadius, double offsetAngle, Bar bar, int color, float tickDelta) {
|
||||
double fill = bar.getPercentFill() * DrawableUtil.TAU;
|
||||
double shadow = bar.getShadowFill() * DrawableUtil.TAU;
|
||||
double fill = bar.getPercentFill(tickDelta) * DrawableUtil.TAU;
|
||||
double shadow = bar.getShadowFill(tickDelta) * DrawableUtil.TAU;
|
||||
|
||||
DrawableUtil.drawArc(matrices, innerRadius, outerRadius, offsetAngle, fill, color, true);
|
||||
|
||||
|
|
|
@ -67,7 +67,8 @@ public class SpellbookProfilePageContent implements SpellbookChapterList.Content
|
|||
|
||||
int y = SpellbookScreen.TITLE_Y;
|
||||
|
||||
float delta = pony.asEntity().age + client.getTickDelta();
|
||||
float tickDelta = client.getTickDelta();
|
||||
float delta = pony.asEntity().age + tickDelta;
|
||||
int currentLevel = pony.getLevel().get();
|
||||
float currentScaledLevel = pony.getLevel().getScaled(1);
|
||||
float currentCorruption = pony.getCorruption().getScaled(1);
|
||||
|
@ -100,8 +101,8 @@ public class SpellbookProfilePageContent implements SpellbookChapterList.Content
|
|||
double growth = MathHelper.sin(delta / 9F) * 2;
|
||||
|
||||
double radius = 40 + growth;
|
||||
float xpPercentage = reserves.getXp().getPercentFill();
|
||||
float manaPercentage = reserves.getMana().getPercentFill();
|
||||
float xpPercentage = reserves.getXp().getPercentFill(tickDelta);
|
||||
float manaPercentage = reserves.getMana().getPercentFill(tickDelta);
|
||||
|
||||
float alphaF = (MathHelper.sin(delta / 9F) + 1) / 2F;
|
||||
int alpha = (int)(alphaF * 0x10) & 0xFF;
|
||||
|
|
|
@ -41,7 +41,14 @@ public interface MagicReserves {
|
|||
/**
|
||||
* Gets the current value of this bar
|
||||
*/
|
||||
float get();
|
||||
default float get() {
|
||||
return get(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the (lerped) value of this bar
|
||||
*/
|
||||
float get(float tickDelta);
|
||||
|
||||
/**
|
||||
* Sets the absolute value
|
||||
|
@ -52,13 +59,20 @@ public interface MagicReserves {
|
|||
* Gets the percentage fill of this bar
|
||||
*/
|
||||
default float getPercentFill() {
|
||||
return get() / getMax();
|
||||
return getPercentFill(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the percentage fill of this bar
|
||||
*/
|
||||
default float getPercentFill(float tickDelta) {
|
||||
return get(tickDelta) / getMax();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shadow fill used for animating on the UI
|
||||
*/
|
||||
float getShadowFill();
|
||||
float getShadowFill(float tickDelta);
|
||||
|
||||
/**
|
||||
* Adds a percentage increment to this bar's current value
|
||||
|
|
|
@ -102,8 +102,8 @@ class ManaContainer implements MagicReserves, Tickable, NbtSerialisable, Copyabl
|
|||
}
|
||||
|
||||
if (!pony.getSpecies().canFly() || !pony.getPhysics().isFlying()) {
|
||||
if (mana.getPercentFill() < 1 && mana.getShadowFill() == mana.getPercentFill()) {
|
||||
mana.addPercent(MathHelper.clamp(1 + pony.getLevel().get(), 1, 50));
|
||||
if (mana.getPercentFill() < 1 && mana.getShadowFill(1) <= mana.getPercentFill(1)) {
|
||||
mana.addPercent(MathHelper.clamp(1 + pony.getLevel().get(), 1, 50) / 4F);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,6 +157,8 @@ class ManaContainer implements MagicReserves, Tickable, NbtSerialisable, Copyabl
|
|||
private final float max;
|
||||
|
||||
private float trailingValue;
|
||||
private float prevTrailingValue;
|
||||
private float prevValue;
|
||||
|
||||
BarInst(TrackedData<Float> marker, float max, float initial) {
|
||||
this.marker = marker;
|
||||
|
@ -171,8 +173,13 @@ class ManaContainer implements MagicReserves, Tickable, NbtSerialisable, Copyabl
|
|||
}
|
||||
|
||||
@Override
|
||||
public float getShadowFill() {
|
||||
return trailingValue;
|
||||
public float get(float tickDelta) {
|
||||
return MathHelper.lerp(tickDelta, prevValue, get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShadowFill(float tickDelta) {
|
||||
return MathHelper.lerp(tickDelta, prevTrailingValue, trailingValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -203,6 +210,9 @@ class ManaContainer implements MagicReserves, Tickable, NbtSerialisable, Copyabl
|
|||
}
|
||||
|
||||
void tick() {
|
||||
prevValue = get();
|
||||
prevTrailingValue = trailingValue;
|
||||
|
||||
float fill = getPercentFill();
|
||||
float trailingIncrement = 0.003F;
|
||||
|
||||
|
|
Loading…
Reference in a new issue