WIP map objective system

This commit is contained in:
Anuken
2022-04-11 23:59:38 -04:00
parent 5e65e250c3
commit a4ba1ed340
5 changed files with 55 additions and 1 deletions

View File

@@ -435,6 +435,22 @@ public class Logic implements ApplicationListener{
}
}
//TODO objectives clientside???
//update objectives; do not get completed clientside
if(state.rules.objectives.size > 0){
var first = state.rules.objectives.first();
first.update();
if(!net.client() && first.complete()){
state.rules.objectives.remove(0);
//TODO call packet for this?
if(net.server()){
Call.setRules(state.rules);
}
}
}
if(state.rules.waves && state.rules.waveTimer && !state.gameOver){
if(!isWaitingWave()){
state.wavetime = Math.max(state.wavetime - Time.delta, 0);

View File

@@ -0,0 +1,29 @@
package mindustry.game;
import arc.func.*;
import arc.struct.*;
import arc.util.*;
public class MapObjectives{
public static Seq<Prov<MapObjective>> allObjectiveTypes = Seq.with();
public abstract class MapObjective{
public boolean complete(){
return false;
}
public void update(){
}
/** Reset internal state, if any. */
public void reset(){
}
public @Nullable String details(){
return null;
}
}
}

View File

@@ -6,6 +6,7 @@ import arc.util.*;
import arc.util.serialization.*;
import arc.util.serialization.Json.*;
import mindustry.content.*;
import mindustry.game.MapObjectives.*;
import mindustry.graphics.g3d.*;
import mindustry.io.*;
import mindustry.type.*;
@@ -115,6 +116,8 @@ public class Rules{
public ObjectSet<String> researched = new ObjectSet<>();
/** Block containing these items as requirements are hidden. */
public ObjectSet<Item> hiddenBuildItems = Items.erekirOnlyItems.asSet();
/** Campaign-only map objectives. */
public Seq<MapObjective> objectives = new Seq<>();
/** HIGHLY UNSTABLE/EXPERIMENTAL. DO NOT USE THIS. */
public boolean fog = false;
/** If fog = true, this is whether static (black) fog is enabled. */

View File

@@ -242,6 +242,12 @@ public class JsonIO{
var i = filter.get();
json.addClassTag(Strings.camelize(i.getClass().getSimpleName().replace("Filter", "")), i.getClass());
}
//use short names for all objective types
for(var obj : MapObjectives.allObjectiveTypes){
var i = obj.get();
json.addClassTag(Strings.camelize(i.getClass().getSimpleName().replace("Objective", "")), i.getClass());
}
}
static class CustomJson extends Json{

View File

@@ -40,7 +40,7 @@ public class LExecutor{
public static final int
maxGraphicsBuffer = 256,
maxDisplayBuffer = 1024,
maxTextBuffer = 256;
maxTextBuffer = 400;
public LInstruction[] instructions = {};
public Var[] vars = {};