Im currently at the game synchronization state with my morpg, and i’ve run into a problem.
Im using Artemis Entity Framework, and im trying to synchronize server entities with local entities.
Each entity has a set of components. I’ve created a custom Component class, called CrunchableComponent.
Basically it has 2 abstract functions : Object[] crunch(); and void decrunch(Object[] fields);
In the first one the component stores all its data, and in the second it deciphers it.
Now the problem part. Im sending a EntityCreationPacket each time a entity gets created on the server, and it contains a array of ComponentData objects, which just hold the Component’s class and the Object[] array which represent the fields.
When the client receives the packet, it should create a object of that class (f.ex. PositionComponent, which extends CrunchableComponent), cast it to CrunchableComponent, call decrunch(); on the component,
and add it to a new entity. And thats what i have trouble with.