Merge branch 'master' of https://github.com/Anuken/Mindustry into 7.0-features
This commit is contained in:
@@ -38,7 +38,7 @@ public class PhysicsProcess implements AsyncProcess{
|
||||
|
||||
//find Unit without bodies and assign them
|
||||
for(Unit entity : group){
|
||||
if(entity.type == null) continue;
|
||||
if(entity == null || entity.type == null) continue;
|
||||
|
||||
if(entity.physref == null){
|
||||
PhysicsBody body = new PhysicsBody();
|
||||
|
||||
@@ -5,6 +5,7 @@ import arc.graphics.*;
|
||||
import arc.graphics.Texture.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.graphics.gl.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
|
||||
import static arc.Core.*;
|
||||
@@ -35,6 +36,8 @@ public class Pixelator implements Disposable{
|
||||
w = (int)(Core.camera.width * renderer.landScale() / renderer.getScale());
|
||||
h = (int)(Core.camera.height * renderer.landScale() / renderer.getScale());
|
||||
}
|
||||
w = Mathf.clamp(w, 2, graphics.getWidth());
|
||||
h = Mathf.clamp(h, 2, graphics.getHeight());
|
||||
|
||||
buffer.resize(w, h);
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ public class PlanetGrid{
|
||||
|
||||
static int tileCount(int size){
|
||||
return 10 * Mathf.pow(3, size) + 2;
|
||||
}///
|
||||
}
|
||||
|
||||
static int cornerCount(int size){
|
||||
return 20 * Mathf.pow(3, size);
|
||||
|
||||
@@ -97,6 +97,8 @@ public class Weapon implements Cloneable{
|
||||
public boolean parentizeEffects;
|
||||
/** internal value used for alternation - do not change! */
|
||||
public int otherSide = -1;
|
||||
/** draw Z offset relative to the default value */
|
||||
public float layerOffset = 0f;
|
||||
/** sound used for shooting */
|
||||
public Sound shootSound = Sounds.pew;
|
||||
/** sound used for weapons that have a delay */
|
||||
@@ -155,12 +157,16 @@ public class Weapon implements Cloneable{
|
||||
Draw.rect(outlineRegion,
|
||||
wx, wy,
|
||||
outlineRegion.width * Draw.scl * -Mathf.sign(flipSprite),
|
||||
region.height * Draw.scl,
|
||||
outlineRegion.height * Draw.scl,
|
||||
weaponRotation);
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(Unit unit, WeaponMount mount){
|
||||
//apply layer offset, roll it back at the end
|
||||
float z = Draw.z();
|
||||
Draw.z(z + layerOffset);
|
||||
|
||||
float
|
||||
rotation = unit.rotation - 90,
|
||||
weaponRotation = rotation + (rotate ? mount.rotation : 0),
|
||||
@@ -171,12 +177,8 @@ public class Weapon implements Cloneable{
|
||||
Drawf.shadow(wx, wy, shadow);
|
||||
}
|
||||
|
||||
if(outlineRegion.found() && top){
|
||||
Draw.rect(outlineRegion,
|
||||
wx, wy,
|
||||
outlineRegion.width * Draw.scl * -Mathf.sign(flipSprite),
|
||||
region.height * Draw.scl,
|
||||
weaponRotation);
|
||||
if(top){
|
||||
drawOutline(unit, mount);
|
||||
}
|
||||
|
||||
Draw.rect(region,
|
||||
@@ -196,6 +198,8 @@ public class Weapon implements Cloneable{
|
||||
Draw.blend();
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
Draw.z(z);
|
||||
}
|
||||
|
||||
public void update(Unit unit, WeaponMount mount){
|
||||
|
||||
@@ -365,7 +365,8 @@ public class JoinDialog extends BaseDialog{
|
||||
|
||||
global.clear();
|
||||
global.background(null);
|
||||
for(ServerGroup group : defaultServers){
|
||||
for(int i = 0; i < defaultServers.size; i ++){
|
||||
ServerGroup group = defaultServers.get((i + defaultServers.size/2) % defaultServers.size);
|
||||
boolean hidden = group.hidden();
|
||||
if(hidden && !showHidden){
|
||||
continue;
|
||||
|
||||
@@ -257,6 +257,12 @@ public class ChatFragment extends Table{
|
||||
return shown;
|
||||
}
|
||||
|
||||
/** @deprecated prefixes are ignored now, just add raw messages */
|
||||
@Deprecated
|
||||
public void addMessage(String pointless, String message){
|
||||
addMessage(message);
|
||||
}
|
||||
|
||||
public void addMessage(String message){
|
||||
if(message == null) return;
|
||||
messages.insert(0, message);
|
||||
|
||||
@@ -265,6 +265,8 @@ public class Block extends UnlockableContent{
|
||||
public boolean quickRotate = true;
|
||||
/** Main subclass. Non-anonymous. */
|
||||
public @Nullable Class<?> subclass;
|
||||
/** Determines if this block gets a higher unloader priority. */
|
||||
public boolean highUnloadPriority = false;
|
||||
|
||||
public float selectScroll; //scroll position for certain blocks
|
||||
public Prov<Building> buildType = null; //initialized later
|
||||
|
||||
@@ -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