From eaf02e8328655adde803c347e3e90c544d7e6f4c Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 16 Feb 2022 14:39:59 -0500 Subject: [PATCH] Processor mission set instruction --- core/src/mindustry/game/Rules.java | 2 ++ core/src/mindustry/logic/LExecutor.java | 4 +++- core/src/mindustry/logic/MessageType.java | 3 ++- .../mindustry/ui/fragments/HudFragment.java | 21 ++++++++++++------- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/core/src/mindustry/game/Rules.java b/core/src/mindustry/game/Rules.java index edfb10387d..b8459e2504 100644 --- a/core/src/mindustry/game/Rules.java +++ b/core/src/mindustry/game/Rules.java @@ -130,6 +130,8 @@ public class Rules{ public Color cloudColor = new Color(0f, 0f, 0f, 0f); /** name of the custom mode that this ruleset describes, or null. */ public @Nullable String modeName; + /** Mission string displayed instead of wave/core counter. Null to disable. */ + public @Nullable String mission; /** Whether cores incinerate items when full, just like in the campaign. */ public boolean coreIncinerates = false; /** If false, borders fade out into darkness. Only use with custom backgrounds!*/ diff --git a/core/src/mindustry/logic/LExecutor.java b/core/src/mindustry/logic/LExecutor.java index 7c19944f7e..9a8f3242d4 100644 --- a/core/src/mindustry/logic/LExecutor.java +++ b/core/src/mindustry/logic/LExecutor.java @@ -1365,7 +1365,7 @@ public class LExecutor{ @Override public void run(LExecutor exec){ - if(headless) return; + if(headless && type != MessageType.mission) return; //skip back to self until possible //TODO this is guaranteed desync on servers - I don't see a good solution @@ -1383,6 +1383,8 @@ public class LExecutor{ case notify -> ui.hudfrag.showToast(Icon.info, text); case announce -> ui.announce(text, exec.numf(duration)); case toast -> ui.showInfoToast(text, exec.numf(duration)); + //TODO desync? + case mission -> state.rules.mission = text; } exec.textBuffer.setLength(0); diff --git a/core/src/mindustry/logic/MessageType.java b/core/src/mindustry/logic/MessageType.java index 46eef156f3..2fbe9a3ce9 100644 --- a/core/src/mindustry/logic/MessageType.java +++ b/core/src/mindustry/logic/MessageType.java @@ -3,7 +3,8 @@ package mindustry.logic; public enum MessageType{ notify, announce, - toast; + toast, + mission; public static final MessageType[] all = values(); } diff --git a/core/src/mindustry/ui/fragments/HudFragment.java b/core/src/mindustry/ui/fragments/HudFragment.java index 307fa99ae5..278148a3a5 100644 --- a/core/src/mindustry/ui/fragments/HudFragment.java +++ b/core/src/mindustry/ui/fragments/HudFragment.java @@ -596,13 +596,14 @@ public class HudFragment extends Fragment{ StringBuilder ibuild = new StringBuilder(); - IntFormat wavef = new IntFormat("wave"); - IntFormat wavefc = new IntFormat("wave.cap"); - IntFormat enemyf = new IntFormat("wave.enemy"); - IntFormat enemiesf = new IntFormat("wave.enemies"); - IntFormat enemycf = new IntFormat("wave.enemycore"); - IntFormat enemycsf = new IntFormat("wave.enemycores"); - IntFormat waitingf = new IntFormat("wave.waiting", i -> { + IntFormat + wavef = new IntFormat("wave"), + wavefc = new IntFormat("wave.cap"), + enemyf = new IntFormat("wave.enemy"), + enemiesf = new IntFormat("wave.enemies"), + enemycf = new IntFormat("wave.enemycore"), + enemycsf = new IntFormat("wave.enemycores"), + waitingf = new IntFormat("wave.waiting", i -> { ibuild.setLength(0); int m = i/60; int s = i % 60; @@ -737,6 +738,12 @@ public class HudFragment extends Fragment{ table.labelWrap(() -> { builder.setLength(0); + //mission overrides everything + if(state.rules.mission != null){ + builder.append(state.rules.mission); + return builder; + } + if(!state.rules.waves && state.rules.attackMode){ int sum = Math.max(state.teams.present.sum(t -> t.team != player.team() ? t.cores.size : 0), 1); builder.append(sum > 1 ? enemycsf.get(sum) : enemycf.get(sum));