mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-08 14:57:18 +07:00
@ -53,7 +53,7 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
|
|
||||||
private Interval timer = new Interval(2);
|
private Interval timer = new Interval(2);
|
||||||
private boolean hiscore = false;
|
private boolean hiscore = false;
|
||||||
private boolean wasPaused = false;
|
private boolean wasPaused = false, backgroundPaused = false;
|
||||||
private Seq<Building> toBePlaced = new Seq<>(false);
|
private Seq<Building> toBePlaced = new Seq<>(false);
|
||||||
|
|
||||||
public Control(){
|
public Control(){
|
||||||
@ -558,6 +558,7 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
@Override
|
@Override
|
||||||
public void pause(){
|
public void pause(){
|
||||||
if(settings.getBool("backgroundpause", true) && !net.active()){
|
if(settings.getBool("backgroundpause", true) && !net.active()){
|
||||||
|
backgroundPaused = true;
|
||||||
wasPaused = state.is(State.paused);
|
wasPaused = state.is(State.paused);
|
||||||
if(state.is(State.playing)) state.set(State.paused);
|
if(state.is(State.playing)) state.set(State.paused);
|
||||||
}
|
}
|
||||||
@ -568,6 +569,7 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
if(state.is(State.paused) && !wasPaused && settings.getBool("backgroundpause", true) && !net.active()){
|
if(state.is(State.paused) && !wasPaused && settings.getBool("backgroundpause", true) && !net.active()){
|
||||||
state.set(State.playing);
|
state.set(State.playing);
|
||||||
}
|
}
|
||||||
|
backgroundPaused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -659,6 +661,10 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
core.items.each((i, a) -> i.unlock());
|
core.items.each((i, a) -> i.unlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(backgroundPaused && settings.getBool("backgroundpause") && !net.active()){
|
||||||
|
state.set(State.paused);
|
||||||
|
}
|
||||||
|
|
||||||
//cannot launch while paused
|
//cannot launch while paused
|
||||||
if(state.isPaused() && renderer.isCutscene()){
|
if(state.isPaused() && renderer.isCutscene()){
|
||||||
state.set(State.playing);
|
state.set(State.playing);
|
||||||
|
@ -113,6 +113,10 @@ public class Placement{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void calculateBridges(Seq<BuildPlan> plans, ItemBridge bridge){
|
public static void calculateBridges(Seq<BuildPlan> plans, ItemBridge bridge){
|
||||||
|
calculateBridges(plans, bridge, t -> false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void calculateBridges(Seq<BuildPlan> plans, ItemBridge bridge, Boolf<Block> avoid){
|
||||||
if(isSidePlace(plans) || plans.size == 0) return;
|
if(isSidePlace(plans) || plans.size == 0) return;
|
||||||
|
|
||||||
//check for orthogonal placement + unlocked state
|
//check for orthogonal placement + unlocked state
|
||||||
@ -120,11 +124,11 @@ public class Placement{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolf<BuildPlan> placeable = plan -> (plan.placeable(player.team())) ||
|
Boolf<BuildPlan> placeable = plan ->
|
||||||
(plan.tile() != null && plan.tile().block() == plan.block); //don't count the same block as inaccessible
|
(plan.placeable(player.team()) || (plan.tile() != null && plan.tile().block() == plan.block)) && //don't count the same block as inaccessible
|
||||||
|
!(plan.build() != null && plan.build().rotation != plan.rotation && avoid.get(plan.tile().block()));
|
||||||
|
|
||||||
var result = plans1.clear();
|
var result = plans1.clear();
|
||||||
var team = player.team();
|
|
||||||
var rotated = plans.first().tile() != null && plans.first().tile().absoluteRelativeTo(plans.peek().x, plans.peek().y) == Mathf.mod(plans.first().rotation + 2, 4);
|
var rotated = plans.first().tile() != null && plans.first().tile().absoluteRelativeTo(plans.peek().x, plans.peek().y) == Mathf.mod(plans.first().rotation + 2, 4);
|
||||||
|
|
||||||
outer:
|
outer:
|
||||||
@ -134,6 +138,7 @@ public class Placement{
|
|||||||
|
|
||||||
//gap found
|
//gap found
|
||||||
if(i < plans.size - 1 && placeable.get(cur) && !placeable.get(plans.get(i + 1))){
|
if(i < plans.size - 1 && placeable.get(cur) && !placeable.get(plans.get(i + 1))){
|
||||||
|
boolean wereSame = true;
|
||||||
|
|
||||||
//find the closest valid position within range
|
//find the closest valid position within range
|
||||||
for(int j = i + 1; j < plans.size; j++){
|
for(int j = i + 1; j < plans.size; j++){
|
||||||
@ -147,18 +152,29 @@ public class Placement{
|
|||||||
}
|
}
|
||||||
i = j;
|
i = j;
|
||||||
continue outer;
|
continue outer;
|
||||||
}else if(other.placeable(team)){
|
}else if(placeable.get(other)){
|
||||||
//found a link, assign bridges
|
|
||||||
cur.block = bridge;
|
|
||||||
other.block = bridge;
|
|
||||||
if(rotated){
|
|
||||||
other.config = new Point2(cur.x - other.x, cur.y - other.y);
|
|
||||||
}else{
|
|
||||||
cur.config = new Point2(other.x - cur.x, other.y - cur.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
i = j;
|
if(wereSame){
|
||||||
continue outer;
|
//the gap is fake, it's just conveyors that can be replaced with junctions
|
||||||
|
i ++;
|
||||||
|
continue outer;
|
||||||
|
}else{
|
||||||
|
//found a link, assign bridges
|
||||||
|
cur.block = bridge;
|
||||||
|
other.block = bridge;
|
||||||
|
if(rotated){
|
||||||
|
other.config = new Point2(cur.x - other.x, cur.y - other.y);
|
||||||
|
}else{
|
||||||
|
cur.config = new Point2(other.x - cur.x, other.y - cur.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
i = j;
|
||||||
|
continue outer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(other.tile() != null && !avoid.get(other.tile().block())){
|
||||||
|
wereSame = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +191,7 @@ public class Placement{
|
|||||||
plans.set(result);
|
plans.set(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void calculateBridges(Seq<BuildPlan> plans, DirectionBridge bridge, boolean hasJunction, Boolf<Block> same){
|
public static void calculateBridges(Seq<BuildPlan> plans, DirectionBridge bridge, boolean hasJunction, Boolf<Block> avoid){
|
||||||
if(isSidePlace(plans) || plans.size == 0) return;
|
if(isSidePlace(plans) || plans.size == 0) return;
|
||||||
|
|
||||||
//check for orthogonal placement + unlocked state
|
//check for orthogonal placement + unlocked state
|
||||||
@ -183,13 +199,9 @@ public class Placement{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolf<BuildPlan> rotated = plan -> plan.build() != null && same.get(plan.build().block) && plan.rotation != plan.build().rotation;
|
|
||||||
|
|
||||||
//TODO for chains of ducts, do not count consecutives in a different rotation as 'placeable'
|
|
||||||
Boolf<BuildPlan> placeable = plan ->
|
Boolf<BuildPlan> placeable = plan ->
|
||||||
!(!hasJunction && rotated.get(plan)) &&
|
(plan.placeable(player.team()) || (plan.tile() != null && plan.tile().block() == plan.block)) && //don't count the same block as inaccessible
|
||||||
(plan.placeable(player.team()) ||
|
!(plan.build() != null && plan.build().rotation != plan.rotation && avoid.get(plan.tile().block()));
|
||||||
(plan.tile() != null && same.get(plan.tile().block()))); //don't count the same block as inaccessible
|
|
||||||
|
|
||||||
var result = plans1.clear();
|
var result = plans1.clear();
|
||||||
|
|
||||||
@ -199,10 +211,11 @@ public class Placement{
|
|||||||
result.add(cur);
|
result.add(cur);
|
||||||
|
|
||||||
//gap found
|
//gap found
|
||||||
if(i < plans.size - 1 && placeable.get(cur) && (!placeable.get(plans.get(i + 1)) || (hasJunction && rotated.get(plans.get(i + 1)) && i < plans.size - 2 && !placeable.get(plans.get(i + 2))))){
|
if(i < plans.size - 1 && placeable.get(cur) && !placeable.get(plans.get(i + 1))){
|
||||||
|
boolean wereSame = true;
|
||||||
|
|
||||||
//find the closest valid position within range
|
//find the closest valid position within range
|
||||||
for(int j = i + 2; j < plans.size; j++){
|
for(int j = i + 1; j < plans.size; j++){
|
||||||
var other = plans.get(j);
|
var other = plans.get(j);
|
||||||
|
|
||||||
//out of range now, set to current position and keep scanning forward for next occurrence
|
//out of range now, set to current position and keep scanning forward for next occurrence
|
||||||
@ -214,12 +227,22 @@ public class Placement{
|
|||||||
i = j;
|
i = j;
|
||||||
continue outer;
|
continue outer;
|
||||||
}else if(placeable.get(other)){
|
}else if(placeable.get(other)){
|
||||||
//found a link, assign bridges
|
|
||||||
cur.block = bridge;
|
|
||||||
other.block = bridge;
|
|
||||||
|
|
||||||
i = j;
|
if(wereSame && hasJunction){
|
||||||
continue outer;
|
//the gap is fake, it's just conveyors that can be replaced with junctions
|
||||||
|
i ++;
|
||||||
|
continue outer;
|
||||||
|
}else{
|
||||||
|
//found a link, assign bridges
|
||||||
|
cur.block = bridge;
|
||||||
|
other.block = bridge;
|
||||||
|
i = j;
|
||||||
|
continue outer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(other.tile() != null && !avoid.get(other.tile().block())){
|
||||||
|
wereSame = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,9 +464,11 @@ public class SchematicsDialog extends BaseDialog{
|
|||||||
|
|
||||||
for(var tag : tags){
|
for(var tag : tags){
|
||||||
|
|
||||||
var next = new Table(n -> {
|
var next = new Table(Tex.whiteui, n -> {
|
||||||
n.table(Tex.pane, move -> {
|
n.setColor(Pal.gray);
|
||||||
move.margin(2);
|
n.margin(5f);
|
||||||
|
|
||||||
|
n.table(move -> {
|
||||||
|
|
||||||
//move up
|
//move up
|
||||||
move.button(Icon.upOpen, Styles.emptyi, () -> {
|
move.button(Icon.upOpen, Styles.emptyi, () -> {
|
||||||
@ -486,10 +488,9 @@ public class SchematicsDialog extends BaseDialog{
|
|||||||
rebuild[0].run();
|
rebuild[0].run();
|
||||||
}
|
}
|
||||||
}).tooltip("@editor.movedown");
|
}).tooltip("@editor.movedown");
|
||||||
}).fillY().margin(6f);
|
}).fillY();
|
||||||
|
|
||||||
n.table(Tex.whiteui, t -> {
|
n.table(t -> {
|
||||||
t.setColor(Pal.gray);
|
|
||||||
t.add(tag).left().row();
|
t.add(tag).left().row();
|
||||||
t.add(Core.bundle.format("schematic.tagged", schematics.all().count(s -> s.labels.contains(tag)))).left()
|
t.add(Core.bundle.format("schematic.tagged", schematics.all().count(s -> s.labels.contains(tag)))).left()
|
||||||
.update(b -> b.setColor(b.hasMouse() ? Pal.accent : Color.lightGray)).get().clicked(() -> {
|
.update(b -> b.setColor(b.hasMouse() ? Pal.accent : Color.lightGray)).get().clicked(() -> {
|
||||||
@ -498,9 +499,9 @@ public class SchematicsDialog extends BaseDialog{
|
|||||||
rebuildTags.run();
|
rebuildTags.run();
|
||||||
rebuildPane.run();
|
rebuildPane.run();
|
||||||
});
|
});
|
||||||
}).growX().fillY().margin(8f);
|
}).growX().fillY();
|
||||||
|
|
||||||
n.table(Tex.pane, b -> {
|
n.table(b -> {
|
||||||
b.margin(2);
|
b.margin(2);
|
||||||
|
|
||||||
//rename tag
|
//rename tag
|
||||||
@ -541,13 +542,13 @@ public class SchematicsDialog extends BaseDialog{
|
|||||||
rebuild[0].run();
|
rebuild[0].run();
|
||||||
});
|
});
|
||||||
}).tooltip("@save.delete");
|
}).tooltip("@save.delete");
|
||||||
}).fillY().margin(6f);
|
}).fillY();
|
||||||
});
|
});
|
||||||
|
|
||||||
next.pack();
|
next.pack();
|
||||||
float w = next.getPrefWidth() + Scl.scl(6f);
|
float w = next.getWidth() + Scl.scl(6f);
|
||||||
|
|
||||||
if(w + sum >= Core.graphics.getWidth() * (Core.graphics.isPortrait() ? 1f : 0.8f)){
|
if(w*2f + sum >= Core.graphics.getWidth() * 0.8f){
|
||||||
p.add(current).row();
|
p.add(current).row();
|
||||||
current = new Table();
|
current = new Table();
|
||||||
current.left();
|
current.left();
|
||||||
|
@ -92,7 +92,7 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
public void handlePlacementLine(Seq<BuildPlan> plans){
|
public void handlePlacementLine(Seq<BuildPlan> plans){
|
||||||
if(bridgeReplacement == null) return;
|
if(bridgeReplacement == null) return;
|
||||||
|
|
||||||
Placement.calculateBridges(plans, (ItemBridge)bridgeReplacement);
|
Placement.calculateBridges(plans, (ItemBridge)bridgeReplacement, b -> b instanceof Conveyor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -140,7 +140,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
|||||||
if(rotBridgeReplacement instanceof DirectionBridge duct){
|
if(rotBridgeReplacement instanceof DirectionBridge duct){
|
||||||
Placement.calculateBridges(plans, duct, true, b -> b instanceof Conduit);
|
Placement.calculateBridges(plans, duct, true, b -> b instanceof Conduit);
|
||||||
}else{
|
}else{
|
||||||
Placement.calculateBridges(plans, (ItemBridge)bridgeReplacement);
|
Placement.calculateBridges(plans, (ItemBridge)bridgeReplacement, b -> b instanceof Conduit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user