This commit is contained in:
Anuken
2020-02-06 11:37:22 -05:00
parent a11f6efe0a
commit 6a99a3922e
46 changed files with 2155 additions and 1871 deletions

View File

@@ -5,6 +5,24 @@ import java.lang.annotation.*;
public class Annotations{
//region entity interfaces
/** Indicates that a component field is read-only. */
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.SOURCE)
public @interface Render{
RenderLayer value();
}
public enum RenderLayer{
floor,
groundShadows,
ground,
flyingShadows,
flying,
bullets,
effects,
names,
}
/** Indicates that a component field is read-only. */
@Target({ElementType.FIELD, ElementType.METHOD})
@Retention(RetentionPolicy.SOURCE)

View File

@@ -3,6 +3,7 @@ package mindustry.annotations;
import arc.files.*;
import arc.struct.Array;
import arc.util.*;
import arc.util.Log.*;
import com.squareup.javapoet.*;
import com.sun.source.util.*;
import mindustry.annotations.util.*;
@@ -151,6 +152,10 @@ public abstract class BaseProcessor extends AbstractProcessor{
elementu = env.getElementUtils();
filer = env.getFiler();
messager = env.getMessager();
if(System.getProperty("debug") == null){
Log.setLogLevel(LogLevel.err);
}
}
@Override
@@ -159,7 +164,7 @@ public abstract class BaseProcessor extends AbstractProcessor{
if(rootDirectory == null){
try{
String path = Fi.get(filer.getResource(StandardLocation.CLASS_OUTPUT, "no", "no")
.toUri().toURL().toString().substring(System.getProperty("os.name").contains("Windows") ? 6 : "file:".length()))
.toUri().toURL().toString().substring(OS.isWindows ? 6 : "file:".length()))
.parent().parent().parent().parent().parent().parent().parent().toString().replace("%20", " ");
rootDirectory = Fi.get(path);
}catch(IOException e){

View File

@@ -19,6 +19,7 @@ import java.lang.annotation.*;
@SupportedAnnotationTypes({
"mindustry.annotations.Annotations.EntityDef",
"mindustry.annotations.Annotations.GroupDef",
"mindustry.annotations.Annotations.EntityInterface",
"mindustry.annotations.Annotations.BaseComponent"
})
@@ -64,7 +65,8 @@ public class EntityProcess extends BaseProcessor{
//create component interfaces
for(Stype component : allComponents){
TypeSpec.Builder inter = TypeSpec.interfaceBuilder(interfaceName(component)).addModifiers(Modifier.PUBLIC).addAnnotation(EntityInterface.class);
TypeSpec.Builder inter = TypeSpec.interfaceBuilder(interfaceName(component))
.addModifiers(Modifier.PUBLIC).addAnnotation(EntityInterface.class);
//implement extra interfaces these components may have, e.g. position
for(Stype extraInterface : component.interfaces().select(i -> !isCompInterface(i))){