diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index 0196147dcc..f91d40ba34 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -519,7 +519,7 @@ public class Control implements ApplicationListener, Loadable{ @Override public void pause(){ - if(settings.getBool("backgroundpause", true)){ + if(settings.getBool("backgroundpause", true) && !net.active()){ wasPaused = state.is(State.paused); if(state.is(State.playing)) state.set(State.paused); } @@ -527,7 +527,7 @@ public class Control implements ApplicationListener, Loadable{ @Override public void resume(){ - if(state.is(State.paused) && !wasPaused && settings.getBool("backgroundpause", true)){ + if(state.is(State.paused) && !wasPaused && settings.getBool("backgroundpause", true) && !net.active()){ state.set(State.playing); } } diff --git a/core/src/mindustry/core/Logic.java b/core/src/mindustry/core/Logic.java index f219474d48..2f550f20eb 100644 --- a/core/src/mindustry/core/Logic.java +++ b/core/src/mindustry/core/Logic.java @@ -54,6 +54,10 @@ public class Logic implements ApplicationListener{ it.remove(); } } + + if(event.team == state.rules.defaultTeam){ + state.stats.placedBlockCount.increment(event.tile.block()); + } } }); diff --git a/core/src/mindustry/game/GameStats.java b/core/src/mindustry/game/GameStats.java index 5b54385e32..964b3fd9cd 100644 --- a/core/src/mindustry/game/GameStats.java +++ b/core/src/mindustry/game/GameStats.java @@ -1,5 +1,8 @@ package mindustry.game; +import arc.struct.*; +import mindustry.world.*; + public class GameStats{ /** Enemy (red team) units destroyed. */ public int enemyUnitsDestroyed; @@ -13,4 +16,6 @@ public class GameStats{ public int buildingsDestroyed; /** Total units created by any means. */ public int unitsCreated; + /** Record of blocks that have been placed by count. Used for objectives only. */ + public ObjectIntMap placedBlockCount = new ObjectIntMap<>(); } diff --git a/core/src/mindustry/game/MapObjectives.java b/core/src/mindustry/game/MapObjectives.java index e152e3c03b..ced562435c 100644 --- a/core/src/mindustry/game/MapObjectives.java +++ b/core/src/mindustry/game/MapObjectives.java @@ -11,10 +11,11 @@ import mindustry.ctype.*; import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; +import mindustry.world.*; public class MapObjectives{ public static Prov[] allObjectiveTypes = new Prov[]{ - ResearchObjective::new + ResearchObjective::new, PlaceCountObjective::new, ItemObjective::new }; public static Prov[] allMarkerTypes = new Prov[]{ @@ -70,6 +71,29 @@ public class MapObjectives{ } } + public static class PlaceCountObjective extends MapObjective{ + public Block block = Blocks.conveyor; + public int placeCount = 1; + + public PlaceCountObjective(Block block, int placeCount){ + this.block = block; + this.placeCount = placeCount; + } + + public PlaceCountObjective(){ + } + + @Override + public String text(){ + return Core.bundle.format("objective.place", placeCount, block.emoji(), block.localizedName); + } + + @Override + public boolean complete(){ + return Vars.state.stats.placedBlockCount.get(block, 0) >= placeCount; + } + } + public static abstract class MapObjective{ public ObjectiveMarker[] markers = {}; diff --git a/core/src/mindustry/graphics/MenuRenderer.java b/core/src/mindustry/graphics/MenuRenderer.java index a1f594f193..207b38a57c 100644 --- a/core/src/mindustry/graphics/MenuRenderer.java +++ b/core/src/mindustry/graphics/MenuRenderer.java @@ -46,24 +46,24 @@ public class MenuRenderer implements Disposable{ shadows = new FrameBuffer(width, height); int offset = Mathf.random(100000); int s1 = offset, s2 = offset + 1, s3 = offset + 2; - Block[] selected = Structs.select( - new Block[]{Blocks.sand, Blocks.sandWall}, - new Block[]{Blocks.shale, Blocks.shaleWall}, - new Block[]{Blocks.ice, Blocks.iceWall}, - new Block[]{Blocks.sand, Blocks.sandWall}, - new Block[]{Blocks.shale, Blocks.shaleWall}, - new Block[]{Blocks.ice, Blocks.iceWall}, - new Block[]{Blocks.moss, Blocks.sporePine}, - new Block[]{Blocks.dirt, Blocks.dirtWall}, - new Block[]{Blocks.dacite, Blocks.daciteWall} + Block[] selected = Structs.random( + new Block[]{Blocks.sand, Blocks.sandWall}, + new Block[]{Blocks.shale, Blocks.shaleWall}, + new Block[]{Blocks.ice, Blocks.iceWall}, + new Block[]{Blocks.sand, Blocks.sandWall}, + new Block[]{Blocks.shale, Blocks.shaleWall}, + new Block[]{Blocks.ice, Blocks.iceWall}, + new Block[]{Blocks.moss, Blocks.sporePine}, + new Block[]{Blocks.dirt, Blocks.dirtWall}, + new Block[]{Blocks.dacite, Blocks.daciteWall} ); - Block[] selected2 = Structs.select( - new Block[]{Blocks.basalt, Blocks.duneWall}, - new Block[]{Blocks.basalt, Blocks.duneWall}, - new Block[]{Blocks.stone, Blocks.stoneWall}, - new Block[]{Blocks.stone, Blocks.stoneWall}, - new Block[]{Blocks.moss, Blocks.sporeWall}, - new Block[]{Blocks.salt, Blocks.saltWall} + Block[] selected2 = Structs.random( + new Block[]{Blocks.basalt, Blocks.duneWall}, + new Block[]{Blocks.basalt, Blocks.duneWall}, + new Block[]{Blocks.stone, Blocks.stoneWall}, + new Block[]{Blocks.stone, Blocks.stoneWall}, + new Block[]{Blocks.moss, Blocks.sporeWall}, + new Block[]{Blocks.salt, Blocks.saltWall} ); Block ore1 = ores.random(); diff --git a/gradle.properties b/gradle.properties index 0ff42854f7..d94fd0ea96 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,4 +25,4 @@ org.gradle.caching=true #used for slow jitpack builds; TODO see if this actually works org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.connectionTimeout=100000 -archash=2eb7608c5d +archash=2fd232cbb5