Process fix

This commit is contained in:
Anuken 2022-03-27 19:18:53 -04:00
parent 0e2a5cddfd
commit cefb9d263a
2 changed files with 15 additions and 7 deletions

View File

@ -853,6 +853,10 @@ public class EntityProcess extends BaseProcessor{
Stype compType = interfaceToComp(method.type());
MethodSpec.Builder builder = MethodSpec.overriding(method.e).addModifiers(Modifier.PUBLIC, Modifier.FINAL);
int index = 0;
for(ParameterSpec spec : builder.parameters){
Reflect.set(spec, "name", "arg" + index++);
}
builder.addAnnotation(OverrideCallSuper.class); //just in case
if(!method.isVoid()){

View File

@ -3,7 +3,6 @@ package mindustry.annotations.misc;
import arc.*;
import arc.graphics.g2d.*;
import arc.struct.*;
import arc.struct.ObjectMap.*;
import com.squareup.javapoet.*;
import mindustry.annotations.Annotations.*;
import mindustry.annotations.*;
@ -34,10 +33,15 @@ public class LoadRegionProcessor extends BaseProcessor{
fieldMap.get(field.enclosingType(), Seq::new).add(field);
}
for(Entry<Stype, Seq<Svar>> entry : fieldMap){
method.beginControlFlow("if(content instanceof $L)", entry.key.fullName());
Seq<Stype> entries = Seq.with(fieldMap.keys());
entries.sortComparing(e -> e.name());
for(Svar field : entry.value){
for(Stype type : entries){
Seq<Svar> fields = fieldMap.get(type);
fields.sortComparing(s -> s.name());
method.beginControlFlow("if(content instanceof $L)", type.fullName());
for(Svar field : fields){
Load an = field.annotation(Load.class);
//get # of array dimensions
int dims = count(field.mirror().toString(), "[]");
@ -46,7 +50,7 @@ public class LoadRegionProcessor extends BaseProcessor{
//not an array
if(dims == 0){
method.addStatement("(($L)content).$L = $T.atlas.find($L$L)", entry.key.fullName(), field.name(), Core.class, parse(an.value()), fallbackString);
method.addStatement("(($L)content).$L = $T.atlas.find($L$L)", type.fullName(), field.name(), Core.class, parse(an.value()), fallbackString);
}else{
//is an array, create length string
int[] lengths = an.lengths();
@ -59,7 +63,7 @@ public class LoadRegionProcessor extends BaseProcessor{
StringBuilder lengthString = new StringBuilder();
for(int value : lengths) lengthString.append("[").append(value).append("]");
method.addStatement("(($T)content).$L = new $T$L", entry.key.tname(), field.name(), TextureRegion.class, lengthString.toString());
method.addStatement("(($T)content).$L = new $T$L", type.tname(), field.name(), TextureRegion.class, lengthString.toString());
for(int i = 0; i < dims; i++){
method.beginControlFlow("for(int INDEX$L = 0; INDEX$L < $L; INDEX$L ++)", i, i, lengths[i], i);
@ -70,7 +74,7 @@ public class LoadRegionProcessor extends BaseProcessor{
indexString.append("[INDEX").append(i).append("]");
}
method.addStatement("(($T)content).$L$L = $T.atlas.find($L$L)", entry.key.tname(), field.name(), indexString.toString(), Core.class, parse(an.value()), fallbackString);
method.addStatement("(($T)content).$L$L = $T.atlas.find($L$L)", type.tname(), field.name(), indexString.toString(), Core.class, parse(an.value()), fallbackString);
for(int i = 0; i < dims; i++){
method.endControlFlow();