Fixed unit stats bars not being interpolated
This commit is contained in:
@@ -273,15 +273,15 @@ public class Renderer extends RendererModule{
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends DrawTrait> void drawAndInterpolate(EntityGroup<T> group){
|
||||
public <T extends DrawTrait> void drawAndInterpolate(EntityGroup<T> group){
|
||||
drawAndInterpolate(group, t -> true, DrawTrait::draw);
|
||||
}
|
||||
|
||||
private <T extends DrawTrait> void drawAndInterpolate(EntityGroup<T> group, Predicate<T> toDraw){
|
||||
public <T extends DrawTrait> void drawAndInterpolate(EntityGroup<T> group, Predicate<T> toDraw){
|
||||
drawAndInterpolate(group, toDraw, DrawTrait::draw);
|
||||
}
|
||||
|
||||
private <T extends DrawTrait> void drawAndInterpolate(EntityGroup<T> group, Predicate<T> toDraw, Consumer<T> drawer){
|
||||
public <T extends DrawTrait> void drawAndInterpolate(EntityGroup<T> group, Predicate<T> toDraw, Consumer<T> drawer){
|
||||
EntityDraw.drawWith(group, toDraw, t -> {
|
||||
float lastx = t.getX(), lasty = t.getY(), lastrot = 0f;
|
||||
|
||||
|
||||
@@ -281,6 +281,10 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
}
|
||||
}
|
||||
|
||||
public float getAmmoFraction(){
|
||||
return inventory.totalAmmo() / (float)inventory.ammoCapacity();
|
||||
}
|
||||
|
||||
public void drawUnder(){}
|
||||
public void drawOver(){}
|
||||
|
||||
|
||||
@@ -168,6 +168,11 @@ public class Drone extends FlyingUnit implements BuilderTrait {
|
||||
return isBuilding() ? placeDistance*2f : 30f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAmmoFraction() {
|
||||
return inventory.getItem().amount / (float)type.itemCapacity;
|
||||
}
|
||||
|
||||
protected void findItem(){
|
||||
TileEntity entity = getClosestCore();
|
||||
if(entity == null){
|
||||
|
||||
@@ -156,16 +156,11 @@ public class OverlayRenderer {
|
||||
}
|
||||
|
||||
if((!debug || showUI) && Settings.getBool("healthbars")){
|
||||
|
||||
for(TeamData ally : (debug ? state.teams.getTeams() : state.teams.getTeams(true))){
|
||||
for(Unit e : unitGroups[ally.team.ordinal()].all()){
|
||||
drawStats(e);
|
||||
}
|
||||
renderer.drawAndInterpolate(unitGroups[ally.team.ordinal()], u -> !u.isDead(), this::drawStats);
|
||||
}
|
||||
|
||||
for(Unit e : playerGroup.all()){
|
||||
drawStats(e);
|
||||
}
|
||||
renderer.drawAndInterpolate(playerGroup, u -> !u.isDead(), this::drawStats);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +177,7 @@ public class OverlayRenderer {
|
||||
|
||||
drawEncloser(x, y - 8f, 2f);
|
||||
drawBar(Palette.healthstats, x, y - 8f, unit.healthf());
|
||||
drawBar(Palette.ammo, x, y - 9f, unit.inventory.totalAmmo() / (float) unit.inventory.ammoCapacity());
|
||||
drawBar(Palette.ammo, x, y - 9f, unit.getAmmoFraction());
|
||||
}
|
||||
|
||||
void drawBar(Color color, float x, float y, float finion){
|
||||
|
||||
@@ -44,6 +44,7 @@ public class CoreBlock extends StorageBlock {
|
||||
|
||||
protected float supplyRadius = 50f;
|
||||
protected float supplyInterval = 5f;
|
||||
protected float droneRespawnDuration = 60*6;
|
||||
protected UnitType droneType = UnitTypes.drone;
|
||||
|
||||
public CoreBlock(String name) {
|
||||
@@ -155,7 +156,7 @@ public class CoreBlock extends StorageBlock {
|
||||
if(entity.currentUnit != null){
|
||||
entity.heat = Mathf.lerpDelta(entity.heat, 1f, 0.1f);
|
||||
entity.time += Timers.delta();
|
||||
entity.progress += 1f / Vars.respawnduration;
|
||||
entity.progress += 1f / (entity.currentUnit instanceof Player ? respawnduration : droneRespawnDuration);
|
||||
|
||||
//instant build for fast testing.
|
||||
if(debug){
|
||||
|
||||
Reference in New Issue
Block a user