Add boost bars to overdrive projectors (#4255)

* Add boost bars to overdrive projectors

* Add bar.boost to bundle

* Intelij lied to me
This commit is contained in:
Patrick 'Quezler' Mounier
2021-01-05 21:32:43 +01:00
committed by GitHub
parent 5516435619
commit f4bf8fd998
2 changed files with 19 additions and 7 deletions

View File

@@ -720,6 +720,7 @@ bar.corereq = Core Base Required
bar.drillspeed = Drill Speed: {0}/s bar.drillspeed = Drill Speed: {0}/s
bar.pumpspeed = Pump Speed: {0}/s bar.pumpspeed = Pump Speed: {0}/s
bar.efficiency = Efficiency: {0}% bar.efficiency = Efficiency: {0}%
bar.boost = Boost: {0}%
bar.powerbalance = Power: {0}/s bar.powerbalance = Power: {0}/s
bar.powerstored = Stored: {0}/{1} bar.powerstored = Stored: {0}/{1}
bar.poweramount = Power: {0} bar.poweramount = Power: {0}

View File

@@ -1,5 +1,6 @@
package mindustry.world.blocks.defense; package mindustry.world.blocks.defense;
import arc.*;
import arc.graphics.*; import arc.graphics.*;
import arc.graphics.g2d.*; import arc.graphics.g2d.*;
import arc.math.*; import arc.math.*;
@@ -9,6 +10,7 @@ import mindustry.annotations.Annotations.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.graphics.*; import mindustry.graphics.*;
import mindustry.logic.*; import mindustry.logic.*;
import mindustry.ui.*;
import mindustry.world.*; import mindustry.world.*;
import mindustry.world.meta.*; import mindustry.world.meta.*;
@@ -62,6 +64,12 @@ public class OverdriveProjector extends Block{
} }
} }
@Override
public void setBars(){
super.setBars();
bars.add("boost", (OverdriveBuild entity) -> new Bar(() -> Core.bundle.format("bar.boost", (int)(entity.realBoost() * 100)), () -> Pal.accent, () -> entity.realBoost() / (hasBoost ? speedBoost + speedBoostPhase : speedBoost)));
}
public class OverdriveBuild extends Building implements Ranged{ public class OverdriveBuild extends Building implements Ranged{
float heat; float heat;
float charge = Mathf.random(reload); float charge = Mathf.random(reload);
@@ -88,17 +96,20 @@ public class OverdriveProjector extends Block{
phaseHeat = Mathf.lerpDelta(phaseHeat, Mathf.num(cons.optionalValid()), 0.1f); phaseHeat = Mathf.lerpDelta(phaseHeat, Mathf.num(cons.optionalValid()), 0.1f);
} }
if(charge >= reload){
float realRange = range + phaseHeat * phaseRangeBoost;
charge = 0f;
indexer.eachBlock(this, realRange, other -> true, other -> other.applyBoost(realBoost(), reload + 1f));
}
if(timer(timerUse, useTime) && efficiency() > 0 && consValid()){ if(timer(timerUse, useTime) && efficiency() > 0 && consValid()){
consume(); consume();
} }
}
if(charge >= reload){ public float realBoost(){
float realRange = range + phaseHeat * phaseRangeBoost; return consValid() ? (speedBoost + phaseHeat * speedBoostPhase) * efficiency() : 0f;
float realBoost = (speedBoost + phaseHeat * speedBoostPhase) * efficiency();
charge = 0f;
indexer.eachBlock(this, realRange, other -> true, other -> other.applyBoost(realBoost, reload + 1f));
}
} }
@Override @Override