I am working on a small multiplayer game with rpg elements using java and "Artemis ODB". Most of the logic is already done but one important thing is missing. The persistence.
So i am searching for different ways to persist my game. One thing is important, the world is huge and i cant load in the whole world at once. I already stumbled upon two different ways on my own. Using a relational database or a nosql database. But one thing scares me... entity references.
In my game i have an player entity and item entities. The player entity owns a inventory component which stores a reference to some item entities. In my ecs, each entity reference is an simple integer. So this looks like this...
/**
* Represents the Inventory of our game, contains references to entities acting as items.
*/
public class Inventory extends HibernateComponent {
public Set<Integer> itemEntities = new LinkedHashSet<>();
}
Why does this scare me ? Well... Entity references are Integers in my case. They are no real ID and i cant set or change this "ID" of an entity because my framework permits it. This brings us straight to the problem. When i serialize this component or the whole player entity it would look like this.
Inventory{
itemEntities: [40,2,5,50]
}
So when we save this and load it later on we have no entity with the id 40... and even if we recreate that entity we cant set it to an id of 40, because the frameworks permits it. So how the heck do we save references between entities ? ^^
So all in all... what are common ways to save, load entities from an ecs ? How do you do it ? And what would you recommend ?