Cache upstream
But i do ¬ like how this turned out, so reverting :(
This commit is contained in:
@@ -26,6 +26,8 @@ import static mindustry.Vars.*;
|
|||||||
public class CraterConveyor extends Block implements Autotiler{
|
public class CraterConveyor extends Block implements Autotiler{
|
||||||
private TextureRegion[] regions = new TextureRegion[8];
|
private TextureRegion[] regions = new TextureRegion[8];
|
||||||
|
|
||||||
|
private Tile upstream;
|
||||||
|
|
||||||
public float speed = 0f;
|
public float speed = 0f;
|
||||||
|
|
||||||
public CraterConveyor(String name){
|
public CraterConveyor(String name){
|
||||||
@@ -145,6 +147,8 @@ public class CraterConveyor extends Block implements Autotiler{
|
|||||||
entity.blendbit1 = bits[0];
|
entity.blendbit1 = bits[0];
|
||||||
entity.blendsclx = bits[1];
|
entity.blendsclx = bits[1];
|
||||||
entity.blendscly = bits[2];
|
entity.blendscly = bits[2];
|
||||||
|
|
||||||
|
upstream(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -256,6 +260,7 @@ public class CraterConveyor extends Block implements Autotiler{
|
|||||||
int blendbit1, blendbit2;
|
int blendbit1, blendbit2;
|
||||||
int blendsclx, blendscly;
|
int blendsclx, blendscly;
|
||||||
|
|
||||||
|
int[] upstream = new int[3];
|
||||||
int from = Pos.invalid;
|
int from = Pos.invalid;
|
||||||
float reload;
|
float reload;
|
||||||
|
|
||||||
@@ -276,37 +281,43 @@ public class CraterConveyor extends Block implements Autotiler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void upstream(Tile tile, Cons<Tile> cons){
|
private void upstream(Tile tile){
|
||||||
CraterConveyorEntity entity = tile.ent();
|
CraterConveyorEntity entity = tile.ent();
|
||||||
|
|
||||||
if( entity.blendbit1 == 0 // 1 input from the back, 0 from the sides
|
if( entity.blendbit1 == 0 // 1 input from the back, 0 from the sides
|
||||||
|| entity.blendbit1 == 2 // 1 input from the back, 1 from the sides
|
|| entity.blendbit1 == 2 // 1 input from the back, 1 from the sides
|
||||||
|| entity.blendbit1 == 3 // 1 input from the back, 2 from the sides
|
|| entity.blendbit1 == 3 // 1 input from the back, 2 from the sides
|
||||||
) cons.get(tile.back());
|
) entity.upstream[0] = tile.back().pos(); else entity.upstream[0] = Pos.invalid;
|
||||||
|
|
||||||
if( entity.blendbit1 == 3 // 1 input from the back, 2 from the sides
|
if( entity.blendbit1 == 3 // 1 input from the back, 2 from the sides
|
||||||
|| entity.blendbit1 == 4 // 0 input from the back, 2 from the sides
|
|| entity.blendbit1 == 4 // 0 input from the back, 2 from the sides
|
||||||
||(entity.blendbit1 == 1 && entity.blendscly == -1) // side is open
|
||(entity.blendbit1 == 1 && entity.blendscly == -1) // side is open
|
||||||
||(entity.blendbit1 == 2 && entity.blendscly == +1) // side is open
|
||(entity.blendbit1 == 2 && entity.blendscly == +1) // side is open
|
||||||
) cons.get(tile.right());
|
) entity.upstream[1] = tile.right().pos(); else entity.upstream[1] = Pos.invalid;
|
||||||
|
|
||||||
if( entity.blendbit1 == 3 // 1 input from the back, 2 from the sides
|
if( entity.blendbit1 == 3 // 1 input from the back, 2 from the sides
|
||||||
|| entity.blendbit1 == 4 // 0 input from the back, 2 from the sides
|
|| entity.blendbit1 == 4 // 0 input from the back, 2 from the sides
|
||||||
||(entity.blendbit1 == 1 && entity.blendscly == +1) // side is open
|
||(entity.blendbit1 == 1 && entity.blendscly == +1) // side is open
|
||||||
||(entity.blendbit1 == 2 && entity.blendscly == -1) // side is open
|
||(entity.blendbit1 == 2 && entity.blendscly == -1) // side is open
|
||||||
) cons.get(tile.left());
|
) entity.upstream[2] = tile.left().pos(); else entity.upstream[2] = Pos.invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ▲ | ▼ fixme: refactor
|
// ▲ | ▼ fixme: refactor
|
||||||
|
|
||||||
// awaken inputting conveyors
|
// awaken inputting conveyors
|
||||||
private void bump(Tile tile){
|
private void bump(Tile tile){
|
||||||
upstream(tile, t -> {
|
CraterConveyorEntity entity = tile.ent();
|
||||||
if(t != null && t.entity != null && t.entity.isSleeping() && t.entity.items.total() > 0){
|
|
||||||
t.entity.noSleep();
|
for(int i = 0; i < 3; i++){
|
||||||
bump(t);
|
if(entity.upstream[i] == Pos.invalid) continue;
|
||||||
|
|
||||||
|
upstream = world.tile(entity.upstream[i]);
|
||||||
|
|
||||||
|
if(upstream != null && upstream.entity != null && upstream.entity.isSleeping() && upstream.entity.items.total() > 0){
|
||||||
|
upstream.entity.noSleep();
|
||||||
|
bump(upstream);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldLaunch(Tile tile){
|
public boolean shouldLaunch(Tile tile){
|
||||||
|
|||||||
Reference in New Issue
Block a user