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