Fixed logic IDs not loading / Accelerator animation tweaks

This commit is contained in:
Anuken
2025-02-08 16:04:04 -05:00
parent f8b6600fe7
commit ebaf88e80d
3 changed files with 21 additions and 6 deletions
+2 -1
View File
@@ -23,6 +23,7 @@ import static mindustry.Vars.*;
public class GlobalVars{ public class GlobalVars{
public static final int ctrlProcessor = 1, ctrlPlayer = 2, ctrlCommand = 3; 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[] 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. */ /** Global random state. */
public static final Rand rand = new Rand(); public static final Rand rand = new Rand();
@@ -155,7 +156,7 @@ public class GlobalVars{
if(ids.exists()){ if(ids.exists()){
//read logic ID mapping data (generated in ImagePacker) //read logic ID mapping data (generated in ImagePacker)
try(DataInputStream in = new DataInputStream(ids.readByteStream())){ try(DataInputStream in = new DataInputStream(ids.readByteStream())){
for(ContentType ctype : lookableContent){ for(ContentType ctype : writableLookableContent){
short amount = in.readShort(); short amount = in.readShort();
logicIdToContent[ctype.ordinal()] = new UnlockableContent[amount]; logicIdToContent[ctype.ordinal()] = new UnlockableContent[amount];
contentIdToLogicId[ctype.ordinal()] = new int[Vars.content.getBy(ctype).size]; contentIdToLogicId[ctype.ordinal()] = new int[Vars.content.getBy(ctype).size];
@@ -111,6 +111,7 @@ public class Accelerator extends Block{
public float progress; public float progress;
public float time, launchHeat; public float time, launchHeat;
public boolean launching; public boolean launching;
public float launchTime;
protected float cloudSeed; protected float cloudSeed;
@@ -156,7 +157,18 @@ public class Accelerator extends Block{
{ {
if(launching){ if(launching){
Draw.reset(); 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.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{ }else{
Drawf.shadow(x, y, launchBlock.size * tilesize * 2f, progress); Drawf.shadow(x, y, launchBlock.size * tilesize * 2f, progress);
Draw.draw(Layer.blockBuilding, () -> { Draw.draw(Layer.blockBuilding, () -> {
@@ -175,7 +187,6 @@ public class Accelerator extends Block{
}); });
} }
Draw.reset(); Draw.reset();
} }
@@ -366,13 +377,15 @@ public class Accelerator extends Block{
@Override @Override
public void endLaunch(){ public void endLaunch(){
launching = false; launching = false;
launchTime = 0f;
} }
@Override @Override
public float zoomLaunch(){ public float zoomLaunch(){
float rawTime = launchDuration() - renderer.getLandTime(); 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){ if(rawTime < chargeDuration){
float fin = rawTime / chargeDuration; float fin = rawTime / chargeDuration;
@@ -389,6 +402,7 @@ public class Accelerator extends Block{
@Override @Override
public void updateLaunch(){ public void updateLaunch(){
float in = renderer.getLandTimeIn() * launchDuration(); float in = renderer.getLandTimeIn() * launchDuration();
launchTime = launchDuration() - in;
float tsize = Mathf.sample(CoreBlock.thrusterSizes, (in + 35f) / launchDuration()); float tsize = Mathf.sample(CoreBlock.thrusterSizes, (in + 35f) / launchDuration());
float rawFin = renderer.getLandTimeIn(); float rawFin = renderer.getLandTimeIn();
+3 -3
View File
@@ -140,7 +140,7 @@ public class ImagePacker{
Seq<UnlockableContent> lookupCont = new Seq<>(); Seq<UnlockableContent> lookupCont = new Seq<>();
for(ContentType t : GlobalVars.lookableContent){ for(ContentType t : GlobalVars.writableLookableContent){
lookupCont.addAll(Vars.content.<UnlockableContent>getBy(t).select(UnlockableContent::logicVisible)); lookupCont.addAll(Vars.content.<UnlockableContent>getBy(t).select(UnlockableContent::logicVisible));
} }
@@ -154,7 +154,7 @@ public class ImagePacker{
if(logicidfile.exists()){ if(logicidfile.exists()){
try(DataInputStream in = new DataInputStream(logicidfile.readByteStream())){ try(DataInputStream in = new DataInputStream(logicidfile.readByteStream())){
for(ContentType ctype : GlobalVars.lookableContent){ for(ContentType ctype : GlobalVars.writableLookableContent){
short amount = in.readShort(); short amount = in.readShort();
for(int i = 0; i < amount; i++){ for(int i = 0; i < amount; i++){
String name = in.readUTF(); String name = in.readUTF();
@@ -189,7 +189,7 @@ public class ImagePacker{
//write the resulting IDs //write the resulting IDs
try(DataOutputStream out = new DataOutputStream(logicidfile.write(false, 2048))){ try(DataOutputStream out = new DataOutputStream(logicidfile.write(false, 2048))){
for(ContentType t : GlobalVars.lookableContent){ for(ContentType t : GlobalVars.writableLookableContent){
Seq<UnlockableContent> all = idToContent[t.ordinal()].values().toArray().sort(u -> registered[t.ordinal()].get(u)); Seq<UnlockableContent> all = idToContent[t.ordinal()].values().toArray().sort(u -> registered[t.ordinal()].get(u));
out.writeShort(all.size); out.writeShort(all.size);
for(UnlockableContent u : all){ for(UnlockableContent u : all){