From 63fa50d111f6418aa8195945e15b5a55c7c5bda3 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 2 Feb 2020 17:42:00 -0500 Subject: [PATCH] Implementation begins --- .../annotations/impl/EntityProcess.java | 4 +- core/src/mindustry/core/NetServer.java | 1 - .../mindustry/entities/def/EntityComps.java | 52 +++++++++++++++++-- .../mindustry/entities/traits/SyncTrait.java | 5 -- 4 files changed, 50 insertions(+), 12 deletions(-) diff --git a/annotations/src/main/java/mindustry/annotations/impl/EntityProcess.java b/annotations/src/main/java/mindustry/annotations/impl/EntityProcess.java index 80e294a0f3..ab1ef61b7b 100644 --- a/annotations/src/main/java/mindustry/annotations/impl/EntityProcess.java +++ b/annotations/src/main/java/mindustry/annotations/impl/EntityProcess.java @@ -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 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"; } diff --git a/core/src/mindustry/core/NetServer.java b/core/src/mindustry/core/NetServer.java index 2faf856171..53460e47de 100644 --- a/core/src/mindustry/core/NetServer.java +++ b/core/src/mindustry/core/NetServer.java @@ -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 diff --git a/core/src/mindustry/entities/def/EntityComps.java b/core/src/mindustry/entities/def/EntityComps.java index 3dea444169..9264be9f6c 100644 --- a/core/src/mindustry/entities/def/EntityComps.java +++ b/core/src/mindustry/entities/def/EntityComps.java @@ -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(); diff --git a/core/src/mindustry/entities/traits/SyncTrait.java b/core/src/mindustry/entities/traits/SyncTrait.java index 29da740bc0..b0c6f31628 100644 --- a/core/src/mindustry/entities/traits/SyncTrait.java +++ b/core/src/mindustry/entities/traits/SyncTrait.java @@ -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;