mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 03:59:26 +02:00
pathline done
This commit is contained in:
@@ -20,8 +20,8 @@ shar-stat.waveStatus = [lightgray]Status:[]
|
||||
shar-stat.waveItem = [lightgray]Item:[]
|
||||
|
||||
#Settings
|
||||
setting.spathfinder.name = Enable Pathfinder overdrawing
|
||||
setting.spathfinder.description = shift + q: on/off\n\nshift + 1: Dispslay ground unit path\n\nshift + 2: Dispslay leg unit path\n\nshift + 3: Dispslay naval unit path
|
||||
setting.unitlinelimit.name = UnitLines limit
|
||||
setting.unitlinelimit.description = lots of drawing unitlines drop fps. you need to set lines limit with your device environment.
|
||||
|
||||
setting.wavesetting.name = Wave UI Setting
|
||||
setting.opacitysetting.name = Opacity Setting
|
||||
|
||||
@@ -20,8 +20,8 @@ shar-stat.waveStatus = [lightgray]상태이상:[]
|
||||
shar-stat.waveItem = [lightgray]아이템:[]
|
||||
|
||||
# Settings
|
||||
setting.spathfinder.name = 길찾기 활성화
|
||||
setting.spathfinder.description = shift + q: on/off\n\nshift + 1: 지상유닛 경로 표시\n\nshift + 2: 다리유닛 경로 표시\n\nshift + 3: 해상유닛 경로 표시
|
||||
setting.unitlinelimit.name = 유닛선 제한
|
||||
setting.unitlinelimit.description = 다수의 유닛선은 fps를 떨어트립니다. 기기 환경에 맞추어 조절해야 합니다.
|
||||
|
||||
setting.wavesetting.name = 단계 UI 설정
|
||||
setting.opacitysetting.name = 투명도 설정
|
||||
|
||||
@@ -20,6 +20,6 @@ public class SVars {
|
||||
public static TextureRegion clear = atlas.find("clear");
|
||||
public static TextureRegion error = atlas.find("error");
|
||||
public static float modUiScale = settings.getInt("infoUiScale") / 100f == 0 ? 1 : settings.getInt("infoUiScale") / 100f;
|
||||
|
||||
public static boolean pathLine = false, unitLine = false, logicLine = false;
|
||||
public static Seq<Tile> pathTiles = new Seq<>();
|
||||
}
|
||||
|
||||
@@ -424,6 +424,38 @@ public class HudUi {
|
||||
}
|
||||
});
|
||||
});
|
||||
Table pathlineTable = new Table(t -> {
|
||||
t.right();
|
||||
|
||||
Button pathBtn = new ImageButton(new ScaledNinePatchDrawable(new NinePatch(Icon.grid.getRegion()), 0.5f), Styles.clearToggleTransi);
|
||||
Button unitBtn = new ImageButton(new ScaledNinePatchDrawable(new NinePatch(Icon.grid.getRegion()), 0.5f), Styles.clearToggleTransi);
|
||||
Button logicBtn = new ImageButton(new ScaledNinePatchDrawable(new NinePatch(Icon.grid.getRegion()), 0.5f), Styles.clearToggleTransi);
|
||||
|
||||
pathBtn.addListener(new Tooltip(l -> l.label(() -> "PathLine " + (pathLine ? "[accent]Enabled[]" : "[gray]Disabled[]"))){{allowMobile = true;}});
|
||||
pathBtn.clicked(() -> {
|
||||
pathLine = !pathLine;
|
||||
pathBtn.setChecked(pathLine);
|
||||
});
|
||||
|
||||
unitBtn.addListener(new Tooltip(l -> l.label(() -> "UnitLine " + (unitLine ? "[accent]Enabled[]" : "[gray]Disabled[]"))){{allowMobile = true;}});
|
||||
unitBtn.clicked(() -> {
|
||||
unitLine = !unitLine;
|
||||
unitBtn.setChecked(unitLine);
|
||||
});
|
||||
|
||||
logicBtn.addListener(new Tooltip(l -> l.label(() -> "LogicLine " + (logicLine ? "[accent]Enabled[]" : "[gray]Disabled[]"))){{allowMobile = true;}});
|
||||
logicBtn.clicked(() -> {
|
||||
logicLine = !logicLine;
|
||||
logicBtn.setChecked(logicLine);
|
||||
});
|
||||
|
||||
t.add(pathBtn).padLeft(16).size(24);
|
||||
t.row();
|
||||
t.add(unitBtn).padLeft(16).size(24);
|
||||
t.row();
|
||||
t.add(logicBtn).padLeft(16).size(24);
|
||||
});
|
||||
|
||||
Table waveTable = (Table)((Group)((Group)ui.hudGroup.getChildren().get(5)) //HudFragment#118, name: overlaymarker
|
||||
.getChildren().get(mobile ? 2 : 0)) //HudFragment#192, name: wave/editor
|
||||
.getChildren().get(0); //HudFragment#196, name: waves
|
||||
@@ -432,7 +464,7 @@ public class HudUi {
|
||||
waveTable.removeChild(statusTable);
|
||||
table.row();
|
||||
statusTable.top();
|
||||
table.stack(waveInfoTable, statusTable);
|
||||
table.stack(waveInfoTable, statusTable, pathlineTable);
|
||||
}
|
||||
|
||||
public void addTable(){
|
||||
@@ -735,7 +767,7 @@ public class HudUi {
|
||||
for(StatusEffect effect : content.statusEffects()){
|
||||
if(applied.get(effect.id) && !effect.isHidden()){
|
||||
t.image(effect.uiIcon).size(iconSmall).get().addListener(new Tooltip(l -> l.label(() ->
|
||||
effect.localizedName + " [lightgray]" + UI.formatTime(st.getDuration(effect))).style(Styles.outlineLabel)));
|
||||
effect.localizedName + " [lightgray]" + UI.formatTime(st.getDuration(effect))).style(Styles.outlineLabel)){{allowMobile = true;}});
|
||||
}
|
||||
}
|
||||
statuses.set(applied);
|
||||
@@ -843,7 +875,7 @@ public class HudUi {
|
||||
Label label2 = new Label(()->getTarget() == null ? "(" + 0 + ", " + 0 + ")" : "(" + Strings.fixed(getTarget().x() / tilesize, 2) + ", " + Strings.fixed(getTarget().y() / tilesize, 2) + ")");
|
||||
label2.setFontScale(modUiScale);
|
||||
to.add(label2);
|
||||
})));
|
||||
})){{allowMobile = true;}});
|
||||
tt.update(()->tt.setBackground(((NinePatchDrawable)Tex.underline2).tint(getTarget().isNull() ? Color.gray : getTarget().team().color)));
|
||||
});
|
||||
t.row();
|
||||
@@ -1011,7 +1043,7 @@ public class HudUi {
|
||||
}).size(iconMed * Scl.scl(modUiScale));
|
||||
to.row();
|
||||
}
|
||||
})));
|
||||
})){{allowMobile = true;}});
|
||||
});
|
||||
if(++row % 4 == 0) tx.row();
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import mindustry.*;
|
||||
import mindustry.ai.Pathfinder;
|
||||
import mindustry.ai.types.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.core.Logic;
|
||||
import mindustry.entities.units.AIController;
|
||||
import mindustry.entities.units.UnitCommand;
|
||||
import mindustry.entities.units.UnitController;
|
||||
@@ -19,11 +20,14 @@ import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.logic.LUnitControl;
|
||||
import mindustry.mod.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.defense.turrets.*;
|
||||
import mindustry.world.blocks.storage.CoreBlock;
|
||||
import mindustry.world.blocks.units.CommandCenter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static UnitInfo.SVars.*;
|
||||
@@ -32,14 +36,14 @@ import static mindustry.Vars.*;
|
||||
|
||||
public class Main extends Mod {
|
||||
int otherCores;
|
||||
boolean groundValid = false, legValid = false, navalValid = false;
|
||||
|
||||
public Tile getNextTile(Tile tile, int cost, Team team, int finder) {
|
||||
Pathfinder.Flowfield field = pathfinder.getField(team, cost, finder);
|
||||
Pathfinder.Flowfield field = pathfinder.getField(team, cost, Mathf.clamp(finder, 0, 1));
|
||||
Tile tile1 = pathfinder.getTargetTile(tile, field);
|
||||
pathTiles.add(tile1);
|
||||
if(otherCores != Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != team)
|
||||
|| tile1 == tile || tile1 == null || tile1.build instanceof CoreBlock.CoreBuild) //so many ififififififif.
|
||||
if(tile1 == tile || tile1 == null ||
|
||||
(finder == 0 && (otherCores != Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != team) || tile1.build instanceof CoreBlock.CoreBuild)) ||
|
||||
(finder == 1 && tile1.build instanceof CommandCenter.CommandBuild)) //so many ififififififif.
|
||||
return tile1;
|
||||
return getNextTile(tile1, cost, team, finder);
|
||||
}
|
||||
@@ -77,45 +81,48 @@ public class Main extends Mod {
|
||||
});
|
||||
|
||||
Events.run(Trigger.draw, () -> {
|
||||
if((input.keyDown(KeyCode.shiftRight) || input.keyDown(KeyCode.shiftLeft))) {
|
||||
if(input.keyTap(KeyCode.q)) settings.put("spathfinder", !settings.getBool("spathfinder"));
|
||||
if(input.keyTap(KeyCode.num1)) groundValid = !groundValid;
|
||||
if(input.keyTap(KeyCode.num2)) legValid = !legValid;
|
||||
if(input.keyTap(KeyCode.num3)) navalValid = !navalValid;
|
||||
int[] units = {0};
|
||||
Groups.unit.each(u -> {
|
||||
Team team = u.team;
|
||||
otherCores = Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != team);
|
||||
UnitController c = u.controller();
|
||||
UnitCommand com = team.data().command;
|
||||
|
||||
if(c instanceof LogicAI ai){
|
||||
if(logicLine && (ai.control == LUnitControl.approach || ai.control == LUnitControl.move)) {
|
||||
Lines.stroke(1, 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);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(settings.getBool("spathfinder")) {
|
||||
Groups.unit.each(u -> {
|
||||
Team enemyTeam = u.team;
|
||||
otherCores = Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != enemyTeam);
|
||||
if(otherCores == 0) return; //must have target core
|
||||
|
||||
UnitController c = u.controller();
|
||||
UnitCommand com = enemyTeam.data().command;
|
||||
if(u.type.flying || //not flying
|
||||
if(++units[0] > settings.getInt("unitlinelimit") || //prevent lag
|
||||
!unitLine || //disabled
|
||||
u.type.flying || //not flying
|
||||
c instanceof MinerAI || //not mono
|
||||
c instanceof BuilderAI || //not poly
|
||||
c instanceof RepairAI || //not mega
|
||||
c instanceof DefenderAI || //not oct
|
||||
c instanceof FormationAI || //not commanded unit by player
|
||||
c instanceof LogicAI || //not controlled unit by logic
|
||||
c instanceof FlyingAI ||
|
||||
com == UnitCommand.idle) return;
|
||||
c instanceof FlyingAI || //not flying anyway
|
||||
com == UnitCommand.idle) return; //not idle
|
||||
|
||||
getNextTile(u.tileOn(), u.pathType(), enemyTeam, com == UnitCommand.attack ? Pathfinder.fieldCore : Pathfinder.fieldRally);
|
||||
getNextTile(u.tileOn(), u.pathType(), team, com.ordinal());
|
||||
pathTiles.filter(Objects::nonNull);
|
||||
for(int i = 1; i < pathTiles.size; i++) {
|
||||
if(i + 1 >= pathTiles.size) continue; //prevent IndexOutException
|
||||
Tile tile1 = pathTiles.get(i);
|
||||
Tile tile2 = pathTiles.get(i + 1);
|
||||
Draw.z(Layer.overlayUI);
|
||||
Lines.stroke(1, enemyTeam.color);
|
||||
Lines.stroke(1, team.color);
|
||||
Lines.line(tile1.worldx(), tile1.worldy(), tile2.worldx(), tile2.worldy());
|
||||
}
|
||||
pathTiles.clear();
|
||||
});
|
||||
|
||||
spawner.getSpawns().each(t -> {
|
||||
if(pathLine) spawner.getSpawns().each(t -> {
|
||||
Team enemyTeam = state.rules.waveTeam;
|
||||
for(int p = 0; p < 3; p++) {
|
||||
otherCores = Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != enemyTeam);
|
||||
@@ -135,7 +142,6 @@ public class Main extends Mod {
|
||||
}
|
||||
});
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
if(settings.getBool("blockstatus")) Groups.build.each(build -> {
|
||||
if(Vars.player != null && Vars.player.team() == build.team) return;
|
||||
|
||||
@@ -289,7 +289,7 @@ public class SettingS {
|
||||
addGraphicDialogSetting("opacitysetting", opacitySeq, opacityTable);
|
||||
*/
|
||||
|
||||
addGraphicCheckSetting("spathfinder", true);
|
||||
addGraphicSlideSetting("unitlinelimit", 50, 50, 250, 10, s -> s + "units");
|
||||
addGraphicSlideSetting("infoUiScale", 100, 50, 100, 5, s -> s + "%");
|
||||
addGraphicSlideSetting("coreItemCheckRate", 60, 6, 180, 6, s -> Strings.fixed(s/60f,1) + "sec");
|
||||
addGraphicCheckSetting("pastwave", false);
|
||||
|
||||
Reference in New Issue
Block a user