Merge branch 'master' of https://github.com/Anuken/Mindustry into 7.0-features

 Conflicts:
	core/src/mindustry/type/UnitType.java
	gradle.properties
This commit is contained in:
Anuken
2021-11-04 19:39:16 -04:00
31 changed files with 285 additions and 94 deletions
+1 -1
View File
@@ -86,7 +86,7 @@ public class Block extends UnlockableContent{
public boolean solid;
/** whether this block CAN be solid. */
public boolean solidifes;
/** whether this is rotateable */
/** whether this is rotatable */
public boolean rotate;
/** number of different variant regions to use */
public int variants = 0;
@@ -29,8 +29,7 @@ public class Thruster extends Wall{
@Override
public void draw(){
super.draw();
Draw.rect(block.region, x, y);
Draw.rect(topRegion, x, y, rotdeg());
}
}
@@ -76,7 +76,7 @@ public class Turret extends ReloadTurret{
public Effect chargeBeginEffect = Fx.none;
public Sound chargeSound = Sounds.none;
public Sortf unitSort = Unit::dst2;
public Sortf unitSort = UnitSorts.closest;
protected Vec2 tr = new Vec2();
protected Vec2 tr2 = new Vec2();
@@ -519,4 +519,4 @@ public class Turret extends ReloadTurret{
return 1;
}
}
}
}
@@ -95,7 +95,7 @@ public class PayloadConveyor extends Block{
public void onProximityUpdate(){
super.onProximityUpdate();
Building accept = nearby(Geometry.d4(rotation).x * size, Geometry.d4(rotation).y * size);
Building accept = nearby(Geometry.d4(rotation).x * (size/2+1), Geometry.d4(rotation).y * (size/2+1));
//next block must be aligned and of the same size
if(accept != null && (
//same size
@@ -153,6 +153,11 @@ public class StackConveyor extends Block implements Autotiler{
Draw.z(Layer.block - 0.15f);
super.drawCracks();
}
@Override
public void payloadDraw(){
Draw.rect(block.fullIcon, x, y);
}
@Override
public void onProximityUpdate(){
@@ -80,6 +80,7 @@ public class BuildPayload implements Payload{
@Override
public void set(float x, float y, float rotation){
build.set(x, y);
build.payloadRotation = rotation;
}
@Override
@@ -64,8 +64,11 @@ public class Unloader extends Block{
float loadFactor;
boolean canLoad;
boolean canUnload;
int index;
}
public int[] lastUsed;
@Override
public void updateTile(){
if(((unloadTimer += delta()) < speed) || (proximity.size < 2)) return;
@@ -80,14 +83,14 @@ public class Unloader extends Block{
for(int i = tmp; i < proximity.size; i++){
possibleBlocks.set(i, new ContainerStat());
}
lastUsed = new int[proximity.size];
}
if(sortItem != null){
item = sortItem;
for(int j = 0; j < proximity.size; j++){
int pos = (offset + j) % proximity.size;
var other = proximity.get(j);
for(int pos = 0; pos < proximity.size; pos++){
var other = proximity.get(pos);
boolean interactable = other.interactable(team);
//set the stats of all buildings in possibleBlocks
@@ -95,6 +98,7 @@ public class Unloader extends Block{
pb.building = other;
pb.canUnload = interactable && other.canUnload() && other.items != null && other.items.has(sortItem);
pb.canLoad = interactable && !(other.block instanceof StorageBlock) && other.acceptItem(this, sortItem);
pb.index = pos;
}
}else{
//select the next item for nulloaders
@@ -106,9 +110,8 @@ public class Unloader extends Block{
boolean isDistinct = false;
Item possibleItem = content.item(total);
for(int j = 0; j < proximity.size; j++){
int pos = (offset + j) % proximity.size;
var other = proximity.get(j);
for(int pos = 0; pos < proximity.size; pos++){
var other = proximity.get(pos);
boolean interactable = other.interactable(team);
//set the stats of all buildings in possibleBlocks while we are at it
@@ -116,6 +119,7 @@ public class Unloader extends Block{
pb.building = other;
pb.canUnload = interactable && other.canUnload() && other.items != null && other.items.has(possibleItem);
pb.canLoad = interactable && !(other.block instanceof StorageBlock) && other.acceptItem(this, possibleItem);
pb.index = pos;
//the part handling framerate issues and slow conveyor belts, to avoid skipping items
if(hasProvider && pb.canLoad) isDistinct = true;
@@ -138,11 +142,13 @@ 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 (stackConveyors and Storage), and then by load
//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),
Structs.comparingFloat(e -> e.loadFactor)
));
Structs.comps(
Structs.comparingFloat(e -> e.loadFactor),
Structs.comparingInt(e -> -lastUsed[e.index])
)));
ContainerStat dumpingFrom = null;
ContainerStat dumpingTo = null;
@@ -163,10 +169,17 @@ public class Unloader extends Block{
}
}
//increment the priority if not used
for(int i = 0; i < possibleBlocks.size; i++){
lastUsed[i] = (lastUsed[i] + 1 ) % 2147483647;
}
//trade the items
if(dumpingFrom != null && dumpingTo != null && (dumpingFrom.loadFactor != dumpingTo.loadFactor || dumpingFrom.building.block.highUnloadPriority)){
dumpingTo.building.handleItem(this, item);
dumpingFrom.building.removeStack(item, 1);
lastUsed[dumpingFrom.index] = 0;
lastUsed[dumpingTo.index] = 0;
any = true;
}
@@ -78,7 +78,7 @@ public class UnitFactory extends UnitBlock{
Core.bundle.format("bar.unitcap",
Fonts.getUnicodeStr(e.unit().name),
e.team.data().countType(e.unit()),
Units.getCap(e.team)
Units.getStringCap(e.team)
),
() -> Pal.power,
() -> e.unit() == null ? 0f : (float)e.team.data().countType(e.unit()) / Units.getCap(e.team)