This commit is contained in:
Anuken
2020-02-06 20:24:30 -05:00
parent e3136e9e09
commit f83b6728cf
8 changed files with 34 additions and 29 deletions

View File

@@ -5,16 +5,10 @@ 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 DrawLayer{
floor,
groundShadows,
groundUnder,
ground,
flyingShadows,
flying,
@@ -69,6 +63,7 @@ public class Annotations{
public @interface EntityDef{
Class[] value();
boolean isFinal() default true;
boolean pooled() default false;
}
/** Indicates an internal interface for entity components. */

View File

@@ -157,7 +157,8 @@ public class EntityProcess extends BaseProcessor{
//look at each definition
for(Stype type : allDefs){
boolean isFinal = type.annotation(EntityDef.class).isFinal();
EntityDef ann = type.annotation(EntityDef.class);
boolean isFinal = ann.isFinal();
if(!type.name().endsWith("Def")){
err("All entity def names must end with 'Def'", type.e);
}
@@ -279,7 +280,7 @@ public class EntityProcess extends BaseProcessor{
//add create() method
builder.addMethod(MethodSpec.methodBuilder("create").addModifiers(Modifier.PUBLIC, Modifier.STATIC)
.returns(tname(packageName + "." + name))
.addStatement("return new $L()", name).build());
.addStatement(ann.pooled() ? "return " : "return new $L()", name).build());
definitions.add(new EntityDefinition("mindustry.gen." + name, builder, type, components, groups));
}