Land animation progress / IntelliJ android plugin hack

This commit is contained in:
Anuken
2021-07-27 16:26:13 -04:00
parent 269c48b65b
commit 00e3a59463
9 changed files with 61 additions and 31 deletions

View File

@ -107,6 +107,7 @@ importPackage(Packages.mindustry.maps.planet)
importPackage(Packages.mindustry.net)
importPackage(Packages.mindustry.service)
importPackage(Packages.mindustry.type)
importPackage(Packages.mindustry.type.ammo)
importPackage(Packages.mindustry.type.weapons)
importPackage(Packages.mindustry.type.weather)
importPackage(Packages.mindustry.ui)

View File

@ -44,6 +44,7 @@ public class Renderer implements ApplicationListener{
public @Nullable Bloom bloom;
public FrameBuffer effectBuffer = new FrameBuffer();
public boolean animateShields, drawWeather = true, drawStatus;
public float weatherAlpha;
/** minZoom = zooming out, maxZoom = zooming in */
public float minZoom = 1.5f, maxZoom = 6f;
public Seq<EnvRenderer> envRenderers = new Seq<>();
@ -51,9 +52,25 @@ public class Renderer implements ApplicationListener{
private @Nullable CoreBuild landCore;
private Color clearColor = new Color(0f, 0f, 0f, 1f);
private float cloudSeed = 0f;
private float targetscale = Scl.scl(4), camerascale = targetscale, landscale, landTime, landPTimer, weatherAlpha, minZoomScl = Scl.scl(0.01f);
private float shakeIntensity, shaketime;
private float
//seed for cloud visuals, 0-1
cloudSeed = 0f,
//target camera scale that is lerp-ed to
targetscale = Scl.scl(4),
//current actual camera scale
camerascale = targetscale,
//minimum camera zoom value for landing/launching; constant TODO make larger?
minZoomScl = Scl.scl(0.02f),
//starts at coreLandDuration, ends at 0. if positive, core is landing.
landTime,
//timer for core landing particles
landPTimer,
//intensity for screen shake
shakeIntensity,
//current duration of screen shake
shakeTime;
//for landTime > 0: if true, core is currently *launching*, otherwise landing.
private boolean isLaunching;
private Vec2 camShakeOffset = new Vec2();
public Renderer(){
@ -63,7 +80,7 @@ public class Renderer implements ApplicationListener{
public void shake(float intensity, float duration){
shakeIntensity = Math.max(shakeIntensity, intensity);
shaketime = Math.max(shaketime, duration);
shakeTime = Math.max(shakeTime, duration);
}
public void addEnvRenderer(int mask, Runnable render){
@ -112,9 +129,13 @@ public class Renderer implements ApplicationListener{
if(!state.isPaused()){
landTime -= Time.delta;
}
landscale = landInterp.apply(minZoomScl, Scl.scl(4f), 1f - landTime / coreLandDuration);
camerascale = landscale;
camerascale = landInterp.apply(minZoomScl, Scl.scl(4f), 1f - landTime / coreLandDuration);
weatherAlpha = 0f;
//snap camera to cutscene core regardless of player input
if(landCore != null){
camera.position.set(landCore);
}
}else{
weatherAlpha = Mathf.lerpDelta(weatherAlpha, 1f, 0.08f);
}
@ -126,12 +147,12 @@ public class Renderer implements ApplicationListener{
landTime = 0f;
graphics.clear(Color.black);
}else{
if(shaketime > 0){
if(shakeTime > 0){
float intensity = shakeIntensity * (settings.getInt("screenshake", 4) / 4f) * 0.75f;
camShakeOffset.setToRandomDirection().scl(Mathf.random(intensity));
camera.position.add(camShakeOffset);
shakeIntensity -= 0.25f * Time.delta;
shaketime -= Time.delta;
shakeTime -= Time.delta;
shakeIntensity = Mathf.clamp(shakeIntensity, 0f, 100f);
}else{
camShakeOffset.setZero();
@ -148,16 +169,13 @@ public class Renderer implements ApplicationListener{
}
}
public boolean isLanding(){
/** @return whether a launch/land cutscene is playing. */
public boolean isCutscene(){
return landTime > 0;
}
public float weatherAlpha(){
return weatherAlpha;
}
public float landScale(){
return landTime > 0 ? landscale : 1f;
return landTime > 0 ? camerascale : 1f;
}
@Override
@ -290,7 +308,7 @@ public class Renderer implements ApplicationListener{
}
private void drawBackground(){
//nothing to draw currently
}
void updateLandParticles(){
@ -378,7 +396,7 @@ public class Renderer implements ApplicationListener{
if(state.rules.cloudColor.a > 0.0001f){
//clouds
float scaling = cloudScaling;
float sscl = Math.max(1f + Mathf.clamp(fin + cfinOffset)* cfinScl, 0f) * landscale;
float sscl = Math.max(1f + Mathf.clamp(fin + cfinOffset)* cfinScl, 0f) * camerascale;
Tmp.tr1.set(clouds);
Tmp.tr1.set(
@ -454,11 +472,19 @@ public class Renderer implements ApplicationListener{
}
public void showLanding(){
landscale = minZoomScl;
isLaunching = false;
camerascale = minZoomScl;
landTime = coreLandDuration;
cloudSeed = Mathf.random(1f);
}
public void showLaunch(){
isLaunching = true;
landCore = player.team().core();
cloudSeed = Mathf.random(1f);
//TODO other stuff.
}
public void takeMapScreenshot(){
int w = world.width() * tilesize, h = world.height() * tilesize;
int memory = w * h * 4 / 1024 / 1024;

View File

@ -204,7 +204,6 @@ public class DesktopInput extends InputHandler{
panning = false;
}
//TODO awful UI state checking code
if(((player.dead() || state.isPaused()) && !ui.chatfrag.shown()) && !scene.hasField() && !scene.hasDialog()){
if(input.keyDown(Binding.mouse_move)){
panCam = true;
@ -237,7 +236,7 @@ public class DesktopInput extends InputHandler{
}
}
if(!player.dead() && !state.isPaused() && !scene.hasField()){
if(!player.dead() && !state.isPaused() && !scene.hasField() && !renderer.isCutscene()){
updateMovement(player.unit());
if(Core.input.keyTap(Binding.respawn)){

View File

@ -681,7 +681,7 @@ public class MobileInput extends InputHandler implements GestureListener{
}
}
if(!player.dead() && !state.isPaused()){
if(!player.dead() && !state.isPaused() && !renderer.isCutscene()){
updateMovement(player.unit());
}
@ -822,7 +822,7 @@ public class MobileInput extends InputHandler implements GestureListener{
shiftDeltaX %= tilesize;
shiftDeltaY %= tilesize;
}
}else if(!renderer.isLanding()){
}else{
//pan player
Core.camera.position.x -= deltaX;
Core.camera.position.y -= deltaY;

View File

@ -1,8 +1,6 @@
package mindustry.mod;
import arc.struct.*;
import mindustry.type.ammo.*;
/** Generated class. Maps simple class names to concrete classes. For use in JSON mods. */
@SuppressWarnings("deprecation")
public class ClassMap{
@ -54,8 +52,6 @@ public class ClassMap{
classes.put("Research", mindustry.game.Objectives.Research.class);
classes.put("SectorComplete", mindustry.game.Objectives.SectorComplete.class);
classes.put("AmmoType", mindustry.type.AmmoType.class);
classes.put("ItemAmmoType", ItemAmmoType.class);
classes.put("PowerAmmoType", PowerAmmoType.class);
classes.put("Category", mindustry.type.Category.class);
classes.put("ErrorContent", mindustry.type.ErrorContent.class);
classes.put("Item", mindustry.type.Item.class);
@ -75,6 +71,8 @@ public class ClassMap{
classes.put("Weapon", mindustry.type.Weapon.class);
classes.put("Weather", mindustry.type.Weather.class);
classes.put("WeatherEntry", mindustry.type.Weather.WeatherEntry.class);
classes.put("ItemAmmoType", mindustry.type.ammo.ItemAmmoType.class);
classes.put("PowerAmmoType", mindustry.type.ammo.PowerAmmoType.class);
classes.put("PointDefenseWeapon", mindustry.type.weapons.PointDefenseWeapon.class);
classes.put("RepairBeamWeapon", mindustry.type.weapons.RepairBeamWeapon.class);
classes.put("HealBeamMount", mindustry.type.weapons.RepairBeamWeapon.HealBeamMount.class);

View File

@ -342,15 +342,15 @@ public class Weather extends UnlockableContent{
@Override
public void draw(){
if(renderer.weatherAlpha() > 0.0001f && renderer.drawWeather && Core.settings.getBool("showweather")){
if(renderer.weatherAlpha > 0.0001f && renderer.drawWeather && Core.settings.getBool("showweather")){
Draw.draw(Layer.weather, () -> {
Draw.alpha(renderer.weatherAlpha() * opacity * weather.opacityMultiplier);
Draw.alpha(renderer.weatherAlpha * opacity * weather.opacityMultiplier);
weather.drawOver(self());
Draw.reset();
});
Draw.draw(Layer.debris, () -> {
Draw.alpha(renderer.weatherAlpha() * opacity * weather.opacityMultiplier);
Draw.alpha(renderer.weatherAlpha * opacity * weather.opacityMultiplier);
weather.drawUnder(self());
Draw.reset();
});

View File

@ -920,8 +920,9 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
launching = true;
zoom = 0.5f;
ui.hudfrag.showLaunchDirect();
//TODO animation; 140 is fine
//TODO
renderer.showLaunch();
hide();
Time.runTask(launchDuration, () -> control.playSector(from, sector));
});
}

View File

@ -22,7 +22,11 @@ if(new File(settingsDir, 'local.properties').exists()){
if(System.getenv("JITPACK") == "true") hasSdk = false
if(hasSdk){
include 'android'
//hack: pretend the Android module doesn't exist when imported through IntelliJ
//why? because IntelliJ chokes on the new version of the Android plugin
if(!System.getProperty("jna.tmpdir")?.contains("JetBrains")){
include 'android'
}
}else{
println("No Android SDK found. Skipping Android module.")
}

View File

@ -80,6 +80,7 @@ public class ScriptMainGenerator{
"mindustry.ai.types",
"mindustry.type.weather",
"mindustry.type.weapons",
"mindustry.type.ammo",
"mindustry.game.Objectives",
"mindustry.world.blocks",
"mindustry.world.draw",