mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 12:09:27 +02:00
added forceProjector bar, clean up
This commit is contained in:
@@ -17,6 +17,7 @@ import mindustry.gen.*;
|
|||||||
import mindustry.graphics.Pal;
|
import mindustry.graphics.Pal;
|
||||||
import mindustry.ui.Fonts;
|
import mindustry.ui.Fonts;
|
||||||
import mindustry.world.blocks.ConstructBlock;
|
import mindustry.world.blocks.ConstructBlock;
|
||||||
|
import mindustry.world.blocks.defense.ForceProjector;
|
||||||
import mindustry.world.blocks.defense.turrets.*;
|
import mindustry.world.blocks.defense.turrets.*;
|
||||||
import mindustry.world.blocks.storage.*;
|
import mindustry.world.blocks.storage.*;
|
||||||
import mindustry.world.blocks.units.Reconstructor;
|
import mindustry.world.blocks.units.Reconstructor;
|
||||||
@@ -33,19 +34,6 @@ public class BarInfo {
|
|||||||
static Seq<Float> numbers = new Seq<>(new Float[]{0f,0f,0f,0f,0f,0f});
|
static Seq<Float> numbers = new Seq<>(new Float[]{0f,0f,0f,0f,0f,0f});
|
||||||
static Seq<Color> colors = new Seq<>(new Color[]{Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear});
|
static Seq<Color> colors = new Seq<>(new Color[]{Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear});
|
||||||
|
|
||||||
public static <T extends Teamc> Seq<String> returnStrings(T target){
|
|
||||||
getInfo(target);
|
|
||||||
return strings;
|
|
||||||
}
|
|
||||||
public static <T extends Teamc> Seq<Color> returnColors(T target){
|
|
||||||
getInfo(target);
|
|
||||||
return colors;
|
|
||||||
}
|
|
||||||
public static <T extends Teamc> Seq<Float> returnNumbers(T target){
|
|
||||||
getInfo(target);
|
|
||||||
return numbers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String format(float number){
|
public static String format(float number){
|
||||||
if(number >= 10000) return UI.formatAmount((long)number);
|
if(number >= 10000) return UI.formatAmount((long)number);
|
||||||
if(String.valueOf(number).split("[.]")[1].matches("0")) return String.valueOf(number).split("[.]")[0];
|
if(String.valueOf(number).split("[.]")[1].matches("0")) return String.valueOf(number).split("[.]")[0];
|
||||||
@@ -98,6 +86,15 @@ public class BarInfo {
|
|||||||
colors.set(1, Pal.darkerMetal);
|
colors.set(1, Pal.darkerMetal);
|
||||||
numbers.set(1, reconstruct.fraction());
|
numbers.set(1, reconstruct.fraction());
|
||||||
}
|
}
|
||||||
|
else if(target instanceof ForceProjector.ForceBuild){
|
||||||
|
ForceProjector.ForceBuild force = (ForceProjector.ForceBuild) target;
|
||||||
|
ForceProjector forceBlock = (ForceProjector) force.block;
|
||||||
|
float max = forceBlock.shieldHealth + forceBlock.phaseShieldBoost * force.phaseHeat;
|
||||||
|
strings.set(1, Core.bundle.format("shar-stat.shield", format(max-force.buildup), max));
|
||||||
|
colors.set(1, Pal.shield);
|
||||||
|
numbers.set(1, (max-force.buildup)/max);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if(target instanceof ItemTurret.ItemTurretBuild) {
|
if(target instanceof ItemTurret.ItemTurretBuild) {
|
||||||
ItemTurret.ItemTurretBuild turretBuild = (ItemTurret.ItemTurretBuild) target;
|
ItemTurret.ItemTurretBuild turretBuild = (ItemTurret.ItemTurretBuild) target;
|
||||||
|
|||||||
@@ -62,22 +62,29 @@ public class HudUi {
|
|||||||
int waveamount;
|
int waveamount;
|
||||||
int coreamount;
|
int coreamount;
|
||||||
|
|
||||||
Seq<String> strings = new Seq<>(new String[]{"","","","","",""});
|
|
||||||
Seq<Float> numbers = new Seq<>(new Float[]{0f,0f,0f,0f,0f,0f});
|
|
||||||
Seq<Color> colors = new Seq<>(new Color[]{Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear});
|
|
||||||
Seq<Color> lastColors = new Seq<>(new Color[]{Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear});
|
Seq<Color> lastColors = new Seq<>(new Color[]{Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear});
|
||||||
CoresItemsDisplay coreItems = new CoresItemsDisplay(Team.baseTeams);
|
CoresItemsDisplay coreItems = new CoresItemsDisplay(Team.baseTeams);
|
||||||
|
|
||||||
|
|
||||||
@Nullable Teamc target;
|
@Nullable Teamc target;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T extends Teamc> T getTarget(){
|
public <T extends Teamc> T getTarget(){
|
||||||
if(locked && lockedTarget != null) return (T) lockedTarget; //if there is locked target, return it first.
|
if(locked &&
|
||||||
Seq<Unit> units = Groups.unit.intersect(Core.input.mouseWorldX(), Core.input.mouseWorldY(), 4, 4);
|
(lockedTarget instanceof Unit && ((Unit) lockedTarget).dead) ||
|
||||||
if(units.size > 0) return (T) units.peek(); //if there is unit, return it.
|
(lockedTarget instanceof Building && ((Building) lockedTarget).dead)) {
|
||||||
else if(getTile() != null && getTile().build != null) return (T) getTile().build; //if there isn't unit but there is build, return it.
|
lockedTarget = null;
|
||||||
else if(player.unit() instanceof BlockUnitUnit && ((BlockUnitUnit)player.unit()).tile() != null) return (T)((BlockUnitUnit)player.unit()).tile();
|
locked = false;
|
||||||
|
}
|
||||||
|
if(locked && lockedTarget != null)
|
||||||
|
return (T) lockedTarget; //if there is locked target, return it first.
|
||||||
|
|
||||||
|
Seq<Unit> units = Groups.unit.intersect(Core.input.mouseWorldX(), Core.input.mouseWorldY(), 4, 4); // well, 0.5tile is enough to search them........ maybe?
|
||||||
|
if(units.size > 0)
|
||||||
|
return (T) units.peek(); //if there is unit, return it.
|
||||||
|
else if(getTile() != null && getTile().build != null)
|
||||||
|
return (T) getTile().build; //if there isn't unit but there is build, return it.
|
||||||
|
else if(player.unit() instanceof BlockUnitUnit && ((BlockUnitUnit)player.unit()).tile() != null)
|
||||||
|
return (T)((BlockUnitUnit)player.unit()).tile();
|
||||||
return (T) player.unit(); //if there are not unit and not build, return player.
|
return (T) player.unit(); //if there are not unit and not build, return player.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,27 +232,27 @@ public class HudUi {
|
|||||||
|
|
||||||
public void addBars(){
|
public void addBars(){
|
||||||
bars.clear();
|
bars.clear();
|
||||||
lastColors.set(2, colors.get(2));
|
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
bars.add(new SBar(
|
bars.add(new SBar(
|
||||||
() -> strings.get(i),
|
() -> BarInfo.strings.get(i),
|
||||||
() -> {
|
() -> {
|
||||||
if (colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
|
if (BarInfo.colors.get(i) != Color.clear) lastColors.set(i, BarInfo.colors.get(i));
|
||||||
return lastColors.get(i);
|
return lastColors.get(i);
|
||||||
},
|
},
|
||||||
() -> numbers.get(i)
|
() -> BarInfo.numbers.get(i)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
int i = 1;
|
int i = 1;
|
||||||
bars.add(new SBar(
|
bars.add(new SBar(
|
||||||
() -> strings.get(i),
|
() -> BarInfo.strings.get(i),
|
||||||
() -> {
|
() -> {
|
||||||
if (colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
|
if (BarInfo.colors.get(i) != Color.clear) lastColors.set(i, BarInfo.colors.get(i));
|
||||||
return lastColors.get(i);
|
return lastColors.get(i);
|
||||||
},
|
},
|
||||||
() -> numbers.get(i)
|
() -> BarInfo.numbers.get(i)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
bars.add(new Stack(){{
|
bars.add(new Stack(){{
|
||||||
@@ -253,12 +260,12 @@ public class HudUi {
|
|||||||
t.top().defaults().width(Scl.scl(23 * 8f)).height(Scl.scl(4f * 8f));
|
t.top().defaults().width(Scl.scl(23 * 8f)).height(Scl.scl(4f * 8f));
|
||||||
int i = 2;
|
int i = 2;
|
||||||
t.add(new SBar(
|
t.add(new SBar(
|
||||||
() -> strings.get(i),
|
() -> BarInfo.strings.get(i),
|
||||||
() -> {
|
() -> {
|
||||||
if(colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
|
if(BarInfo.colors.get(i) != Color.clear) lastColors.set(i, BarInfo.colors.get(i));
|
||||||
return lastColors.get(i);
|
return lastColors.get(i);
|
||||||
},
|
},
|
||||||
() -> numbers.get(i)
|
() -> BarInfo.numbers.get(i)
|
||||||
)).growX().left();
|
)).growX().left();
|
||||||
}));
|
}));
|
||||||
add(new Table(){{
|
add(new Table(){{
|
||||||
@@ -333,12 +340,12 @@ public class HudUi {
|
|||||||
{
|
{
|
||||||
int i = 3;
|
int i = 3;
|
||||||
bars.add(new SBar(
|
bars.add(new SBar(
|
||||||
() -> strings.get(i),
|
() -> BarInfo.strings.get(i),
|
||||||
() -> {
|
() -> {
|
||||||
if (colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
|
if (BarInfo.colors.get(i) != Color.clear) lastColors.set(i, BarInfo.colors.get(i));
|
||||||
return lastColors.get(i);
|
return lastColors.get(i);
|
||||||
},
|
},
|
||||||
() -> numbers.get(i)
|
() -> BarInfo.numbers.get(i)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,12 +353,12 @@ public class HudUi {
|
|||||||
{
|
{
|
||||||
int i = 4;
|
int i = 4;
|
||||||
bars.add(new SBar(
|
bars.add(new SBar(
|
||||||
() -> strings.get(i),
|
() -> BarInfo.strings.get(i),
|
||||||
() -> {
|
() -> {
|
||||||
if (colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
|
if (BarInfo.colors.get(i) != Color.clear) lastColors.set(i, BarInfo.colors.get(i));
|
||||||
return lastColors.get(i);
|
return lastColors.get(i);
|
||||||
},
|
},
|
||||||
() -> numbers.get(i)
|
() -> BarInfo.numbers.get(i)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,12 +368,12 @@ public class HudUi {
|
|||||||
|
|
||||||
int i = 5;
|
int i = 5;
|
||||||
t.add(new SBar(
|
t.add(new SBar(
|
||||||
() -> strings.get(i),
|
() -> BarInfo.strings.get(i),
|
||||||
() -> {
|
() -> {
|
||||||
if (colors.get(i) != Color.clear) lastColors.set(i, colors.get(i));
|
if (BarInfo.colors.get(i) != Color.clear) lastColors.set(i, BarInfo.colors.get(i));
|
||||||
return lastColors.get(i);
|
return lastColors.get(i);
|
||||||
},
|
},
|
||||||
() -> numbers.get(i)
|
() -> BarInfo.numbers.get(i)
|
||||||
)).growX().left();
|
)).growX().left();
|
||||||
}));
|
}));
|
||||||
add(new Table(t -> {
|
add(new Table(t -> {
|
||||||
@@ -569,9 +576,7 @@ public class HudUi {
|
|||||||
}).padRight(Scl.scl(24 * 8f));
|
}).padRight(Scl.scl(24 * 8f));
|
||||||
table.row();
|
table.row();
|
||||||
table.update(() -> {
|
table.update(() -> {
|
||||||
strings = BarInfo.returnStrings(getTarget());
|
BarInfo.getInfo(target);
|
||||||
numbers = BarInfo.returnNumbers(getTarget());
|
|
||||||
colors = BarInfo.returnColors(getTarget());
|
|
||||||
if(getTarget() instanceof Turret.TurretBuild){
|
if(getTarget() instanceof Turret.TurretBuild){
|
||||||
if(((Turret.TurretBuild) getTarget()).charging) charge += Time.delta;
|
if(((Turret.TurretBuild) getTarget()).charging) charge += Time.delta;
|
||||||
else charge = 0f;
|
else charge = 0f;
|
||||||
|
|||||||
Reference in New Issue
Block a user