Implementation begins
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user