Added inverted sorter

This commit is contained in:
Anuken
2019-10-13 12:58:58 -04:00
parent 92dacf18cd
commit 3d624f7eaf
11 changed files with 10356 additions and 10304 deletions

View File

@@ -58,7 +58,7 @@ public class Blocks implements ContentList{
phaseWall, phaseWallLarge, surgeWall, surgeWallLarge, mender, mendProjector, overdriveProjector, forceProjector, shockMine,
//transport
conveyor, titaniumConveyor, armoredConveyor, distributor, junction, itemBridge, phaseConveyor, sorter, router, overflowGate, massDriver,
conveyor, titaniumConveyor, armoredConveyor, distributor, junction, itemBridge, phaseConveyor, sorter, invertedSorter, router, overflowGate, massDriver,
//liquids
mechanicalPump, rotaryPump, thermalPump, conduit, pulseConduit, liquidRouter, liquidTank, liquidJunction, bridgeConduit, phaseConduit,
@@ -935,7 +935,11 @@ public class Blocks implements ContentList{
sorter = new Sorter("sorter"){{
requirements(Category.distribution, ItemStack.with(Items.lead, 2, Items.copper, 2));
}};
invertedSorter = new Sorter("inverted-sorter"){{
requirements(Category.distribution, ItemStack.with(Items.lead, 2, Items.copper, 2));
invert = true;
}};
router = new Router("router"){{

View File

@@ -31,6 +31,7 @@ public class TechTree implements ContentList{
node(distributor);
node(sorter, () -> {
node(invertedSorter);
node(message);
node(overflowGate);
});

View File

@@ -17,6 +17,7 @@ import static io.anuke.mindustry.Vars.content;
public class Sorter extends Block{
private static Item lastItem;
protected boolean invert;
public Sorter(String name){
super(name);
@@ -40,16 +41,6 @@ public class Sorter extends Block{
}
}
/*
@Remote(targets = Loc.both, called = Loc.both, forward = true)
public static void setSorterItem(Player player, Tile tile, Item item){
if(!Units.canInteract(player, tile)) return;
SorterEntity entity = tile.entity();
if(entity != null){
entity.sortItem = item;
}
}*/
@Override
public void configured(Tile tile, Player player, int value){
tile.<SorterEntity>entity().sortItem = content.item(value);
@@ -92,7 +83,7 @@ public class Sorter extends Block{
if(dir == -1) return null;
Tile to;
if(item == entity.sortItem){
if((item == entity.sortItem) != invert){
//prevent 3-chains
if(isSame(dest, source) && isSame(dest, dest.getNearby(dir))){
return null;
@@ -115,12 +106,10 @@ public class Sorter extends Block{
}else{
if(dest.rotation() == 0){
to = a;
if(flip)
dest.rotation((byte)1);
if(flip) dest.rotation((byte)1);
}else{
to = b;
if(flip)
dest.rotation((byte)0);
if(flip) dest.rotation((byte)0);
}
}
}