From 3d12b66f3c42f652912a4dc90feaa75fbbe84ed7 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 27 Apr 2022 16:37:38 -0400 Subject: [PATCH] DestroyBlocksObjective --- core/assets/bundles/bundle.properties | 1 + core/src/mindustry/content/SectorPresets.java | 2 +- core/src/mindustry/game/MapObjectives.java | 41 ++++++++++++++++++- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 2064be3b30..6b54fe5588 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -577,6 +577,7 @@ configure = Configure Loadout objective.research = [accent]Research:\n[]{0}[lightgray]{1} objective.produce = [accent]Obtain:\n[]{0}[lightgray]{1} objective.destroyblock = [accent]Destroy:\n[]{0}[lightgray]{1} +objective.destroyblocks = [accent]Destroy: [lightgray]{0}[]/{1}\n{2}[lightgray]{3} objective.item = [accent]Obtain: [][lightgray]{0}[]/{1}\n{2}[lightgray]{3} objective.coreitem = [accent]Move into Core:\n[][lightgray]{0}[]/{1}\n{2}[lightgray]{3} objective.build = [accent]Build: [][lightgray]{0}[]x\n{1}[lightgray]{2} diff --git a/core/src/mindustry/content/SectorPresets.java b/core/src/mindustry/content/SectorPresets.java index daa7db2f4c..a9e4cc38e0 100644 --- a/core/src/mindustry/content/SectorPresets.java +++ b/core/src/mindustry/content/SectorPresets.java @@ -1,7 +1,7 @@ package mindustry.content; import mindustry.game.MapObjectives.*; -import mindustry.game.Team; +import mindustry.game.*; import mindustry.graphics.*; import mindustry.type.*; diff --git a/core/src/mindustry/game/MapObjectives.java b/core/src/mindustry/game/MapObjectives.java index 58697249e0..31261bae63 100644 --- a/core/src/mindustry/game/MapObjectives.java +++ b/core/src/mindustry/game/MapObjectives.java @@ -5,6 +5,7 @@ import arc.func.*; import arc.graphics.*; import arc.graphics.g2d.*; import arc.math.*; +import arc.math.geom.*; import arc.scene.ui.layout.*; import arc.util.*; import mindustry.content.*; @@ -20,7 +21,8 @@ public class MapObjectives{ public static Prov[] allObjectiveTypes = new Prov[]{ ResearchObjective::new, BuildCountObjective::new, UnitCountObjective::new, ItemObjective::new, CommandModeObjective::new, CoreItemObjective::new, DestroyCoreObjective::new, DestroyUnitsObjective::new, - TimerObjective::new, FlagObjective::new, DestroyBlockObjective::new, ProduceObjective::new + TimerObjective::new, FlagObjective::new, DestroyBlockObjective::new, ProduceObjective::new, + DestroyBlocksObjective::new }; public static Prov[] allMarkerTypes = new Prov[]{ @@ -270,7 +272,44 @@ public class MapObjectives{ public String text(){ return Core.bundle.format("objective.destroyblock", block.emoji(), block.localizedName); } + } + public static class DestroyBlocksObjective extends MapObjective{ + public int[] positions = {}; + public Team team = Team.crux; + public Block block = Blocks.router; + + public DestroyBlocksObjective(Block block, Team team, int... positions){ + this.block = block; + this.team = team; + this.positions = positions; + } + + public DestroyBlocksObjective(){ + } + + public int progress(){ + int count = 0; + for(var pos : positions){ + int x = Point2.x(pos), y = Point2.y(pos); + + var build = world.build(x, y); + if(build == null || build.team != team || build.block != block){ + count ++; + } + } + return count; + } + + @Override + public boolean complete(){ + return progress() >= positions.length; + } + + @Override + public String text(){ + return Core.bundle.format("objective.destroyblocks", positions, positions.length, block.emoji(), block.localizedName); + } } /** Command any unit to do anything. Always compete in headless mode. */