Unit definitions
This commit is contained in:
@@ -58,7 +58,6 @@ public class Annotations{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Indicates an entity definition. */
|
/** Indicates an entity definition. */
|
||||||
@Target(ElementType.TYPE)
|
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface EntityDef{
|
public @interface EntityDef{
|
||||||
Class[] value();
|
Class[] value();
|
||||||
|
|||||||
@@ -184,6 +184,9 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
groupDefs.add(def);
|
groupDefs.add(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ObjectMap<String, Selement> usedNames = new ObjectMap<>();
|
||||||
|
ObjectMap<Selement, ObjectSet<String>> extraNames = new ObjectMap<>();
|
||||||
|
|
||||||
//look at each definition
|
//look at each definition
|
||||||
for(Selement<?> type : allDefs){
|
for(Selement<?> type : allDefs){
|
||||||
EntityDef ann = type.annotation(EntityDef.class);
|
EntityDef ann = type.annotation(EntityDef.class);
|
||||||
@@ -194,6 +197,19 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
String name = type.isType() ?
|
String name = type.isType() ?
|
||||||
type.name().replace("Def", "Entity") :
|
type.name().replace("Def", "Entity") :
|
||||||
createName(type);
|
createName(type);
|
||||||
|
|
||||||
|
//skip double classes
|
||||||
|
if(usedNames.containsKey(name)){
|
||||||
|
extraNames.getOr(usedNames.get(name), ObjectSet::new).add(type.name());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
usedNames.put(name, type);
|
||||||
|
extraNames.getOr(type, ObjectSet::new).add(name);
|
||||||
|
if(!type.isType()){
|
||||||
|
extraNames.getOr(type, ObjectSet::new).add(type.name());
|
||||||
|
}
|
||||||
|
|
||||||
TypeSpec.Builder builder = TypeSpec.classBuilder(name).addModifiers(Modifier.PUBLIC);
|
TypeSpec.Builder builder = TypeSpec.classBuilder(name).addModifiers(Modifier.PUBLIC);
|
||||||
if(isFinal) builder.addModifiers(Modifier.FINAL);
|
if(isFinal) builder.addModifiers(Modifier.FINAL);
|
||||||
|
|
||||||
@@ -398,8 +414,9 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
for(EntityDefinition def : definitions){
|
for(EntityDefinition def : definitions){
|
||||||
//store mapping
|
//store mapping
|
||||||
idStore.addStatement("idMap[$L] = $L::new", def.classID, def.name);
|
idStore.addStatement("idMap[$L] = $L::new", def.classID, def.name);
|
||||||
idStore.addStatement("nameMap.put($S, $L::new)", def.name.substring(packageName.length() + 1), def.name);
|
extraNames.get(def.base).each(extra -> {
|
||||||
idStore.addStatement("nameMap.put($S, $L::new)", def.base.name(), def.name);
|
idStore.addStatement("nameMap.put($S, $L::new)", extra, def.name);
|
||||||
|
});
|
||||||
|
|
||||||
//return mapping
|
//return mapping
|
||||||
def.builder.addMethod(MethodSpec.methodBuilder("classId").addAnnotation(Override.class)
|
def.builder.addMethod(MethodSpec.methodBuilder("classId").addAnnotation(Override.class)
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
#Maps entity names to IDs. Autogenerated.
|
#Maps entity names to IDs. Autogenerated.
|
||||||
|
|
||||||
|
dagger=7
|
||||||
mindustry.entities.def.AllEntities.GenericBuilderDef=6
|
mindustry.entities.def.AllEntities.GenericBuilderDef=6
|
||||||
mindustry.entities.def.AllEntities.BulletDef=0
|
mindustry.entities.def.AllEntities.BulletDef=0
|
||||||
mindustry.entities.def.AllEntities.PlayerDef=4
|
mindustry.entities.def.AllEntities.PlayerDef=4
|
||||||
|
dagger2=8
|
||||||
mindustry.entities.def.AllEntities.GenericUnitDef=5
|
mindustry.entities.def.AllEntities.GenericUnitDef=5
|
||||||
mindustry.entities.def.AllEntities.EffectDef=2
|
mindustry.entities.def.AllEntities.EffectDef=2
|
||||||
mindustry.entities.def.AllEntities.DecalDef=1
|
mindustry.entities.def.AllEntities.DecalDef=1
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package mindustry.content;
|
package mindustry.content;
|
||||||
|
|
||||||
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
|
|
||||||
public class UnitTypes implements ContentList{
|
public class UnitTypes implements ContentList{
|
||||||
@@ -9,8 +11,7 @@ public class UnitTypes implements ContentList{
|
|||||||
wraith, ghoul, revenant, lich, reaper,
|
wraith, ghoul, revenant, lich, reaper,
|
||||||
crawler, titan, fortress, eruptor, chaosArray, eradicator;
|
crawler, titan, fortress, eruptor, chaosArray, eradicator;
|
||||||
|
|
||||||
//TODO can't get comp classes
|
public static @EntityDef({Unitc.class, Legsc.class}) UnitDef dagger;
|
||||||
public static UnitDef dagger;
|
|
||||||
|
|
||||||
public static UnitDef vanguard, alpha, delta, tau, omega, dart, javelin, trident, glaive;
|
public static UnitDef vanguard, alpha, delta, tau, omega, dart, javelin, trident, glaive;
|
||||||
public static UnitDef starter;
|
public static UnitDef starter;
|
||||||
@@ -18,6 +19,7 @@ public class UnitTypes implements ContentList{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(){
|
public void load(){
|
||||||
|
|
||||||
dagger = new UnitDef("dagger"){{
|
dagger = new UnitDef("dagger"){{
|
||||||
speed = 0.2f;
|
speed = 0.2f;
|
||||||
drag = 0.4f;
|
drag = 0.4f;
|
||||||
|
|||||||
Reference in New Issue
Block a user