mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 11:36:43 +01:00
A bit of balancing
This commit is contained in:
parent
8025cf570b
commit
ea08c78df0
4 changed files with 45 additions and 39 deletions
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
import com.minelittlepony.unicopia.ability.Abilities;
|
||||
import com.minelittlepony.unicopia.ability.AbilityDispatcher;
|
||||
import com.minelittlepony.unicopia.ability.AbilitySlot;
|
||||
import com.minelittlepony.unicopia.entity.player.MagicReserves;
|
||||
import com.minelittlepony.unicopia.entity.player.MagicReserves.Bar;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
@ -89,37 +90,47 @@ public class UHud extends DrawableHelper {
|
|||
}
|
||||
|
||||
void renderManaRings(MatrixStack matrices) {
|
||||
|
||||
matrices.push();
|
||||
matrices.translate(24.5, 25.5, 0);
|
||||
|
||||
Bar mana = Pony.of(client.player).getMagicalReserves().getMana();
|
||||
Bar exer = Pony.of(client.player).getMagicalReserves().getEnergy();
|
||||
MagicReserves mana = Pony.of(client.player).getMagicalReserves();
|
||||
|
||||
renderRing(matrices, 17, 13, MathHelper.lerp(client.getTickDelta(), mana.getPrev(), mana.get()) / mana.getMax(), 0xFF88FF99);
|
||||
renderRing(matrices, 17, 13, MathHelper.lerp(client.getTickDelta(), exer.getPrev(), exer.get()) / exer.getMax(), 0xFF002299);
|
||||
double arcBegin = 0;
|
||||
|
||||
arcBegin = renderRing(matrices, 17, 13, 0, mana.getMana(), 0xFF88FF99);
|
||||
arcBegin = renderRing(matrices, 17, 13, arcBegin, mana.getEnergy(), 0xFF002299);
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
static void renderRing(MatrixStack matrices, double outerRadius, double innerRadius, double maxAngle, int color) {
|
||||
private double renderRing(MatrixStack matrices, double outerRadius, double innerRadius, double offsetAngle, Bar bar, int color) {
|
||||
double fill = bar.getPercentFill() * Math.PI * 2;
|
||||
|
||||
float f = (color >> 24 & 255) / 255.0F;
|
||||
float g = (color >> 16 & 255) / 255.0F;
|
||||
float h = (color >> 8 & 255) / 255.0F;
|
||||
float k = (color & 255) / 255.0F;
|
||||
renderArc(matrices, innerRadius, outerRadius, offsetAngle, fill, color, false);
|
||||
return offsetAngle + fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a colored arc.
|
||||
*
|
||||
* @param mirrorHorizontally Whether or not the arc must be mirrored across the horizontal plane. Will produce a bar that grows from the middle filling both sides.
|
||||
*/
|
||||
static void renderArc(MatrixStack matrices, double innerRadius, double outerRadius, double startAngle, double arcAngle, int color, boolean mirrorHorizontally) {
|
||||
float f = (color >> 24 & 255) / 255F;
|
||||
float g = (color >> 16 & 255) / 255F;
|
||||
float h = (color >> 8 & 255) / 255F;
|
||||
float k = (color & 255) / 255F;
|
||||
|
||||
final double num_rings = 300;
|
||||
double twoPi = Math.PI * 2;
|
||||
final double twoPi = Math.PI * 2;
|
||||
final double increment = twoPi / num_rings;
|
||||
|
||||
maxAngle *= twoPi;
|
||||
maxAngle = MathHelper.clamp(maxAngle, 0, twoPi - increment);
|
||||
|
||||
if (maxAngle < increment) {
|
||||
if (arcAngle < increment) {
|
||||
return;
|
||||
}
|
||||
|
||||
final double maxAngle = MathHelper.clamp(startAngle + arcAngle, 0, twoPi - increment);
|
||||
|
||||
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.disableTexture();
|
||||
|
@ -129,7 +140,11 @@ public class UHud extends DrawableHelper {
|
|||
|
||||
Matrix4f model = matrices.peek().getModel();
|
||||
|
||||
for (double angle = 0; angle >= -maxAngle; angle -= increment) {
|
||||
if (!mirrorHorizontally) {
|
||||
startAngle = -startAngle;
|
||||
}
|
||||
|
||||
for (double angle = startAngle; angle >= -maxAngle; angle -= increment) {
|
||||
// center
|
||||
bufferBuilder.vertex(model,
|
||||
(float)(innerRadius * Math.sin(angle)),
|
||||
|
|
|
@ -27,12 +27,6 @@ public interface MagicReserves {
|
|||
*/
|
||||
float get();
|
||||
|
||||
/**
|
||||
* Gets the previous value from the last tick.
|
||||
* Only updated when calling getPrev again.
|
||||
*/
|
||||
float getPrev();
|
||||
|
||||
/**
|
||||
* Sets the absolute value
|
||||
*/
|
||||
|
@ -62,8 +56,6 @@ public interface MagicReserves {
|
|||
/**
|
||||
* Get the maximum value this bar is allowed to contain
|
||||
*/
|
||||
default float getMax() {
|
||||
return 100F;
|
||||
}
|
||||
float getMax();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ public class ManaContainer implements MagicReserves {
|
|||
|
||||
public ManaContainer(Pony pony) {
|
||||
this.pony = pony;
|
||||
this.energy = new BarInst(Pony.ENERGY);
|
||||
this.exertion = new BarInst(Pony.EXERTION);
|
||||
this.mana = new BarInst(Pony.MANA);
|
||||
this.energy = new BarInst(Pony.ENERGY, 100F);
|
||||
this.exertion = new BarInst(Pony.EXERTION, 10F);
|
||||
this.mana = new BarInst(Pony.MANA, 100F);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,10 +35,11 @@ public class ManaContainer implements MagicReserves {
|
|||
class BarInst implements Bar {
|
||||
|
||||
private final TrackedData<Float> marker;
|
||||
private float prev;
|
||||
private final float max;
|
||||
|
||||
BarInst(TrackedData<Float> marker) {
|
||||
BarInst(TrackedData<Float> marker, float max) {
|
||||
this.marker = marker;
|
||||
this.max = max;
|
||||
pony.getOwner().getDataTracker().startTracking(marker, 0F);
|
||||
}
|
||||
|
||||
|
@ -47,16 +48,14 @@ public class ManaContainer implements MagicReserves {
|
|||
return pony.getOwner().getDataTracker().get(marker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPrev() {
|
||||
float value = prev;
|
||||
prev = get();
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(float value) {
|
||||
pony.getOwner().getDataTracker().set(marker, MathHelper.clamp(value, 0, getMax()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMax() {
|
||||
return max;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,11 +109,11 @@ public class PlayerPhysics extends EntityPhysics<Pony> implements Tickable, Moti
|
|||
if (ticksInAir > 100) {
|
||||
Bar mana = pony.getMagicalReserves().getMana();
|
||||
|
||||
mana.add((int)(-getHorizontalMotion(entity) * 100));
|
||||
mana.add((int)(-getHorizontalMotion(entity) * 50));
|
||||
|
||||
if (mana.getPercentFill() < 0.2) {
|
||||
pony.getMagicalReserves().getExertion().add(2);
|
||||
pony.getMagicalReserves().getEnergy().add(2);
|
||||
pony.getMagicalReserves().getEnergy().add(2 + (int)(getHorizontalMotion(entity) * 5));
|
||||
|
||||
if (mana.getPercentFill() < 0.1 && ticksInAir % 10 == 0) {
|
||||
float exhaustion = (0.3F * ticksInAir) / 70;
|
||||
|
|
Loading…
Reference in a new issue