More objective stuff

This commit is contained in:
Anuken
2022-04-12 13:28:22 -04:00
parent c5d89ea6bf
commit 0902a675db
5 changed files with 54 additions and 3 deletions

View File

@@ -115,7 +115,7 @@ public class SectorPresets{
difficulty = 1;
rules = r -> {
r.objectives.addAll(new ResearchObjective(Items.beryllium){{
r.objectives.addAll(new ItemObjective(Items.beryllium, 20){{
markers = new ObjectiveMarker[]{
new TextMarker("Units can mine [accent]resources[] from walls.", 1984f, 2240f + 16f),
new ShapeMarker(1984f, 2240f),

View File

@@ -313,6 +313,7 @@ public class Logic implements ApplicationListener{
if(!net.client() && first.complete()){
state.rules.objectives.remove(0);
first.completed();
if(!headless){
//delete markers
for(var marker : first.markers){

View File

@@ -5,10 +5,12 @@ import arc.func.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.util.*;
import mindustry.*;
import mindustry.content.*;
import mindustry.ctype.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.type.*;
public class MapObjectives{
public static Prov<MapObjective>[] allObjectiveTypes = new Prov[]{
@@ -45,6 +47,29 @@ public class MapObjectives{
}
}
public static class ItemObjective extends MapObjective{
public Item item = Items.copper;
public int amount = 1;
public ItemObjective(Item item, int amount){
this.item = item;
this.amount = amount;
}
public ItemObjective(){
}
@Override
public String text(){
return Core.bundle.format("objective.item", Vars.state.rules.defaultTeam.items().get(item), amount, item.emoji(), item.localizedName);
}
@Override
public boolean complete(){
return Vars.state.rules.defaultTeam.items().has(item, amount);
}
}
public static abstract class MapObjective{
public ObjectiveMarker[] markers = {};
@@ -52,6 +77,11 @@ public class MapObjectives{
return false;
}
/** Called immediately after this objective is completed and removed from the rules. */
public void completed(){
}
public void update(){
}
@@ -61,10 +91,12 @@ public class MapObjectives{
}
/** Basic mission display text. */
public @Nullable String text(){
return null;
}
/** Details that appear upon click. */
public @Nullable String details(){
return null;
}

View File

@@ -215,7 +215,7 @@ public class HudFragment{
}else{
logic.skipWave();
}
}).growY().fillX().right().width(40f).disabled(b -> !canSkipWave()).name("skip");
}).growY().fillX().right().width(40f).disabled(b -> !canSkipWave()).name("skip").get().toBack();
}).width(dsize * 5 + 4f).name("statustable");
wavesMain.row();
@@ -744,7 +744,24 @@ public class HudFragment{
t.getChildren().get(1).toFront();
})).size(120f, 80).padRight(4);
table.labelWrap(() -> {
Cell[] lcell = {null};
boolean[] couldSkip = {true};
lcell[0] = table.labelWrap(() -> {
//update padding depend on whether the button to the right is there
boolean can = canSkipWave();
if(can != couldSkip[0]){
if(canSkipWave()){
lcell[0].padRight(8f);
}else{
lcell[0].padRight(-42f);
}
table.invalidateHierarchy();
table.pack();
couldSkip[0] = can;
}
builder.setLength(0);
//objectives override mission?