mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-21 21:28:28 +07:00
Updated version, teleporter tweaks
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
#Autogenerated file. Do not modify.
|
||||
#Sun Feb 18 12:25:44 EST 2018
|
||||
#Sun Feb 18 12:38:19 EST 2018
|
||||
version=beta
|
||||
androidBuildCode=236
|
||||
androidBuildCode=238
|
||||
name=Mindustry
|
||||
code=3.3
|
||||
build=custom build
|
||||
build=24
|
||||
|
@ -89,6 +89,10 @@ public class Teleporter extends PowerBlock{
|
||||
TeleporterEntity entity = tile.entity();
|
||||
|
||||
teleporters[entity.color].add(tile);
|
||||
|
||||
if(entity.totalItems() > 0){
|
||||
tryDump(tile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -130,12 +134,12 @@ public class Teleporter extends PowerBlock{
|
||||
public void handleItem(Item item, Tile tile, Tile source){
|
||||
PowerEntity entity = tile.entity();
|
||||
|
||||
Array<Tile> links = findLinks(tile, item);
|
||||
Array<Tile> links = findLinks(tile);
|
||||
|
||||
if(links.size > 0){
|
||||
if(!syncBlockState || Net.server() || !Net.active()){
|
||||
Tile target = links.random();
|
||||
target.block().offloadNear(target, item);
|
||||
target.entity.addItem(item, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,7 +149,7 @@ public class Teleporter extends PowerBlock{
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
PowerEntity entity = tile.entity();
|
||||
return !(source.block() instanceof Teleporter) && entity.power >= powerPerItem && findLinks(tile, item).size > 0;
|
||||
return !(source.block() instanceof Teleporter) && entity.power >= powerPerItem && findLinks(tile).size > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -153,17 +157,7 @@ public class Teleporter extends PowerBlock{
|
||||
return new TeleporterEntity();
|
||||
}
|
||||
|
||||
public boolean available(Tile tile, Item item){
|
||||
for(int i = 0; i < 4; i ++){
|
||||
Tile next = tile.getNearby(i);
|
||||
if(next != null && !(next.block().instantTransfer) && next.block().acceptItem(item, next, tile)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Array<Tile> findLinks(Tile tile, Item output){
|
||||
private Array<Tile> findLinks(Tile tile){
|
||||
TeleporterEntity entity = tile.entity();
|
||||
|
||||
removal.clear();
|
||||
@ -174,7 +168,7 @@ public class Teleporter extends PowerBlock{
|
||||
if(other.block() instanceof Teleporter){
|
||||
if(other.<TeleporterEntity>entity().color != entity.color){
|
||||
removal.add(other);
|
||||
}else if(((Teleporter)other.block()).available(other, output)){
|
||||
}else if(other.entity.totalItems() == 0){
|
||||
returns.add(other);
|
||||
}
|
||||
}else{
|
||||
|
Reference in New Issue
Block a user