From 5ca5025fb1076789813333bb84451d1767362362 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 27 Jul 2021 19:02:04 -0400 Subject: [PATCH] Final core launch animation / Added option to skip core animations --- core/assets/bundles/bundle.properties | 1 + core/src/mindustry/Vars.java | 8 ++--- core/src/mindustry/content/Fx.java | 10 ++++++ core/src/mindustry/core/Control.java | 7 +++- core/src/mindustry/core/Renderer.java | 19 ++++++++-- .../mindustry/ui/dialogs/PlanetDialog.java | 36 ++++++++++++++----- .../ui/dialogs/SettingsMenuDialog.java | 2 ++ 7 files changed, 65 insertions(+), 18 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 099e1b7140..f03d682c12 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -835,6 +835,7 @@ category.items = Items category.crafting = Input/Output category.function = Function category.optional = Optional Enhancements +setting.skipcoreanimation.name = Skip Core Launch/Land Animation setting.landscape.name = Lock Landscape setting.shadows.name = Shadows setting.blockreplace.name = Automatic Block Suggestions diff --git a/core/src/mindustry/Vars.java b/core/src/mindustry/Vars.java index f27fc0f77c..dbd8e9cc42 100644 --- a/core/src/mindustry/Vars.java +++ b/core/src/mindustry/Vars.java @@ -103,8 +103,8 @@ public class Vars implements Loadable{ public static final float invasionGracePeriod = 20; /** min armor fraction damage; e.g. 0.05 = at least 5% damage */ public static final float minArmorDamage = 0.1f; - /** land animation duration */ - public static final float coreLandDuration = 150f; + /** land/launch animation duration */ + public static final float coreLandDuration = 160f; /** size of tiles in units */ public static final int tilesize = 8; /** size of one tile payload (^2) */ @@ -142,10 +142,6 @@ public class Vars implements Loadable{ public static boolean clientLoaded = false; /** max GL texture size */ public static int maxTextureSize = 2048; - /** Whether to show the core landing animation. */ - public static boolean showLandAnimation = true; - /** Whether to show the campaign core launch animation. */ - public static boolean showLaunchAnimation = true; /** Whether to show sector info upon landing. */ public static boolean showSectorLandInfo = true; /** Whether to check for memory use before taking screenshots. */ diff --git a/core/src/mindustry/content/Fx.java b/core/src/mindustry/content/Fx.java index dc11b79f36..28ab6e7a3b 100644 --- a/core/src/mindustry/content/Fx.java +++ b/core/src/mindustry/content/Fx.java @@ -184,6 +184,16 @@ public class Fx{ Lines.square(e.x, e.y, tilesize / 2f * e.rotation + e.fin() * 3f); }), + coreLaunchConstruct = new Effect(35, e -> { + color(Pal.accent); + stroke(4f - e.fin() * 3f); + Lines.square(e.x, e.y, tilesize / 2f * e.rotation * 1.2f + e.fin() * 5f); + + randLenVectors(e.id, 5 + (int)(e.rotation * 5), e.rotation * 3f + (tilesize * e.rotation) * e.finpow() * 1.5f, (x, y) -> { + Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * (4f + e.rotation)); + }); + }), + tapBlock = new Effect(12, e -> { color(Pal.accent); stroke(3f - e.fin() * 2f); diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index ff42a5e6c0..e4f84b8d38 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -201,7 +201,7 @@ public class Control implements ApplicationListener, Loadable{ camera.position.set(core); player.set(core); - if(showLandAnimation){ + if(!settings.getBool("skipcoreanimation")){ //delay player respawn so animation can play. player.deathTimer = -80f; //TODO this sounds pretty bad due to conflict @@ -544,6 +544,11 @@ public class Control implements ApplicationListener, Loadable{ core.items.each((i, a) -> i.unlock()); } + //cannot launch while paused + if(state.is(State.paused) && renderer.isCutscene()){ + state.set(State.playing); + } + if(Core.input.keyTap(Binding.pause) && !renderer.isCutscene() && !scene.hasDialog() && !scene.hasKeyboard() && !ui.restart.isShown() && (state.is(State.paused) || state.is(State.playing))){ state.set(state.is(State.playing) ? State.paused : State.playing); } diff --git a/core/src/mindustry/core/Renderer.java b/core/src/mindustry/core/Renderer.java index 4d107c06ed..e7fe48677e 100644 --- a/core/src/mindustry/core/Renderer.java +++ b/core/src/mindustry/core/Renderer.java @@ -51,6 +51,7 @@ public class Renderer implements ApplicationListener{ public TextureRegion[] bubbles = new TextureRegion[16], splashes = new TextureRegion[12]; private @Nullable CoreBuild landCore; + private @Nullable CoreBlock launchCoreType; private Color clearColor = new Color(0f, 0f, 0f, 1f); private float //seed for cloud visuals, 0-1 @@ -340,7 +341,7 @@ public class Renderer implements ApplicationListener{ float fin = 1f - fout; //draw core - var block = (CoreBlock)build.block; + var block = launching && launchCoreType != null ? launchCoreType : (CoreBlock)build.block; TextureRegion reg = block.fullIcon; float scl = Scl.scl(4f) / camerascale; float shake = 0f; @@ -373,6 +374,15 @@ public class Renderer implements ApplicationListener{ Draw.color(); Draw.mixcol(Color.white, Interp.pow5In.apply(fout)); + + //accent tint indicating that the core was just constructed + if(launching){ + float f = Mathf.clamp(1f - fout * 12f); + if(f > 0.001f){ + Draw.mixcol(Pal.accent, f); + } + } + Draw.scl(scl); Draw.alpha(1f); @@ -492,13 +502,16 @@ public class Renderer implements ApplicationListener{ cloudSeed = Mathf.random(1f); } - public void showLaunch(){ + public void showLaunch(CoreBlock coreType){ Vars.ui.hudfrag.showLaunch(); + launchCoreType = coreType; launching = true; landCore = player.team().core(); cloudSeed = Mathf.random(1f); landTime = coreLandDuration; - //TODO other stuff. + if(landCore != null){ + Fx.coreLaunchConstruct.at(landCore.x, landCore.y, coreType.size); + } } public void takeMapScreenshot(){ diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index 74d0265058..2f213fd6c8 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -32,6 +32,7 @@ import mindustry.type.*; import mindustry.ui.*; import mindustry.world.blocks.storage.*; +import static arc.Core.*; import static mindustry.Vars.*; import static mindustry.graphics.g3d.PlanetRenderer.*; import static mindustry.ui.dialogs.PlanetDialog.Mode.*; @@ -913,19 +914,38 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ }else{ CoreBlock block = from.info.bestCoreType instanceof CoreBlock b ? b : (CoreBlock)Blocks.coreShard; - //TODO load launchFrom sector right before launching so animation is correct loadouts.show(block, from, () -> { + var schemCore = universe.getLastLoadout().findCore(); from.removeItems(universe.getLastLoadout().requirements()); from.removeItems(universe.getLaunchResources()); - launching = true; - zoom = 0.5f; + if(settings.getBool("skipcoreanimation")){ + //just... go there + control.playSector(from, sector); + //hide only after load screen is shown + Time.runTask(8f, this::hide); + }else{ + //hide immediately so launch sector is visible + hide(); - //TODO - renderer.showLaunch(); - hide(); - //run with less delay, as the loading animation is delayed by several frames - Time.runTask(coreLandDuration - 8f, () -> control.playSector(from, sector)); + //allow planet dialog to finish hiding before actually launching + Time.runTask(5f, () -> { + Runnable doLaunch = () -> { + renderer.showLaunch(schemCore); + //run with less delay, as the loading animation is delayed by several frames + Time.runTask(coreLandDuration - 8f, () -> control.playSector(from, sector)); + }; + + //load launchFrom sector right before launching so animation is correct + if(!from.isBeingPlayed()){ + //run *after* the loading animation is done + Time.runTask(9f, doLaunch); + control.playSector(from); + }else{ + doLaunch.run(); + } + }); + } }); } }else if(mode == select){ diff --git a/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java b/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java index f15693634e..7ba99bf975 100644 --- a/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java +++ b/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java @@ -448,6 +448,8 @@ public class SettingsMenuDialog extends Dialog{ } } + graphics.checkPref("skipcoreanimation", false); + if(!mobile){ Core.settings.put("swapdiagonal", false); }