mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-22 20:48:33 +07:00
Process fix
This commit is contained in:
parent
0e2a5cddfd
commit
cefb9d263a
@ -853,6 +853,10 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
|
|
||||||
Stype compType = interfaceToComp(method.type());
|
Stype compType = interfaceToComp(method.type());
|
||||||
MethodSpec.Builder builder = MethodSpec.overriding(method.e).addModifiers(Modifier.PUBLIC, Modifier.FINAL);
|
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
|
builder.addAnnotation(OverrideCallSuper.class); //just in case
|
||||||
|
|
||||||
if(!method.isVoid()){
|
if(!method.isVoid()){
|
||||||
|
@ -3,7 +3,6 @@ package mindustry.annotations.misc;
|
|||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.struct.ObjectMap.*;
|
|
||||||
import com.squareup.javapoet.*;
|
import com.squareup.javapoet.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.annotations.*;
|
import mindustry.annotations.*;
|
||||||
@ -34,10 +33,15 @@ public class LoadRegionProcessor extends BaseProcessor{
|
|||||||
fieldMap.get(field.enclosingType(), Seq::new).add(field);
|
fieldMap.get(field.enclosingType(), Seq::new).add(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Entry<Stype, Seq<Svar>> entry : fieldMap){
|
Seq<Stype> entries = Seq.with(fieldMap.keys());
|
||||||
method.beginControlFlow("if(content instanceof $L)", entry.key.fullName());
|
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);
|
Load an = field.annotation(Load.class);
|
||||||
//get # of array dimensions
|
//get # of array dimensions
|
||||||
int dims = count(field.mirror().toString(), "[]");
|
int dims = count(field.mirror().toString(), "[]");
|
||||||
@ -46,7 +50,7 @@ public class LoadRegionProcessor extends BaseProcessor{
|
|||||||
|
|
||||||
//not an array
|
//not an array
|
||||||
if(dims == 0){
|
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{
|
}else{
|
||||||
//is an array, create length string
|
//is an array, create length string
|
||||||
int[] lengths = an.lengths();
|
int[] lengths = an.lengths();
|
||||||
@ -59,7 +63,7 @@ public class LoadRegionProcessor extends BaseProcessor{
|
|||||||
StringBuilder lengthString = new StringBuilder();
|
StringBuilder lengthString = new StringBuilder();
|
||||||
for(int value : lengths) lengthString.append("[").append(value).append("]");
|
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++){
|
for(int i = 0; i < dims; i++){
|
||||||
method.beginControlFlow("for(int INDEX$L = 0; INDEX$L < $L; INDEX$L ++)", i, i, lengths[i], 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("]");
|
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++){
|
for(int i = 0; i < dims; i++){
|
||||||
method.endControlFlow();
|
method.endControlFlow();
|
||||||
|
Loading…
Reference in New Issue
Block a user