Made Unloader have the same "memory" as the sorter (#366)
I implemented the same 'memory' feature as the sorter's, introduced in b62. It's sort of under the 'sorter' category in terms of features, so I thought it would be logical to do so.
This commit is contained in:
committed by
Anuken
parent
6d59fe3080
commit
989034c799
@@ -17,15 +17,22 @@ import java.io.DataOutput;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.content;
|
import static io.anuke.mindustry.Vars.content;
|
||||||
|
import static io.anuke.mindustry.Vars.threads;
|
||||||
|
|
||||||
public class SortedUnloader extends Unloader implements SelectionTrait{
|
public class SortedUnloader extends Unloader implements SelectionTrait{
|
||||||
protected float speed = 1f;
|
protected float speed = 1f;
|
||||||
|
private static Item lastItem;
|
||||||
|
|
||||||
public SortedUnloader(String name){
|
public SortedUnloader(String name){
|
||||||
super(name);
|
super(name);
|
||||||
configurable = true;
|
configurable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playerPlaced(Tile tile){
|
||||||
|
threads.runDelay(() -> Call.setSortedUnloaderItem(null, tile, lastItem));
|
||||||
|
}
|
||||||
|
|
||||||
@Remote(targets = Loc.both, called = Loc.both, forward = true)
|
@Remote(targets = Loc.both, called = Loc.both, forward = true)
|
||||||
public static void setSortedUnloaderItem(Player player, Tile tile, Item item){
|
public static void setSortedUnloaderItem(Player player, Tile tile, Item item){
|
||||||
SortedUnloaderEntity entity = tile.entity();
|
SortedUnloaderEntity entity = tile.entity();
|
||||||
@@ -65,7 +72,10 @@ public class SortedUnloader extends Unloader implements SelectionTrait{
|
|||||||
@Override
|
@Override
|
||||||
public void buildTable(Tile tile, Table table){
|
public void buildTable(Tile tile, Table table){
|
||||||
SortedUnloaderEntity entity = tile.entity();
|
SortedUnloaderEntity entity = tile.entity();
|
||||||
buildItemTable(table, () -> entity.sortItem, item -> Call.setSortedUnloaderItem(null, tile, item));
|
buildItemTable(table, () -> entity.sortItem, item -> {
|
||||||
|
lastItem = item;
|
||||||
|
Call.setSortedUnloaderItem(null, tile, item);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user