mirror of
https://github.com/yawaflua/Informatis.git
synced 2026-02-04 10:24:21 +02:00
block progress bar
This commit is contained in:
@@ -1,69 +0,0 @@
|
||||
package informatis.ui.draws;
|
||||
|
||||
import arc.graphics.g2d.Draw;
|
||||
import arc.graphics.g2d.Fill;
|
||||
import arc.scene.style.TextureRegionDrawable;
|
||||
import mindustry.Vars;
|
||||
import mindustry.gen.Building;
|
||||
import mindustry.gen.Groups;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.world.Build;
|
||||
import mindustry.world.Tile;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import static informatis.SUtils.*;
|
||||
import static arc.Core.settings;
|
||||
|
||||
public class BlockDraw extends OverDraw {
|
||||
BlockDraw(String name, TextureRegionDrawable icon) {
|
||||
super(name, icon);
|
||||
registerOption("blockStatus");
|
||||
registerOption("blockBar");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
super.draw();
|
||||
|
||||
if(!enabled) return;
|
||||
Groups.build.each(b -> {
|
||||
if(!isInCamera(b.x, b.y, b.block.size/2f)) return;
|
||||
if(settings.getBool("blockStatus") && b.block.consumers.length > 0) {
|
||||
float multiplier = b.block.size > 1 ? 1.0F : 0.64F;
|
||||
float brcx = b.x + (float)(b.block.size * 8) / 2.0F - 8.0F * multiplier / 2.0F;
|
||||
float brcy = b.y - (float)(b.block.size * 8) / 2.0F + 8.0F * multiplier / 2.0F;
|
||||
Draw.z(71.0F);
|
||||
Draw.color(Pal.gray);
|
||||
Fill.square(brcx, brcy, 2.5F * multiplier, 45.0F);
|
||||
Draw.color(b.status().color);
|
||||
Fill.square(brcx, brcy, 1.5F * multiplier, 45.0F);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
});
|
||||
for (Tile tile : Vars.world.tiles) {
|
||||
if(!isInCamera(tile.worldx(), tile.worldy(), 8) || tile.build == null) continue;
|
||||
|
||||
Building b = tile.build;
|
||||
|
||||
if(settings.getBool("blockBar")) {
|
||||
float bx = b.x, by = b.y - b.block.size * 4 - 2;
|
||||
float width = b.block.size * 7.5f, height = 2;
|
||||
Draw.color(Pal.gray);
|
||||
Fill.quad(
|
||||
bx - width/2, by + height/2,
|
||||
bx - width/2, by - height/2,
|
||||
bx + width/2, by - height/2,
|
||||
bx + width/2, by + height/2);
|
||||
Draw.color(Pal.health);
|
||||
width = b.block.size * 7.5f - 0.5f; height = 2 - 0.5f;
|
||||
Fill.quad(
|
||||
bx - width/2, by + height/2,
|
||||
bx - width/2, by - height/2,
|
||||
bx - width/2 + width * b.healthf(), by - height/2,
|
||||
bx - width/2 + width * b.healthf(), by + height/2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,159 +0,0 @@
|
||||
package informatis.ui.draws;
|
||||
|
||||
import arc.graphics.Color;
|
||||
import arc.graphics.g2d.Draw;
|
||||
import arc.graphics.g2d.Lines;
|
||||
import arc.math.Angles;
|
||||
import arc.math.Mathf;
|
||||
import arc.scene.style.TextureRegionDrawable;
|
||||
import arc.struct.IntSeq;
|
||||
import arc.struct.Seq;
|
||||
import arc.util.Time;
|
||||
import arc.util.Tmp;
|
||||
import mindustry.core.Renderer;
|
||||
import mindustry.gen.Building;
|
||||
import mindustry.gen.Groups;
|
||||
import mindustry.graphics.Drawf;
|
||||
import mindustry.graphics.Layer;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.world.blocks.distribution.MassDriver;
|
||||
import mindustry.world.blocks.payloads.PayloadMassDriver;
|
||||
|
||||
import static arc.Core.atlas;
|
||||
import static arc.Core.settings;
|
||||
import static mindustry.Vars.*;
|
||||
import static informatis.SVars.*;
|
||||
|
||||
public class LinkDraw extends OverDraw {
|
||||
Seq<MassDriver.MassDriverBuild> linkedMasses = new Seq<>();
|
||||
Seq<PayloadMassDriver.PayloadDriverBuild> linkedPayloadMasses = new Seq<>();
|
||||
Seq<Building> linkedNodes = new Seq<>();
|
||||
|
||||
LinkDraw(String name, TextureRegionDrawable icon) {
|
||||
super(name, icon);
|
||||
registerOption("powerNode");
|
||||
registerOption("massDriver");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
if(!enabled) return;
|
||||
|
||||
Draw.z(Layer.max);
|
||||
if(target instanceof Building b){
|
||||
if(settings.getBool("powerNode") && enabled) {
|
||||
linkedNodes.clear();
|
||||
drawNodeLink(b);
|
||||
}
|
||||
if(settings.getBool("massDriver") && enabled) {
|
||||
if (target instanceof MassDriver.MassDriverBuild mass) {
|
||||
linkedMasses.clear();
|
||||
drawMassLink(mass);
|
||||
} else if (target instanceof PayloadMassDriver.PayloadDriverBuild mass) {
|
||||
linkedPayloadMasses.clear();
|
||||
drawMassPayloadLink(mass);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawMassPayloadLink(PayloadMassDriver.PayloadDriverBuild from){
|
||||
float sin = Mathf.absin(Time.time, 6f, 1f);
|
||||
|
||||
//call every mass drivers that link to this driver
|
||||
for(Building b : Groups.build) {
|
||||
if (b != from && b instanceof PayloadMassDriver.PayloadDriverBuild fromMass && world.build(fromMass.link) == from && !linkedPayloadMasses.contains(fromMass)) {
|
||||
linkedPayloadMasses.add(fromMass);
|
||||
drawMassPayloadLink(fromMass);
|
||||
}
|
||||
}
|
||||
|
||||
//get and draw line between this mass driver and linked one
|
||||
Building target = world.build(from.link);
|
||||
if(target instanceof PayloadMassDriver.PayloadDriverBuild targetDriver) {
|
||||
Tmp.v1.set(from.x + from.block.offset, from.y + from.block.offset).sub(targetDriver.x, targetDriver.y).limit(from.block.size * tilesize + sin + 0.5f);
|
||||
float x2 = from.x - Tmp.v1.x, y2 = from.y - Tmp.v1.y, x1 = targetDriver.x + Tmp.v1.x, y1 = targetDriver.y + Tmp.v1.y;
|
||||
int segs = (int) (targetDriver.dst(from.x, from.y) / tilesize);
|
||||
Lines.stroke(4f, Pal.gray);
|
||||
Lines.dashLine(x1, y1, x2, y2, segs);
|
||||
Lines.stroke(2f, Pal.placing);
|
||||
Lines.dashLine(x1, y1, x2, y2, segs);
|
||||
Lines.stroke(1f, Pal.accent);
|
||||
Drawf.circles(from.x, from.y, (from.tile.block().size / 2f + 1) * tilesize + sin - 2f, Pal.accent);
|
||||
Drawf.arrow(from.x, from.y, targetDriver.x, targetDriver.y, from.block.size * tilesize + sin, 4f + sin);
|
||||
for (Building shooter : from.waitingShooters) {
|
||||
Drawf.circles(shooter.x, shooter.y, (from.tile.block().size / 2f + 1) * tilesize + sin - 2f);
|
||||
Drawf.arrow(shooter.x, shooter.y, from.x, from.y, from.block.size * tilesize + sin, 4f + sin);
|
||||
}
|
||||
|
||||
//call method again when target links to another mass driver which isn't stored in array
|
||||
if(!linkedPayloadMasses.contains(targetDriver)) {
|
||||
linkedPayloadMasses.add(targetDriver);
|
||||
drawMassPayloadLink(targetDriver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawMassLink(MassDriver.MassDriverBuild from){
|
||||
float sin = Mathf.absin(Time.time, 6f, 1f);
|
||||
|
||||
//call every mass drivers that link to this driver
|
||||
for(Building b : Groups.build) {
|
||||
if (b != from && b instanceof MassDriver.MassDriverBuild fromMass && world.build(fromMass.link) == from && !linkedMasses.contains(fromMass)) {
|
||||
linkedMasses.add(fromMass);
|
||||
drawMassLink(fromMass);
|
||||
}
|
||||
}
|
||||
|
||||
//get and draw line between this mass driver and linked one
|
||||
Building target = world.build(from.link);
|
||||
if(target instanceof MassDriver.MassDriverBuild targetDriver) {
|
||||
Tmp.v1.set(from.x + from.block.offset, from.y + from.block.offset).sub(targetDriver.x, targetDriver.y).limit(from.block.size * tilesize + sin + 0.5f);
|
||||
float x2 = from.x - Tmp.v1.x, y2 = from.y - Tmp.v1.y, x1 = targetDriver.x + Tmp.v1.x, y1 = targetDriver.y + Tmp.v1.y;
|
||||
int segs = (int) (targetDriver.dst(from.x, from.y) / tilesize);
|
||||
Lines.stroke(4f, Pal.gray);
|
||||
Lines.dashLine(x1, y1, x2, y2, segs);
|
||||
Lines.stroke(2f, Pal.placing);
|
||||
Lines.dashLine(x1, y1, x2, y2, segs);
|
||||
Lines.stroke(1f, Pal.accent);
|
||||
Drawf.circles(from.x, from.y, (from.tile.block().size / 2f + 1) * tilesize + sin - 2f, Pal.accent);
|
||||
Drawf.arrow(from.x, from.y, targetDriver.x, targetDriver.y, from.block.size * tilesize + sin, 4f + sin);
|
||||
for (Building shooter : from.waitingShooters) {
|
||||
Drawf.circles(shooter.x, shooter.y, (from.tile.block().size / 2f + 1) * tilesize + sin - 2f);
|
||||
Drawf.arrow(shooter.x, shooter.y, from.x, from.y, from.block.size * tilesize + sin, 4f + sin);
|
||||
}
|
||||
|
||||
//call method again when target links to another mass driver which isn't stored in array
|
||||
if(!linkedMasses.contains(targetDriver)) {
|
||||
linkedMasses.add(targetDriver);
|
||||
drawMassLink(targetDriver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IntSeq getPowerLinkedBuilds(Building build) {
|
||||
IntSeq seq = new IntSeq(build.power.links);
|
||||
seq.addAll(build.proximity().mapInt(Building::pos));
|
||||
return seq;
|
||||
}
|
||||
|
||||
void drawNodeLink(Building node) {
|
||||
if(node.power == null) return;
|
||||
if(!linkedNodes.contains(node)) {
|
||||
linkedNodes.add(node);
|
||||
int[] builds = getPowerLinkedBuilds(node).items;
|
||||
for(int i : builds) {
|
||||
Building other = world.build(i);
|
||||
if(other == null || other.power == null) return;
|
||||
float angle1 = Angles.angle(node.x, node.y, other.x, other.y),
|
||||
vx = Mathf.cosDeg(angle1), vy = Mathf.sinDeg(angle1),
|
||||
len1 = node.block.size * tilesize / 2f - 1.5f, len2 = other.block.size * tilesize / 2f - 1.5f;
|
||||
Draw.color(Color.white, Color.valueOf("98ff98"), (1f - node.power.graph.getSatisfaction()) * 0.86f + Mathf.absin(3f, 0.1f));
|
||||
Draw.alpha(Renderer.laserOpacity);
|
||||
Drawf.laser(atlas.find("informatis-Slaser"), atlas.find("informatis-Slaser"), atlas.find("informatis-Slaser-end"), node.x + vx * len1, node.y + vy * len1, other.x - vx * len2, other.y - vy * len2, 0.25f);
|
||||
|
||||
drawNodeLink(other);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package informatis.ui.draws;
|
||||
|
||||
import arc.scene.Element;
|
||||
import arc.scene.style.TextureRegionDrawable;
|
||||
import arc.scene.ui.CheckBox;
|
||||
import arc.scene.ui.layout.Table;
|
||||
import arc.struct.Seq;
|
||||
import mindustry.ui.Styles;
|
||||
|
||||
import static arc.Core.bundle;
|
||||
import static arc.Core.settings;
|
||||
|
||||
public class OverDraw {
|
||||
public TextureRegionDrawable icon;
|
||||
public String name;
|
||||
public boolean enabled = false;
|
||||
public Seq<String> options = new Seq<>();
|
||||
|
||||
OverDraw(String name, TextureRegionDrawable icon) {
|
||||
this.name = name;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public void displayStats(Table parent) {
|
||||
if(options.isEmpty()) return;
|
||||
parent.background(Styles.squarei.up);
|
||||
parent.left();
|
||||
options.each(name-> parent
|
||||
.check(bundle.get("setting."+name+".name"), settings.getBool(name), b->settings.put(name, b))
|
||||
.tooltip(t->t.background(Styles.black8).add(bundle.get("setting."+name+".description")))
|
||||
.disabled(!enabled)
|
||||
.left().row());
|
||||
}
|
||||
|
||||
public void draw() {}
|
||||
|
||||
public <T> void onEnabled(T param) {
|
||||
if(param instanceof Table t) {
|
||||
for (int i = 0; i < t.getChildren().size; i++) {
|
||||
Element elem = t.getChildren().get(i);
|
||||
if (elem instanceof CheckBox cb) cb.setDisabled(!enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerOption(String name) {
|
||||
registerOption(name, settings.has(name) && settings.getBool(name));
|
||||
}
|
||||
|
||||
public void registerOption(String name, boolean defaults) {
|
||||
options.add(name);
|
||||
settings.put(name, defaults);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package informatis.ui.draws;
|
||||
|
||||
import mindustry.gen.Icon;
|
||||
|
||||
public class OverDraws {
|
||||
public static OverDraw range, link, unit, block, util;
|
||||
public static OverDraw[] all = {};
|
||||
|
||||
public static void init() {
|
||||
range = new RangeDraw("Range Draws", Icon.commandRally);
|
||||
link = new LinkDraw("Link Draws", Icon.line);
|
||||
unit = new UnitDraw("Unit Draws", Icon.units);
|
||||
block = new BlockDraw("Block Draws", Icon.crafting);
|
||||
util = new UtilDraw("Utils", Icon.github);
|
||||
all = new OverDraw[]{range, link, unit, block, util};
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
package informatis.ui.draws;
|
||||
|
||||
import arc.graphics.Color;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.graphics.gl.FrameBuffer;
|
||||
import arc.scene.style.TextureRegionDrawable;
|
||||
import mindustry.Vars;
|
||||
import mindustry.game.Team;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.Drawf;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.type.Weapon;
|
||||
import mindustry.world.blocks.defense.turrets.*;
|
||||
|
||||
import static informatis.SVars.turretRange;
|
||||
import static informatis.SUtils.*;
|
||||
import static arc.Core.*;
|
||||
import static mindustry.Vars.player;
|
||||
|
||||
public class RangeDraw extends OverDraw {
|
||||
FrameBuffer effectBuffer = new FrameBuffer();
|
||||
|
||||
RangeDraw(String name, TextureRegionDrawable icon) {
|
||||
super(name, icon);
|
||||
registerOption("blockRange");
|
||||
registerOption("unitRange");
|
||||
registerOption("aliceRange");
|
||||
registerOption("invalidRange");
|
||||
registerOption("airRange");
|
||||
registerOption("groundRange");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
if(!enabled) return;
|
||||
|
||||
Unit target = player.unit();
|
||||
|
||||
effectBuffer.resize(graphics.getWidth(), graphics.getHeight());
|
||||
for(Team team : Team.baseTeams) {
|
||||
Draw.drawRange(166 + (Team.baseTeams.length-team.id) * 3, 1, () -> effectBuffer.begin(Color.clear), () -> {
|
||||
effectBuffer.end();
|
||||
effectBuffer.blit(turretRange);
|
||||
});
|
||||
}
|
||||
|
||||
boolean includeBlock = settings.getBool("blockRange"),
|
||||
includeUnit = settings.getBool("unitRange"),
|
||||
includeInvalid = settings.getBool("invalidRange"),
|
||||
includeAir = settings.getBool("airRange"), isAir = target == null || target.isFlying(),
|
||||
includeGround = settings.getBool("groundRange"), isGround = target == null || !target.isFlying(),
|
||||
includeAlice = settings.getBool("aliceRange"),
|
||||
shader = settings.getBool("RangeShader");
|
||||
|
||||
Teamc selected = getTarget();
|
||||
if(selected instanceof BaseTurret.BaseTurretBuild turretBuild) {
|
||||
Drawf.dashCircle(turretBuild.x, turretBuild.y, turretBuild.range(), turretBuild.team.color);
|
||||
} else if(selected instanceof Unit unit) {
|
||||
Drawf.dashCircle(unit.x, unit.y, unit.range(), unit.team.color);
|
||||
}
|
||||
|
||||
if(includeBlock) {
|
||||
for(Building building : Groups.build) {
|
||||
if(!((includeAlice || player.team() != building.team)
|
||||
&& building instanceof BaseTurret.BaseTurretBuild turret && isInCamera(building.x, building.y, turret.range() * 2))) continue;
|
||||
|
||||
boolean valid = false;
|
||||
if (building instanceof Turret.TurretBuild turretBuild) {
|
||||
Turret block = (Turret) turretBuild.block;
|
||||
if ((building.team == player.team()
|
||||
|| (block.targetAir && isAir && includeAir)
|
||||
|| (block.targetGround && isGround && includeGround))
|
||||
&& turretBuild.hasAmmo() && turretBuild.canConsume()) valid = true;
|
||||
} else if (building instanceof TractorBeamTurret.TractorBeamBuild tractorBeamBuild) {
|
||||
TractorBeamTurret block = (TractorBeamTurret) tractorBeamBuild.block;
|
||||
if ((building.team == player.team()
|
||||
|| (block.targetAir && isAir && includeAir)
|
||||
|| (block.targetGround && isGround && includeGround))
|
||||
&& tractorBeamBuild.canConsume()) valid = true;
|
||||
}
|
||||
|
||||
if(!includeInvalid && !valid) continue;
|
||||
|
||||
//non-base teams are considered as crux
|
||||
int index = valid ? building.team.id > 5 ? 2 : building.team.id : 0;
|
||||
float range = turret.range();
|
||||
Draw.color(Team.baseTeams[index].color);
|
||||
if (shader) {
|
||||
Draw.z(166+(Team.baseTeams.length-index)*3);
|
||||
Fill.poly(building.x, building.y, Lines.circleVertices(range), range);
|
||||
} else Drawf.dashCircle(building.x, building.y, range, Team.baseTeams[index].color);
|
||||
Draw.reset();
|
||||
}
|
||||
}
|
||||
|
||||
if(includeUnit) {
|
||||
for(Unit unit : Groups.unit) {
|
||||
if(!((includeAlice || player.team() != unit.team) && isInCamera(unit.x, unit.y, unit.range() * 2))) continue;
|
||||
|
||||
boolean valid = false;
|
||||
if (target == null) valid = true;
|
||||
else if ((unit.team == player.team()
|
||||
|| (unit.type.targetAir && isAir && includeAir)
|
||||
|| (unit.type.targetGround && isGround && includeGround))
|
||||
&& unit.canShoot()) valid = true;
|
||||
|
||||
if(!includeInvalid && !valid) continue;
|
||||
|
||||
//non-base teams are considered as crux
|
||||
int index = valid ? unit.team.id > 5 ? 2 : unit.team.id : 0;
|
||||
float range = unit.range();
|
||||
Draw.color(Team.baseTeams[index].color.cpy().shiftSaturation(0.25f));
|
||||
if (shader) {
|
||||
Draw.z(166 + (Team.baseTeams.length - index) * 3);
|
||||
Fill.poly(unit.x, unit.y, Lines.circleVertices(range), range);
|
||||
} else Drawf.dashCircle(unit.x, unit.y, range, Team.baseTeams[index].color);
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
package informatis.ui.draws;
|
||||
|
||||
import informatis.SVars;
|
||||
import informatis.core.Pathfinder;
|
||||
import informatis.ui.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.style.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.Vars;
|
||||
import mindustry.ai.types.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.storage.*;
|
||||
|
||||
import static informatis.SUtils.*;
|
||||
import static arc.Core.settings;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class UnitDraw extends OverDraw {
|
||||
Seq<Tile> pathTiles = new Seq<>();
|
||||
Seq<Building> otherCores;
|
||||
|
||||
UnitDraw(String name, TextureRegionDrawable icon) {
|
||||
super(name, icon);
|
||||
registerOption("pathLine");
|
||||
registerOption("logicLine");
|
||||
registerOption("commandLine");
|
||||
registerOption("unitLine");
|
||||
registerOption("unitItem");
|
||||
registerOption("unitBar");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
if(!enabled) return;
|
||||
|
||||
Groups.unit.each(u -> {
|
||||
UnitController c = u.controller();
|
||||
|
||||
if(settings.getBool("commandLine") && c instanceof CommandAI com && com.hasCommand()) {
|
||||
Lines.stroke(1, u.team.color);
|
||||
Lines.line(u.x(), u.y(), com.targetPos.x, com.targetPos.y);
|
||||
}
|
||||
|
||||
if(settings.getBool("logicLine") && c instanceof LogicAI ai && (ai.control == LUnitControl.approach || ai.control == LUnitControl.move)) {
|
||||
Lines.stroke(1, u.team.color);
|
||||
Lines.line(u.x(), u.y(), ai.moveX, ai.moveY);
|
||||
Lines.stroke(0.5f + Mathf.absin(6f, 0.5f), Tmp.c1.set(Pal.logicOperations).lerp(Pal.sap, Mathf.absin(6f, 0.5f)));
|
||||
Lines.line(u.x(), u.y(), ai.controller.x, ai.controller.y);
|
||||
}
|
||||
|
||||
if(settings.getBool("unitLine") && u.team == state.rules.waveTeam && !u.type.flying && !(c instanceof MinerAI || c instanceof BuilderAI || c instanceof RepairAI || c instanceof DefenderAI || c instanceof FlyingAI)) {
|
||||
Lines.stroke(1, u.team.color);
|
||||
|
||||
pathTiles.clear();
|
||||
otherCores = Groups.build.copy(new Seq<>()).filter(b -> b instanceof CoreBlock.CoreBuild && b.team != u.team);
|
||||
getNextTile(u.tileOn(), SVars.pathfinder.getField(u.team, u.controller() instanceof SuicideAI ? 0 : u.pathType(), Pathfinder.fieldCore));
|
||||
for(int i = 0; i < pathTiles.size - 1; i++) {
|
||||
Tile from = pathTiles.get(i), to = pathTiles.get(i + 1);
|
||||
if(from == null || to == null) continue;
|
||||
Lines.line(from.worldx(), from.worldy(), to.worldx(), to.worldy());
|
||||
}
|
||||
}
|
||||
|
||||
if(isInCamera(u.x, u.y, u.hitSize)) {
|
||||
if (settings.getBool("unitBar")) FreeBar.draw(u);
|
||||
if (settings.getBool("unitItem") && !renderer.pixelator.enabled() && u.item() != null && u.itemTime > 0.01f)
|
||||
Fonts.outline.draw(String.valueOf(u.stack.amount),
|
||||
u.x + Angles.trnsx(u.rotation + 180f, u.type.itemOffsetY),
|
||||
u.y + Angles.trnsy(u.rotation + 180f, u.type.itemOffsetY) - 3,
|
||||
Pal.accent, 0.25f * u.itemTime / Scl.scl(1f), false, Align.center);
|
||||
}
|
||||
});
|
||||
|
||||
if(settings.getBool("pathLine")) {
|
||||
pathTiles.clear();
|
||||
otherCores = Groups.build.copy(new Seq<>()).filter(b -> b instanceof CoreBlock.CoreBuild && b.team != state.rules.waveTeam);
|
||||
spawner.getSpawns().each(t -> {
|
||||
for(int p = 0; p < 3; p++) {
|
||||
getNextTile(t, SVars.pathfinder.getField(state.rules.waveTeam, p, Pathfinder.fieldCore));
|
||||
}
|
||||
});
|
||||
Lines.stroke(1, state.rules.waveTeam.color);
|
||||
for(int i = 0; i < pathTiles.size - 1; i++) {
|
||||
Tile from = pathTiles.get(i), to = pathTiles.get(i + 1);
|
||||
if(from == null || to == null) continue;
|
||||
Lines.line(from.worldx(), from.worldy(), to.worldx(), to.worldy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void getNextTile(Tile tile, Pathfinder.Flowfield field) {
|
||||
Tile nextTile = SVars.pathfinder.getTargetTile(tile, field);
|
||||
pathTiles.add(nextTile);
|
||||
if(nextTile == tile || nextTile == null) return;
|
||||
getNextTile(nextTile, field);
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package informatis.ui.draws;
|
||||
|
||||
import arc.input.KeyCode;
|
||||
import arc.math.Angles;
|
||||
import arc.math.geom.Geometry;
|
||||
import arc.scene.style.TextureRegionDrawable;
|
||||
import mindustry.entities.Units;
|
||||
import mindustry.game.Team;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.logic.Ranged;
|
||||
import mindustry.world.blocks.ControlBlock;
|
||||
import mindustry.world.blocks.defense.turrets.Turret;
|
||||
|
||||
import static arc.Core.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class UtilDraw extends OverDraw {
|
||||
Teamc shotTarget;
|
||||
|
||||
UtilDraw(String name, TextureRegionDrawable icon) {
|
||||
super(name, icon);
|
||||
registerOption("autoShooting");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
super.draw();
|
||||
|
||||
if(!enabled) return;
|
||||
if(settings.getBool("autoShooting")) {
|
||||
Unit unit = player.unit();
|
||||
if (unit.type == null) return;
|
||||
boolean omni = unit.type.omniMovement;
|
||||
boolean validHealTarget = unit.type.canHeal && shotTarget instanceof Building b && b.isValid() && b.damaged() && shotTarget.team() == unit.team && shotTarget.within(unit, unit.type.range);
|
||||
boolean boosted = (unit instanceof Mechc && unit.isFlying());
|
||||
if ((unit.type != null && Units.invalidateTarget(shotTarget, unit, unit.type.range) && !validHealTarget) || state.isEditor()) {
|
||||
shotTarget = null;
|
||||
}
|
||||
|
||||
float mouseAngle = unit.angleTo(unit.aimX(), unit.aimY());
|
||||
boolean aimCursor = omni && player.shooting && unit.type.hasWeapons() && unit.type.faceTarget && !boosted && unit.type.rotateToBuilding;
|
||||
unit.lookAt(aimCursor ? mouseAngle : unit.prefRotation());
|
||||
|
||||
//update shooting if not building + not mining
|
||||
if(!player.unit().activelyBuilding() && player.unit().mineTile == null) {
|
||||
if(input.keyDown(KeyCode.mouseLeft)) {
|
||||
player.shooting = !boosted;
|
||||
unit.aim(player.mouseX = input.mouseWorldX(), player.mouseY = input.mouseWorldY());
|
||||
} else if(shotTarget == null) {
|
||||
player.shooting = false;
|
||||
if(unit instanceof BlockUnitUnit b) {
|
||||
if(b.tile() instanceof ControlBlock c && !c.shouldAutoTarget()) {
|
||||
Building build = b.tile();
|
||||
float range = build instanceof Ranged ? ((Ranged) build).range() : 0f;
|
||||
boolean targetGround = build instanceof Turret.TurretBuild && ((Turret) build.block).targetAir;
|
||||
boolean targetAir = build instanceof Turret.TurretBuild && ((Turret) build.block).targetGround;
|
||||
shotTarget = Units.closestTarget(build.team, build.x, build.y, range, u -> u.checkTarget(targetAir, targetGround), u -> targetGround);
|
||||
}
|
||||
else shotTarget = null;
|
||||
} else if(unit.type != null) {
|
||||
float range = unit.hasWeapons() ? unit.range() : 0f;
|
||||
shotTarget = Units.closestTarget(unit.team, unit.x, unit.y, range, u -> u.checkTarget(unit.type.targetAir, unit.type.targetGround), u -> unit.type.targetGround);
|
||||
|
||||
if(unit.type.canHeal && shotTarget == null) {
|
||||
shotTarget = Geometry.findClosest(unit.x, unit.y, indexer.getDamaged(Team.sharded));
|
||||
if (shotTarget != null && !unit.within(shotTarget, range)) {
|
||||
shotTarget = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.shooting = !boosted;
|
||||
unit.rotation(Angles.angle(unit.x, unit.y, shotTarget.x(), shotTarget.y()));
|
||||
unit.aim(shotTarget.x(), shotTarget.y());
|
||||
}
|
||||
}
|
||||
unit.controlWeapons(player.shooting && !boosted);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package informatis.ui.windows;
|
||||
|
||||
import informatis.ui.*;
|
||||
import informatis.ui.draws.*;
|
||||
import informatis.draws.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
|
||||
Reference in New Issue
Block a user