From dd7062f0f798845c5e4c2b468bee5e4cea0a33b5 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 7 Sep 2021 22:32:27 -0400 Subject: [PATCH] ParticleEffect#sizeInterp / Log usable RAM --- core/src/mindustry/ClientLauncher.java | 3 +++ core/src/mindustry/entities/effect/ParticleEffect.java | 9 ++++++--- .../mindustry/world/blocks/defense/turrets/Turret.java | 5 ++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/core/src/mindustry/ClientLauncher.java b/core/src/mindustry/ClientLauncher.java index a7d1791e20..4a3fce014a 100644 --- a/core/src/mindustry/ClientLauncher.java +++ b/core/src/mindustry/ClientLauncher.java @@ -56,6 +56,9 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform Log.info("[GL] Using @ context.", gl30 != null ? "OpenGL 3" : "OpenGL 2"); if(maxTextureSize < 4096) Log.warn("[GL] Your maximum texture size is below the recommended minimum of 4096. This will cause severe performance issues."); Log.info("[JAVA] Version: @", OS.javaVersion); + long ram = Runtime.getRuntime().maxMemory(); + boolean gb = ram >= 1024 * 1024 * 1024; + Log.info("[RAM] Available: @ @", Strings.fixed(gb ? ram / 1024f / 1024 / 1024f : ram / 1024f / 1024f, 1), gb ? "GB" : "MB"); Time.setDeltaProvider(() -> { float result = Core.graphics.getDeltaTime() * 60f; diff --git a/core/src/mindustry/entities/effect/ParticleEffect.java b/core/src/mindustry/entities/effect/ParticleEffect.java index 0efbaefcbf..477e52e19a 100644 --- a/core/src/mindustry/entities/effect/ParticleEffect.java +++ b/core/src/mindustry/entities/effect/ParticleEffect.java @@ -20,6 +20,8 @@ public class ParticleEffect extends Effect{ public float cone = 180f, length = 20f, baseLength = 0f; /** Particle size/length/radius interpolation. */ public Interp interp = Interp.linear; + /** Particle size interpolation. Null to use interp. */ + public @Nullable Interp sizeInterp = null; public float offsetX, offsetY; public float lightScl = 2f, lightOpacity = 0.6f; public @Nullable Color lightColor; @@ -44,6 +46,7 @@ public class ParticleEffect extends Effect{ @Override public void init(){ clip = Math.max(clip, length + Math.max(sizeFrom, sizeTo)); + if(sizeInterp == null) sizeInterp = interp; } @Override @@ -52,15 +55,15 @@ public class ParticleEffect extends Effect{ float rawfin = e.fin(); float fin = e.fin(interp); - float rad = interp.apply(sizeFrom, sizeTo, rawfin) * 2; + float rad = sizeInterp.apply(sizeFrom, sizeTo, rawfin) * 2; float ox = e.x + Angles.trnsx(e.rotation, offsetX, offsetY), oy = e.y + Angles.trnsy(e.rotation, offsetX, offsetY); Draw.color(colorFrom, colorTo, fin); Color lightColor = this.lightColor == null ? Draw.getColor() : this.lightColor; if(line){ - Lines.stroke(interp.apply(strokeFrom, strokeTo, rawfin)); - float len = interp.apply(lenFrom, lenTo, rawfin); + Lines.stroke(sizeInterp.apply(strokeFrom, strokeTo, rawfin)); + float len = sizeInterp.apply(lenFrom, lenTo, rawfin); rand.setSeed(e.id); for(int i = 0; i < particles; i++){ diff --git a/core/src/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/mindustry/world/blocks/defense/turrets/Turret.java index 5f26af42d8..050e20975a 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/Turret.java @@ -273,6 +273,7 @@ public class Turret extends ReloadTurret{ } if(hasAmmo()){ + if(Float.isNaN(reload)) rotation = 0; if(timer(timerTarget, targetInterval)){ findTarget(); @@ -289,9 +290,7 @@ public class Turret extends ReloadTurret{ }else{ //default AI behavior targetPosition(target); - if(Float.isNaN(rotation)){ - rotation = 0; - } + if(Float.isNaN(rotation)) rotation = 0; } float targetRot = angleTo(targetPos);