mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 19:46:42 +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.Abilities;
|
||||||
import com.minelittlepony.unicopia.ability.AbilityDispatcher;
|
import com.minelittlepony.unicopia.ability.AbilityDispatcher;
|
||||||
import com.minelittlepony.unicopia.ability.AbilitySlot;
|
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.MagicReserves.Bar;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
@ -89,37 +90,47 @@ public class UHud extends DrawableHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderManaRings(MatrixStack matrices) {
|
void renderManaRings(MatrixStack matrices) {
|
||||||
|
|
||||||
matrices.push();
|
matrices.push();
|
||||||
matrices.translate(24.5, 25.5, 0);
|
matrices.translate(24.5, 25.5, 0);
|
||||||
|
|
||||||
Bar mana = Pony.of(client.player).getMagicalReserves().getMana();
|
MagicReserves mana = Pony.of(client.player).getMagicalReserves();
|
||||||
Bar exer = Pony.of(client.player).getMagicalReserves().getEnergy();
|
|
||||||
|
|
||||||
renderRing(matrices, 17, 13, MathHelper.lerp(client.getTickDelta(), mana.getPrev(), mana.get()) / mana.getMax(), 0xFF88FF99);
|
double arcBegin = 0;
|
||||||
renderRing(matrices, 17, 13, MathHelper.lerp(client.getTickDelta(), exer.getPrev(), exer.get()) / exer.getMax(), 0xFF002299);
|
|
||||||
|
arcBegin = renderRing(matrices, 17, 13, 0, mana.getMana(), 0xFF88FF99);
|
||||||
|
arcBegin = renderRing(matrices, 17, 13, arcBegin, mana.getEnergy(), 0xFF002299);
|
||||||
|
|
||||||
matrices.pop();
|
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;
|
renderArc(matrices, innerRadius, outerRadius, offsetAngle, fill, color, false);
|
||||||
float g = (color >> 16 & 255) / 255.0F;
|
return offsetAngle + fill;
|
||||||
float h = (color >> 8 & 255) / 255.0F;
|
}
|
||||||
float k = (color & 255) / 255.0F;
|
|
||||||
|
/**
|
||||||
|
* 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;
|
final double num_rings = 300;
|
||||||
double twoPi = Math.PI * 2;
|
final double twoPi = Math.PI * 2;
|
||||||
final double increment = twoPi / num_rings;
|
final double increment = twoPi / num_rings;
|
||||||
|
|
||||||
maxAngle *= twoPi;
|
if (arcAngle < increment) {
|
||||||
maxAngle = MathHelper.clamp(maxAngle, 0, twoPi - increment);
|
|
||||||
|
|
||||||
if (maxAngle < increment) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final double maxAngle = MathHelper.clamp(startAngle + arcAngle, 0, twoPi - increment);
|
||||||
|
|
||||||
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
|
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.disableTexture();
|
RenderSystem.disableTexture();
|
||||||
|
@ -129,7 +140,11 @@ public class UHud extends DrawableHelper {
|
||||||
|
|
||||||
Matrix4f model = matrices.peek().getModel();
|
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
|
// center
|
||||||
bufferBuilder.vertex(model,
|
bufferBuilder.vertex(model,
|
||||||
(float)(innerRadius * Math.sin(angle)),
|
(float)(innerRadius * Math.sin(angle)),
|
||||||
|
|
|
@ -27,12 +27,6 @@ public interface MagicReserves {
|
||||||
*/
|
*/
|
||||||
float get();
|
float get();
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the previous value from the last tick.
|
|
||||||
* Only updated when calling getPrev again.
|
|
||||||
*/
|
|
||||||
float getPrev();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the absolute value
|
* Sets the absolute value
|
||||||
*/
|
*/
|
||||||
|
@ -62,8 +56,6 @@ public interface MagicReserves {
|
||||||
/**
|
/**
|
||||||
* Get the maximum value this bar is allowed to contain
|
* Get the maximum value this bar is allowed to contain
|
||||||
*/
|
*/
|
||||||
default float getMax() {
|
float getMax();
|
||||||
return 100F;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,9 @@ public class ManaContainer implements MagicReserves {
|
||||||
|
|
||||||
public ManaContainer(Pony pony) {
|
public ManaContainer(Pony pony) {
|
||||||
this.pony = pony;
|
this.pony = pony;
|
||||||
this.energy = new BarInst(Pony.ENERGY);
|
this.energy = new BarInst(Pony.ENERGY, 100F);
|
||||||
this.exertion = new BarInst(Pony.EXERTION);
|
this.exertion = new BarInst(Pony.EXERTION, 10F);
|
||||||
this.mana = new BarInst(Pony.MANA);
|
this.mana = new BarInst(Pony.MANA, 100F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,10 +35,11 @@ public class ManaContainer implements MagicReserves {
|
||||||
class BarInst implements Bar {
|
class BarInst implements Bar {
|
||||||
|
|
||||||
private final TrackedData<Float> marker;
|
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.marker = marker;
|
||||||
|
this.max = max;
|
||||||
pony.getOwner().getDataTracker().startTracking(marker, 0F);
|
pony.getOwner().getDataTracker().startTracking(marker, 0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,16 +48,14 @@ public class ManaContainer implements MagicReserves {
|
||||||
return pony.getOwner().getDataTracker().get(marker);
|
return pony.getOwner().getDataTracker().get(marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getPrev() {
|
|
||||||
float value = prev;
|
|
||||||
prev = get();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(float value) {
|
public void set(float value) {
|
||||||
pony.getOwner().getDataTracker().set(marker, MathHelper.clamp(value, 0, getMax()));
|
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) {
|
if (ticksInAir > 100) {
|
||||||
Bar mana = pony.getMagicalReserves().getMana();
|
Bar mana = pony.getMagicalReserves().getMana();
|
||||||
|
|
||||||
mana.add((int)(-getHorizontalMotion(entity) * 100));
|
mana.add((int)(-getHorizontalMotion(entity) * 50));
|
||||||
|
|
||||||
if (mana.getPercentFill() < 0.2) {
|
if (mana.getPercentFill() < 0.2) {
|
||||||
pony.getMagicalReserves().getExertion().add(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) {
|
if (mana.getPercentFill() < 0.1 && ticksInAir % 10 == 0) {
|
||||||
float exhaustion = (0.3F * ticksInAir) / 70;
|
float exhaustion = (0.3F * ticksInAir) / 70;
|
||||||
|
|
Loading…
Reference in a new issue