Line optimization & cleanup
This commit is contained in:
@@ -673,7 +673,7 @@ public class Block extends UnlockableContent{
|
||||
public void load(){
|
||||
region = Core.atlas.find(name);
|
||||
|
||||
if(cracks == null || (cracks[0][0].getTexture() != null && cracks[0][0].getTexture().isDisposed())){
|
||||
if(cracks == null || (cracks[0][0].texture != null && cracks[0][0].texture.isDisposed())){
|
||||
cracks = new TextureRegion[maxCrackSize][crackRegions];
|
||||
for(int size = 1; size <= maxCrackSize; size++){
|
||||
for(int i = 0; i < crackRegions; i++){
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ExtendingItemBridge extends ItemBridge{
|
||||
x + Geometry.d4[i].x * tilesize / 2f,
|
||||
y + Geometry.d4[i].y * tilesize / 2f,
|
||||
x + ex,
|
||||
y + ey, false, 0f);
|
||||
y + ey, false);
|
||||
|
||||
Draw.rect(endRegion, x, y, i * 90 + 90);
|
||||
Draw.rect(endRegion,
|
||||
|
||||
@@ -61,11 +61,17 @@ public class ItemBridge extends Block{
|
||||
if(otherReq == null) return;
|
||||
|
||||
Lines.stroke(8f);
|
||||
Lines.line(bridgeRegion,
|
||||
req.drawx(),
|
||||
req.drawy(),
|
||||
otherReq.drawx(),
|
||||
otherReq.drawy(), false, -tilesize / 2f);
|
||||
|
||||
Tmp.v1.set(otherReq.drawx(), otherReq.drawx()).sub(req.drawx(), req.drawy()).setLength(-tilesize/2f);
|
||||
|
||||
Lines.line(
|
||||
bridgeRegion,
|
||||
req.drawx() + Tmp.v1.x,
|
||||
req.drawy() + Tmp.v1.y,
|
||||
otherReq.drawx() - Tmp.v1.x,
|
||||
otherReq.drawy() - Tmp.v1.y, false
|
||||
);
|
||||
|
||||
Draw.rect(arrowRegion, (req.drawx() + otherReq.drawx()) / 2f, (req.drawy() + otherReq.drawy()) / 2f,
|
||||
Angles.angle(req.drawx(), req.drawy(), otherReq.drawx(), otherReq.drawy()));
|
||||
}
|
||||
@@ -296,11 +302,14 @@ public class ItemBridge extends Block{
|
||||
Draw.rect(endRegion, other.drawx(), other.drawy(), i * 90 + 270);
|
||||
|
||||
Lines.stroke(8f);
|
||||
|
||||
Tmp.v1.set(x, y).sub(other.worldx(), other.worldy()).setLength(-tilesize/2f);
|
||||
|
||||
Lines.line(bridgeRegion,
|
||||
x,
|
||||
y,
|
||||
other.worldx(),
|
||||
other.worldy(), false, -tilesize / 2f);
|
||||
x + Tmp.v1.x,
|
||||
y + Tmp.v1.y,
|
||||
other.worldx() - Tmp.v1.x,
|
||||
other.worldy() - Tmp.v1.y, false);
|
||||
|
||||
int dist = Math.max(Math.abs(other.x - tile.x), Math.abs(other.y - tile.y));
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@ public class PayloadConveyor extends Block{
|
||||
boolean overlaps = Intersector.intersectRectangles(bounds, sprite, over);
|
||||
|
||||
TextureRegion out = Tmp.tr1;
|
||||
out.set(region.getTexture());
|
||||
out.set(region.texture);
|
||||
|
||||
if(overlaps){
|
||||
float w = region.u2 - region.u;
|
||||
|
||||
@@ -67,7 +67,6 @@ public class LogicDisplay extends Block{
|
||||
buffer.begin();
|
||||
Draw.color(color);
|
||||
Lines.stroke(stroke);
|
||||
Lines.precise(true);
|
||||
|
||||
while(!commands.isEmpty()){
|
||||
long c = commands.removeFirst();
|
||||
@@ -88,8 +87,6 @@ public class LogicDisplay extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
Lines.precise(false);
|
||||
|
||||
buffer.end();
|
||||
Draw.proj(Tmp.m1);
|
||||
Draw.reset();
|
||||
|
||||
@@ -145,22 +145,19 @@ public class PowerNode extends PowerBlock{
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
protected void drawLaser(Team team, float x1, float y1, float x2, float y2, float satisfaction, int size1, int size2){
|
||||
float angle1 = Angles.angle(x1, y1, x2, y2);
|
||||
t1.trns(angle1, size1 * tilesize / 2f - 1.5f);
|
||||
t2.trns(angle1 + 180f, size2 * tilesize / 2f - 1.5f);
|
||||
|
||||
x1 += t1.x;
|
||||
y1 += t1.y;
|
||||
x2 += t2.x;
|
||||
y2 += t2.y;
|
||||
|
||||
protected void setupColor(float satisfaction){
|
||||
float fract = 1f - satisfaction;
|
||||
|
||||
Draw.color(laserColor1, laserColor2, fract * 0.86f + Mathf.absin(3f, 0.1f));
|
||||
Draw.alpha(renderer.laserOpacity);
|
||||
Drawf.laser(team, laser, laserEnd, x1, y1, x2, y2, 0.25f);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
protected void drawLaser(Team team, float x1, float y1, float x2, float y2, int size1, int size2){
|
||||
float angle1 = Angles.angle(x1, y1, x2, y2);
|
||||
float vx = Mathf.cosDeg(angle1), vy = Mathf.sinDeg(angle1);
|
||||
float len1 = size1 * tilesize / 2f - 1.5f, len2 = size2 * tilesize / 2f - 1.5f;
|
||||
|
||||
Drawf.laser(team, laser, laserEnd, x1 + vx*len1, y1 + vy*len1, x2 - vx*len2, y2 - vy*len2, 0.25f);
|
||||
}
|
||||
|
||||
protected boolean overlaps(float srcx, float srcy, Tile other, float range){
|
||||
@@ -214,6 +211,7 @@ public class PowerNode extends PowerBlock{
|
||||
@Override
|
||||
public void drawRequestConfigTop(BuildPlan req, Eachable<BuildPlan> list){
|
||||
if(req.config instanceof Point2[]){
|
||||
setupColor(1f);
|
||||
for(Point2 point : (Point2[])req.config){
|
||||
otherReq = null;
|
||||
list.each(other -> {
|
||||
@@ -224,8 +222,9 @@ public class PowerNode extends PowerBlock{
|
||||
|
||||
if(otherReq == null || otherReq.block == null) return;
|
||||
|
||||
drawLaser(player.team(), req.drawx(), req.drawy(), otherReq.drawx(), otherReq.drawy(), 1f, size, otherReq.block.size);
|
||||
drawLaser(player.team(), req.drawx(), req.drawy(), otherReq.drawx(), otherReq.drawy(), size, otherReq.block.size);
|
||||
}
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,6 +385,7 @@ public class PowerNode extends PowerBlock{
|
||||
if(Mathf.zero(renderer.laserOpacity)) return;
|
||||
|
||||
Draw.z(Layer.power);
|
||||
setupColor(power.graph.getSatisfaction());
|
||||
|
||||
for(int i = 0; i < power.links.size; i++){
|
||||
Building link = world.build(power.links.get(i));
|
||||
@@ -394,7 +394,7 @@ public class PowerNode extends PowerBlock{
|
||||
|
||||
if(link.block instanceof PowerNode && !(link.pos() < tile.pos())) continue;
|
||||
|
||||
drawLaserTo(link);
|
||||
drawLaser(team, x, y, link.x, link.y, size, link.block.size);
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
@@ -404,10 +404,6 @@ public class PowerNode extends PowerBlock{
|
||||
return power.links.contains(other.pos());
|
||||
}
|
||||
|
||||
protected void drawLaserTo(Building target){
|
||||
drawLaser(team, x, y, target.x, target.y, power.graph.getSatisfaction(), size, target.block.size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point2[] config(){
|
||||
Point2[] out = new Point2[power.links.size];
|
||||
|
||||
Reference in New Issue
Block a user