Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anuken
2021-11-20 10:58:12 -05:00
5 changed files with 23 additions and 7 deletions

View File

@ -15,6 +15,8 @@ If you are submitting a new block, make sure it has a name and description, and
If you are interested in adding a large mechanic/feature or changing large amounts of code, first contact me (Anuken) via [Discord](https://discord.gg/mindustry) (preferred method) or via e-mail (*anukendev@gmail.com*).
For most changes, this should not be necessary. I just want to know if you're doing something big so I can offer advice and/or make sure you're not wasting your time on it.
### Do not make formatting PRs.
Yes, there are occurrences of trailing spaces, extra newlines, empty indents, and other tiny errors. No, I don't want to merge, view, or get notified by your 1-line PR fixing it. If you're implementing a PR with modification of *actual code*, feel free to fix formatting in the general vicinity of your changes, but please don't waste everyone's time with pointless changes.
## Style Guidelines

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -122,5 +122,9 @@
{
"name": "Conservatory",
"address": ["143.198.71.232"]
},
{
"name": "Shard",
"address": ["shard.mcv.kr"]
}
]