mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 12:09:27 +02:00
also node link
This commit is contained in:
@@ -117,7 +117,7 @@ public class OverDrawer {
|
|||||||
for(int i = 0; i < pathTiles.size; i++) {
|
for(int i = 0; i < pathTiles.size; i++) {
|
||||||
Tile from = pathTiles.get(i);
|
Tile from = pathTiles.get(i);
|
||||||
Tile to = pathTiles.get(i + 1);
|
Tile to = pathTiles.get(i + 1);
|
||||||
if(!isInCamera(from.x, from.y)) continue;
|
if(isOutCamera(from.x, from.y)) continue;
|
||||||
Lines.line(from.worldx(), from.worldy(), to.worldx(), to.worldy());
|
Lines.line(from.worldx(), from.worldy(), to.worldx(), to.worldy());
|
||||||
}
|
}
|
||||||
pathTiles.clear();
|
pathTiles.clear();
|
||||||
@@ -144,7 +144,7 @@ public class OverDrawer {
|
|||||||
for(int i = 0; i < pathTiles.size; i++) {
|
for(int i = 0; i < pathTiles.size; i++) {
|
||||||
Tile from = pathTiles.get(i);
|
Tile from = pathTiles.get(i);
|
||||||
Tile to = pathTiles.get(i + 1);
|
Tile to = pathTiles.get(i + 1);
|
||||||
if(!isInCamera(from.x, from.y)) continue;
|
if(isOutCamera(from.x, from.y)) continue;
|
||||||
Lines.line(from.worldx(), from.worldy(), to.worldx(), to.worldy());
|
Lines.line(from.worldx(), from.worldy(), to.worldx(), to.worldy());
|
||||||
}
|
}
|
||||||
pathTiles.clear();
|
pathTiles.clear();
|
||||||
@@ -156,6 +156,7 @@ public class OverDrawer {
|
|||||||
|
|
||||||
if(settings.getBool("linkedNode") && target instanceof Building node){
|
if(settings.getBool("linkedNode") && target instanceof Building node){
|
||||||
linkedNodes.clear();
|
linkedNodes.clear();
|
||||||
|
Draw.z(Layer.max);
|
||||||
drawNodeLink(node);
|
drawNodeLink(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,8 +217,8 @@ public class OverDrawer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isInCamera(float x, float y) {
|
static boolean isOutCamera(float x, float y) {
|
||||||
return isInCamera(x, y, 0);
|
return !isInCamera(x, y, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isInCamera(float x, float y, float size) {
|
static boolean isInCamera(float x, float y, float size) {
|
||||||
@@ -310,30 +311,27 @@ public class OverDrawer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Seq<Building> getPowerLinkedBuilds(Building build) {
|
public static IntSeq getPowerLinkedBuilds(Building build) {
|
||||||
linkedBuilds.clear();
|
IntSeq seq = new IntSeq(build.power.links);
|
||||||
build.power.links.each(i -> linkedBuilds.add(world.build(i)));
|
seq.addAll(build.proximity().mapInt(Building::pos));
|
||||||
build.proximity().each(linkedBuilds::add);
|
return seq;
|
||||||
linkedBuilds.filter(b -> b != null && b.power != null);
|
|
||||||
if(!build.block.outputsPower && !(build instanceof PowerNode.PowerNodeBuild))
|
|
||||||
linkedBuilds.filter(b -> b.block.outputsPower || b instanceof PowerNode.PowerNodeBuild);
|
|
||||||
return linkedBuilds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void drawNodeLink(Building node) {
|
public static void drawNodeLink(Building node) {
|
||||||
if(node.power == null) return;
|
if(node.power == null) return;
|
||||||
if(!linkedNodes.contains(node)) {
|
if(!linkedNodes.contains(node)) {
|
||||||
linkedNodes.add(node);
|
linkedNodes.add(node);
|
||||||
getPowerLinkedBuilds(node).each(other -> {
|
getPowerLinkedBuilds(node).each(i -> {
|
||||||
|
Building other = world.build(i);
|
||||||
|
if(other.power == null) return;
|
||||||
float angle1 = Angles.angle(node.x, node.y, other.x, other.y),
|
float angle1 = Angles.angle(node.x, node.y, other.x, other.y),
|
||||||
vx = Mathf.cosDeg(angle1), vy = Mathf.sinDeg(angle1),
|
vx = Mathf.cosDeg(angle1), vy = Mathf.sinDeg(angle1),
|
||||||
len1 = node.block.size * tilesize / 2f - 1.5f, len2 = other.block.size * tilesize / 2f - 1.5f;
|
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.color(Color.white, Color.valueOf("98ff98"), (1f - node.power.graph.getSatisfaction()) * 0.86f + Mathf.absin(3f, 0.1f));
|
||||||
Draw.alpha(Renderer.laserOpacity);
|
Draw.alpha(Renderer.laserOpacity);
|
||||||
Drawf.laser(node.team, atlas.find("unitinfo-Slaser"), atlas.find("unitinfo-Slaser-end"), node.x + vx*len1, node.y + vy*len1, other.x - vx*len2, other.y - vy*len2, 0.25f);
|
Drawf.laser(node.team, atlas.find("unitinfo-Slaser"), atlas.find("unitinfo-Slaser-end"), node.x + vx * len1, node.y + vy * len1, other.x - vx * len2, other.y - vy * len2, 0.25f);
|
||||||
|
|
||||||
if(other.power != null) getPowerLinkedBuilds(other).each(OverDrawer::drawNodeLink);
|
drawNodeLink(other);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user