Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -434,6 +434,10 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
return block.unloadable;
|
||||
}
|
||||
|
||||
public boolean canResupply(){
|
||||
return block.allowResupply;
|
||||
}
|
||||
|
||||
public boolean payloadCheck(int conveyorRotation){
|
||||
return block.rotate && (rotation + 2) % 4 == conveyorRotation;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ItemAmmoType implements AmmoType{
|
||||
|
||||
float range = unit.hitSize + this.range;
|
||||
|
||||
Building build = Units.closestBuilding(unit.team, unit.x, unit.y, range, u -> u.block.allowResupply && u.items.has(item));
|
||||
Building build = Units.closestBuilding(unit.team, unit.x, unit.y, range, u -> u.canResupply() && u.items.has(item));
|
||||
|
||||
if(build != null){
|
||||
Fx.itemTransfer.at(build.x, build.y, ammoPerItem / 2f, item.color, unit);
|
||||
|
||||
@@ -143,12 +143,18 @@ public class Unloader extends Block{
|
||||
}
|
||||
|
||||
//sort so it gives full priority to blocks that can give but not receive (stackConveyors and Storage), and then by load, and then by last use
|
||||
possibleBlocks.sort(Structs.comps(
|
||||
Structs.comparingBool(e -> e.building.block.highUnloadPriority),
|
||||
possibleBlocks.sort(
|
||||
Structs.comps(
|
||||
Structs.comparingFloat(e -> e.loadFactor),
|
||||
Structs.comparingInt(e -> -lastUsed[e.index])
|
||||
)));
|
||||
Structs.comps(
|
||||
Structs.comparingBool(e -> e.building.block.highUnloadPriority && !e.canLoad),
|
||||
Structs.comparingBool(e -> e.canUnload && !e.canLoad)
|
||||
),
|
||||
Structs.comps(
|
||||
Structs.comparingFloat(e -> e.loadFactor),
|
||||
Structs.comparingInt(e -> -lastUsed[e.index])
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
ContainerStat dumpingFrom = null;
|
||||
ContainerStat dumpingTo = null;
|
||||
@@ -175,7 +181,7 @@ public class Unloader extends Block{
|
||||
}
|
||||
|
||||
//trade the items
|
||||
if(dumpingFrom != null && dumpingTo != null && (dumpingFrom.loadFactor != dumpingTo.loadFactor || dumpingFrom.building.block.highUnloadPriority)){
|
||||
if(dumpingFrom != null && dumpingTo != null && (dumpingFrom.loadFactor != dumpingTo.loadFactor || !dumpingFrom.canLoad)){
|
||||
dumpingTo.building.handleItem(this, item);
|
||||
dumpingFrom.building.removeStack(item, 1);
|
||||
lastUsed[dumpingFrom.index] = 0;
|
||||
|
||||
Reference in New Issue
Block a user