From ee4b8c77e44bf8e97c2514c945ffaea847faae33 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 12 Feb 2022 14:28:43 -0500 Subject: [PATCH] Basic logic cutscene stuff --- .../blocks/payload/payload-mass-driver.png | Bin 1388 -> 1332 bytes core/src/mindustry/input/DesktopInput.java | 3 + core/src/mindustry/input/InputHandler.java | 13 +++- core/src/mindustry/logic/CutsceneAction.java | 9 +++ core/src/mindustry/logic/LExecutor.java | 36 +++++++++++ core/src/mindustry/logic/LStatements.java | 56 ++++++++++++++++++ 6 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 core/src/mindustry/logic/CutsceneAction.java diff --git a/core/assets-raw/sprites/blocks/payload/payload-mass-driver.png b/core/assets-raw/sprites/blocks/payload/payload-mass-driver.png index 5346bea41b692bcfe28cf31a67e9a41b9e7cdb81..f8a1dee44427f392533aad58374899f217371de9 100644 GIT binary patch delta 1301 zcmV+w1?u|j3bYE4FnKW-E;6vkf=7obQ%ADWdoz)Bp24kUi7rP$$^nSBNqP#39APP%w{(fuw`QHvvS65e8S65dR z9p!xZ{`&l|dpZvOZ?iceBBIZyAG7kPt&7X61JO%;#yZ1}(#=t9eoBWwU(Izi0g#%{S|S9g`7A30H2|&otR+Fvn$NO8Pyw)--;%Tt!~nYa za%mul09c!3%aV4vNdQyk$3oDS^z-gr^nVfvlK{H;GUY&s0_f)JWQ7m}(9O5W0znmq zO3jZ=+n22U{(n)FZVEz3VgN0h&+>p^UJD9o&E~VD5Tt?uXu*6I5&{H3OXjms5V8SC z&0o^Kz>jZNqOu|&WC1vR^G}p+N#?Vp5YDy_S^1a&tl4~42?!phM)!@H9xm$ z&PkqiRsm?ye3n<;#Q<71pXK2}RunW|o>;T_tT6=b+JDbjW&kak&q6{l0chEL77BtI zKsWzI2na6w0WGWgen3~j{QzlLwr0(CEhslUo0C$le|Bp@YcikZ1p&Smv_|t;9uS~w zL2EXjg@yoI3u?i977_wvPq-!XS*Wl)8$gTZvk(xV=YqQQas{xYY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+@b{x_jb^XuvlX&piv<`cCDfaunQF3exAKUQYByl&0>qN1XrqP+DNnsy0354&Qx P00000NkvXXu0mjf&F*7K diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index 75d8a31f91..08f9d60dba 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -337,6 +337,9 @@ public class DesktopInput extends InputHandler{ if(player.dead() || locked){ cursorType = SystemCursor.arrow; + if(!Core.scene.hasMouse()){ + Core.graphics.cursor(cursorType); + } return; } diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index 58c4a7a2e8..281f4ef2d5 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -53,8 +53,13 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ public final OverlayFragment frag = new OverlayFragment(); + /** If true, there is a cutscene currently occurring in logic. */ + public boolean logicCutscene; + public Vec2 logicCamPan = new Vec2(); + public float logicCamSpeed = 0.1f; + /** If any of these functions return true, input is locked. */ - public Seq inputLocks = Seq.with(() -> renderer.isCutscene()); + public Seq inputLocks = Seq.with(() -> renderer.isCutscene(), () -> logicCutscene); public Interval controlInterval = new Interval(); public @Nullable Block block; public boolean overrideLineRotation; @@ -576,6 +581,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } public void update(){ + if(logicCutscene && !renderer.isCutscene()){ + Core.camera.position.lerpDelta(logicCamPan, logicCamSpeed); + } + playerPlanTree.clear(); player.unit().plans.each(playerPlanTree::insert); @@ -596,6 +605,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ //you don't want selected blocks while locked, looks weird if(locked()){ block = null; + } wasShooting = player.shooting; @@ -678,6 +688,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ public void updateState(){ if(state.isMenu()){ controlledType = null; + logicCutscene = false; } } diff --git a/core/src/mindustry/logic/CutsceneAction.java b/core/src/mindustry/logic/CutsceneAction.java new file mode 100644 index 0000000000..9026eea44f --- /dev/null +++ b/core/src/mindustry/logic/CutsceneAction.java @@ -0,0 +1,9 @@ +package mindustry.logic; + +public enum CutsceneAction{ + pan, + zoom, + stop; + + public static final CutsceneAction[] all = values(); +} diff --git a/core/src/mindustry/logic/LExecutor.java b/core/src/mindustry/logic/LExecutor.java index b93cc388ff..ee4afec401 100644 --- a/core/src/mindustry/logic/LExecutor.java +++ b/core/src/mindustry/logic/LExecutor.java @@ -1118,6 +1118,42 @@ public class LExecutor{ } } + public static class CutsceneI implements LInstruction{ + public CutsceneAction action = CutsceneAction.stop; + public int p1, p2, p3, p4; + + public CutsceneI(CutsceneAction action, int p1, int p2, int p3, int p4){ + this.action = action; + this.p1 = p1; + this.p2 = p2; + this.p3 = p3; + this.p4 = p4; + } + + public CutsceneI(){ + } + + @Override + public void run(LExecutor exec){ + if(headless) return; + + switch(action){ + case pan -> { + control.input.logicCutscene = true; + control.input.logicCamPan.set(World.unconv(exec.numf(p1)), World.unconv(exec.numf(p2))); + control.input.logicCamSpeed = exec.numf(p3); + } + case zoom -> { + control.input.logicCutscene = true; + renderer.setScale(Mathf.lerp(renderer.minZoom, renderer.maxZoom, Mathf.clamp(exec.numf(p1)))); + } + case stop -> { + control.input.logicCutscene = false; + } + } + } + } + //endregion //region privileged / world instructions diff --git a/core/src/mindustry/logic/LStatements.java b/core/src/mindustry/logic/LStatements.java index 8f5d5b894b..c7dac168c5 100644 --- a/core/src/mindustry/logic/LStatements.java +++ b/core/src/mindustry/logic/LStatements.java @@ -1294,4 +1294,60 @@ public class LStatements{ return new FlushNotificationI(); } } + + @RegisterStatement("cutscene") + public static class CutsceneStatement extends LStatement{ + public CutsceneAction action = CutsceneAction.pan; + public String p1 = "100", p2 = "100", p3 = " 0.06", p4 = "0"; + + @Override + public void build(Table table){ + rebuild(table); + } + + void rebuild(Table table){ + table.clearChildren(); + + table.button(b -> { + b.label(() -> action.name()).growX().wrap().labelAlign(Align.center); + b.clicked(() -> showSelect(b, CutsceneAction.all, action, o -> { + action = o; + rebuild(table); + })); + }, Styles.logict, () -> {}).size(90f, 40f).padLeft(2).color(table.color); + + switch(action){ + case pan -> { + table.add(" x "); + fields(table, p1, str -> p1 = str); + table.add(" y "); + fields(table, p2, str -> p2 = str); + + row(table); + + table.add(" speed "); + fields(table, p3, str -> p3 = str); + } + case zoom -> { + table.add(" level "); + fields(table, p1, str -> p1 = str); + } + } + } + + @Override + public boolean privileged(){ + return true; + } + + @Override + public Color color(){ + return Pal.logicWorld; + } + + @Override + public LInstruction build(LAssembler builder){ + return new CutsceneI(action, builder.var(p1), builder.var(p2), builder.var(p3), builder.var(p4)); + } + } }