diff --git a/core/src/mindustry/core/Logic.java b/core/src/mindustry/core/Logic.java index 34626b9b7a..c3dd4654f8 100644 --- a/core/src/mindustry/core/Logic.java +++ b/core/src/mindustry/core/Logic.java @@ -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); diff --git a/core/src/mindustry/game/MapObjectives.java b/core/src/mindustry/game/MapObjectives.java new file mode 100644 index 0000000000..28acfaa58d --- /dev/null +++ b/core/src/mindustry/game/MapObjectives.java @@ -0,0 +1,29 @@ +package mindustry.game; + +import arc.func.*; +import arc.struct.*; +import arc.util.*; + +public class MapObjectives{ + public static Seq> 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; + } + } +} diff --git a/core/src/mindustry/game/Rules.java b/core/src/mindustry/game/Rules.java index 21c485f9f0..bb2ee57634 100644 --- a/core/src/mindustry/game/Rules.java +++ b/core/src/mindustry/game/Rules.java @@ -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 researched = new ObjectSet<>(); /** Block containing these items as requirements are hidden. */ public ObjectSet hiddenBuildItems = Items.erekirOnlyItems.asSet(); + /** Campaign-only map objectives. */ + public Seq 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. */ diff --git a/core/src/mindustry/io/JsonIO.java b/core/src/mindustry/io/JsonIO.java index 8cc9119fcc..a65d7d82ad 100644 --- a/core/src/mindustry/io/JsonIO.java +++ b/core/src/mindustry/io/JsonIO.java @@ -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{ diff --git a/core/src/mindustry/logic/LExecutor.java b/core/src/mindustry/logic/LExecutor.java index a934971aa7..eec07afc33 100644 --- a/core/src/mindustry/logic/LExecutor.java +++ b/core/src/mindustry/logic/LExecutor.java @@ -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 = {};