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

@@ -1,5 +1,6 @@
package mindustry.world.blocks.defense;
import arc.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
@@ -9,6 +10,7 @@ import mindustry.annotations.Annotations.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.logic.*;
import mindustry.ui.*;
import mindustry.world.*;
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{
float heat;
float charge = Mathf.random(reload);
@@ -88,17 +96,20 @@ public class OverdriveProjector extends Block{
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()){
consume();
}
}
if(charge >= reload){
float realRange = range + phaseHeat * phaseRangeBoost;
float realBoost = (speedBoost + phaseHeat * speedBoostPhase) * efficiency();
charge = 0f;
indexer.eachBlock(this, realRange, other -> true, other -> other.applyBoost(realBoost, reload + 1f));
}
public float realBoost(){
return consValid() ? (speedBoost + phaseHeat * speedBoostPhase) * efficiency() : 0f;
}
@Override