From ebaf88e80d7fcf680129789a90d0311854061f4b Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 8 Feb 2025 16:04:04 -0500 Subject: [PATCH] Fixed logic IDs not loading / Accelerator animation tweaks --- core/src/mindustry/logic/GlobalVars.java | 3 ++- .../world/blocks/campaign/Accelerator.java | 18 ++++++++++++++++-- tools/src/mindustry/tools/ImagePacker.java | 6 +++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/core/src/mindustry/logic/GlobalVars.java b/core/src/mindustry/logic/GlobalVars.java index b4f5a59467..732c870983 100644 --- a/core/src/mindustry/logic/GlobalVars.java +++ b/core/src/mindustry/logic/GlobalVars.java @@ -23,6 +23,7 @@ import static mindustry.Vars.*; public class GlobalVars{ public static final int ctrlProcessor = 1, ctrlPlayer = 2, ctrlCommand = 3; public static final ContentType[] lookableContent = {ContentType.block, ContentType.unit, ContentType.item, ContentType.liquid, ContentType.team}; + public static final ContentType[] writableLookableContent = {ContentType.block, ContentType.unit, ContentType.item, ContentType.liquid}; /** Global random state. */ public static final Rand rand = new Rand(); @@ -155,7 +156,7 @@ public class GlobalVars{ if(ids.exists()){ //read logic ID mapping data (generated in ImagePacker) try(DataInputStream in = new DataInputStream(ids.readByteStream())){ - for(ContentType ctype : lookableContent){ + for(ContentType ctype : writableLookableContent){ short amount = in.readShort(); logicIdToContent[ctype.ordinal()] = new UnlockableContent[amount]; contentIdToLogicId[ctype.ordinal()] = new int[Vars.content.getBy(ctype).size]; diff --git a/core/src/mindustry/world/blocks/campaign/Accelerator.java b/core/src/mindustry/world/blocks/campaign/Accelerator.java index 254985bf3f..164e9cd746 100644 --- a/core/src/mindustry/world/blocks/campaign/Accelerator.java +++ b/core/src/mindustry/world/blocks/campaign/Accelerator.java @@ -111,6 +111,7 @@ public class Accelerator extends Block{ public float progress; public float time, launchHeat; public boolean launching; + public float launchTime; protected float cloudSeed; @@ -156,7 +157,18 @@ public class Accelerator extends Block{ { if(launching){ Draw.reset(); + + Draw.blend(Blending.additive); + Fill.light(x, y, 15, launchBlock.size * tilesize * 1f, Tmp.c2.set(Pal.accent).a(launchTime / chargeDuration), Tmp.c1.set(Pal.accent).a(0f)); + Draw.blend(); + Draw.rect(launchBlock.fullIcon, x, y); + + Draw.z(Layer.bullet); + Draw.mixcol(Pal.accent, Mathf.clamp(launchTime / chargeDuration)); + Draw.color(1f, 1f, 1f, Interp.pow2In.apply(Mathf.clamp(launchTime / chargeDuration * 0.7f))); + Draw.rect(launchBlock.fullIcon, x, y); + Draw.reset(); }else{ Drawf.shadow(x, y, launchBlock.size * tilesize * 2f, progress); Draw.draw(Layer.blockBuilding, () -> { @@ -175,7 +187,6 @@ public class Accelerator extends Block{ }); } - Draw.reset(); } @@ -366,13 +377,15 @@ public class Accelerator extends Block{ @Override public void endLaunch(){ launching = false; + launchTime = 0f; } @Override public float zoomLaunch(){ float rawTime = launchDuration() - renderer.getLandTime(); + float shake = rawTime < chargeDuration ? Interp.pow10In.apply(Mathf.clamp(rawTime/chargeDuration)) : 0f; - Core.camera.position.set(this); + Core.camera.position.set(x, y).add(Tmp.v1.setToRandomDirection().scl(shake * 2f)); if(rawTime < chargeDuration){ float fin = rawTime / chargeDuration; @@ -389,6 +402,7 @@ public class Accelerator extends Block{ @Override public void updateLaunch(){ float in = renderer.getLandTimeIn() * launchDuration(); + launchTime = launchDuration() - in; float tsize = Mathf.sample(CoreBlock.thrusterSizes, (in + 35f) / launchDuration()); float rawFin = renderer.getLandTimeIn(); diff --git a/tools/src/mindustry/tools/ImagePacker.java b/tools/src/mindustry/tools/ImagePacker.java index 74a287d083..a319555abe 100644 --- a/tools/src/mindustry/tools/ImagePacker.java +++ b/tools/src/mindustry/tools/ImagePacker.java @@ -140,7 +140,7 @@ public class ImagePacker{ Seq lookupCont = new Seq<>(); - for(ContentType t : GlobalVars.lookableContent){ + for(ContentType t : GlobalVars.writableLookableContent){ lookupCont.addAll(Vars.content.getBy(t).select(UnlockableContent::logicVisible)); } @@ -154,7 +154,7 @@ public class ImagePacker{ if(logicidfile.exists()){ try(DataInputStream in = new DataInputStream(logicidfile.readByteStream())){ - for(ContentType ctype : GlobalVars.lookableContent){ + for(ContentType ctype : GlobalVars.writableLookableContent){ short amount = in.readShort(); for(int i = 0; i < amount; i++){ String name = in.readUTF(); @@ -189,7 +189,7 @@ public class ImagePacker{ //write the resulting IDs try(DataOutputStream out = new DataOutputStream(logicidfile.write(false, 2048))){ - for(ContentType t : GlobalVars.lookableContent){ + for(ContentType t : GlobalVars.writableLookableContent){ Seq all = idToContent[t.ordinal()].values().toArray().sort(u -> registered[t.ordinal()].get(u)); out.writeShort(all.size); for(UnlockableContent u : all){