Implementation begins

This commit is contained in:
Anuken 2020-02-02 17:42:00 -05:00
parent ad84329688
commit 63fa50d111
4 changed files with 50 additions and 12 deletions

View File

@ -93,7 +93,7 @@ public class EntityProcess extends BaseProcessor{
if(!type.name().endsWith("Def")){
err("All entity def names must end with 'Def'", type.e);
}
String name = type.name().replace("Def", "Gen"); //TODO remove 'gen'
String name = type.name().replace("Def", "_"); //TODO remove extra underscore
TypeSpec.Builder builder = TypeSpec.classBuilder(name).addModifiers(Modifier.PUBLIC, Modifier.FINAL);
Array<Stype> components = allComponents(type);
@ -222,7 +222,7 @@ public class EntityProcess extends BaseProcessor{
String interfaceName(Stype comp){
String suffix = "Comp";
if(!comp.name().endsWith(suffix)){
err("All components must have names that end with 'Comp'.", comp.e);
err("All components must have names that end with 'Comp'", comp.e);
}
return comp.name().substring(0, comp.name().length() - suffix.length()) + "c";
}

View File

@ -745,7 +745,6 @@ public class NetServer implements ApplicationListener{
for(Entity entity : group.all()){
SyncTrait sync = (SyncTrait)entity;
if(!sync.isSyncing()) continue;
//write all entities now
dataStream.writeInt(entity.getID()); //write id

View File

@ -12,7 +12,9 @@ import mindustry.content.*;
import mindustry.ctype.*;
import mindustry.entities.bullet.*;
import mindustry.entities.units.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.net.*;
import mindustry.type.*;
import java.io.*;
@ -21,9 +23,9 @@ import static mindustry.Vars.content;
public class EntityComps{
@Depends({HealthComp.class, VelComp.class, StatusComp.class})
@Depends({HealthComp.class, VelComp.class, StatusComp.class, TeamComp.class, ItemsComp.class})
class UnitComp{
//UnitDef type;
}
class OwnerComp{
@ -35,7 +37,13 @@ public class EntityComps{
BulletType bullet;
void init(){
bullet.init();
//TODO
bullet.init(null);
}
void remove(){
//TODO
bullet.despawned(null);
}
}
@ -65,6 +73,27 @@ public class EntityComps{
}
}
class FlyingComp{
boolean flying;
}
class LegsComp{
}
class RotComp{
float rotation;
}
class TeamComp{
Team team = Team.sharded;
}
@Depends(PosComp.class)
class SyncComp{
Interpolator interpolator;
}
abstract class PosComp implements Position{
float x, y;
@ -74,9 +103,24 @@ public class EntityComps{
}
}
abstract class DamageComp{
abstract float getDamage();
}
class MinerComp{
}
class BuilderComp{
}
class ItemsComp{
ItemStack item = new ItemStack();
}
@Depends(PosComp.class)
class VelComp{
//transient fields act as imports from any other component clases; these are ignored by the generator
transient float x, y;
final Vec2 vel = new Vec2();

View File

@ -36,11 +36,6 @@ public interface SyncTrait extends Entity, TypeTrait{
return null;
}
/** Whether syncing is enabled for this entity; true by default. */
default boolean isSyncing(){
return true;
}
//Read and write sync data, usually position
void write(DataOutput data) throws IOException;