Merge branch 'master' of https://github.com/Anuken/Mindustry into 7.0-features
This commit is contained in:
@@ -42,6 +42,7 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
hasItems = true;
|
||||
itemCapacity = 10;
|
||||
conveyorPlacement = true;
|
||||
highUnloadPriority = true;
|
||||
|
||||
ambientSound = Sounds.conveyor;
|
||||
ambientSoundVolume = 0.004f;
|
||||
@@ -312,7 +313,7 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
if(this == source) return true; //player threw items
|
||||
if(this == source) return items.total() < itemCapacity && (!items.any() || items.has(item)); //player threw items
|
||||
if(cooldown > recharge - 1f) return false; //still cooling down
|
||||
return !((state != stateLoad) //not a loading dock
|
||||
|| (items.any() && !items.has(item)) //incompatible items
|
||||
|
||||
@@ -160,8 +160,8 @@ public class PayloadLoader extends PayloadBlock{
|
||||
public boolean shouldExport(){
|
||||
return payload != null && (
|
||||
exporting ||
|
||||
(payload.block().hasLiquids && payload.build.liquids.total() >= payload.block().liquidCapacity - 0.001f) ||
|
||||
(payload.block().hasItems && payload.block().separateItemCapacity && content.items().contains(i -> payload.build.items.get(i) >= payload.block().itemCapacity)));
|
||||
(payload.block().hasLiquids && liquids.total() >= 0.1f && payload.build.liquids.total() >= payload.block().liquidCapacity - 0.001f) ||
|
||||
(payload.block().hasItems && items.any() && payload.block().separateItemCapacity && content.items().contains(i -> payload.build.items.get(i) >= payload.block().itemCapacity)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,7 @@ public class StorageBlock extends Block{
|
||||
flags = EnumSet.of(BlockFlag.storage);
|
||||
allowResupply = true;
|
||||
envEnabled = Env.any;
|
||||
highUnloadPriority = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -85,8 +85,9 @@ public class Unloader extends Block{
|
||||
if(sortItem != null){
|
||||
item = sortItem;
|
||||
|
||||
for(int pos = 0; pos < proximity.size; pos++){
|
||||
var other = proximity.get(pos);
|
||||
for(int j = 0; j < proximity.size; j++){
|
||||
int pos = (offset + j) % proximity.size;
|
||||
var other = proximity.get(j);
|
||||
boolean interactable = other.interactable(team);
|
||||
|
||||
//set the stats of all buildings in possibleBlocks
|
||||
@@ -105,8 +106,9 @@ public class Unloader extends Block{
|
||||
boolean isDistinct = false;
|
||||
Item possibleItem = content.item(total);
|
||||
|
||||
for(int pos = 0; pos < proximity.size; pos++){
|
||||
var other = proximity.get(pos);
|
||||
for(int j = 0; j < proximity.size; j++){
|
||||
int pos = (offset + j) % proximity.size;
|
||||
var other = proximity.get(j);
|
||||
boolean interactable = other.interactable(team);
|
||||
|
||||
//set the stats of all buildings in possibleBlocks while we are at it
|
||||
@@ -136,13 +138,11 @@ public class Unloader extends Block{
|
||||
pb.loadFactor = (other.getMaximumAccepted(item) == 0) || (other.items == null) ? 0 : other.items.get(item) / (float)other.getMaximumAccepted(item);
|
||||
}
|
||||
|
||||
//sort so it gives full priority to blocks that can give but not receive (mainly plast and storage), and then by load
|
||||
possibleBlocks.sort((e1, e2) -> {
|
||||
// TODO: instead of canLoad it should be ((instance of Storage) || (is it a plast belt i can unload from))
|
||||
// otherwise a 100% full factory will get full priority over the storage/plast, barely an issue but still wasting trades and thus speed
|
||||
int canLoad = Boolean.compare(e2.canLoad, e1.canLoad);
|
||||
return (canLoad != 0) ? canLoad : Float.compare(e1.loadFactor, e2.loadFactor);
|
||||
});
|
||||
//sort so it gives full priority to blocks that can give but not receive (stackConveyors and Storage), and then by load
|
||||
possibleBlocks.sort(Structs.comps(
|
||||
Structs.comparingBool(e -> e.building.block.highUnloadPriority),
|
||||
Structs.comparingFloat(e -> e.loadFactor)
|
||||
));
|
||||
|
||||
ContainerStat dumpingFrom = null;
|
||||
ContainerStat dumpingTo = null;
|
||||
@@ -164,7 +164,7 @@ public class Unloader extends Block{
|
||||
}
|
||||
|
||||
//trade the items
|
||||
if(dumpingFrom != null && dumpingTo != null && dumpingFrom.loadFactor != dumpingTo.loadFactor){
|
||||
if(dumpingFrom != null && dumpingTo != null && (dumpingFrom.loadFactor != dumpingTo.loadFactor || dumpingFrom.building.block.highUnloadPriority)){
|
||||
dumpingTo.building.handleItem(this, item);
|
||||
dumpingFrom.building.removeStack(item, 1);
|
||||
any = true;
|
||||
@@ -233,4 +233,4 @@ public class Unloader extends Block{
|
||||
sortItem = id == -1 ? null : content.items().get(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user