question

James McGhee avatar image
James McGhee asked

Entity Groups and variable but persistent data

From what I have read up I think I understand but am not 100% sure if our design would fit into Entity Group and Entity Objects.

So what we have is shared worlds, each game server representing a single world and has a number of members that have access to it (usually a small number but count is variable). So in this case we have an Entity Group which represents the world and thus its members ... we think anyway.

The players can add and manipulate objects in the world at current we represent an 'object' as a collection of componenets each componenet can be represented as a small json object ... we do this for ease of sync and our save method so for example if you move the object only the position componenet changed and that is all we sync, when we save the state of the world we are actually saving the list of all componenets that exist in the world.

The question is can we (or should we) map the current structure onto Entity Group and Entity Object.
That is represent a world as a Entity Group so now we can assoceate a number of players with that group. Our componenets would be Entity Objects in that case. A world could consist of thousands of small componenets ... or we could serialize the object level reducing the number but increasing the size of each serialized element slightly ... a typical object would have a handful of componenets on it but could have many. For example we have an annotaiton componenet that lets players attach messages to the object, an object can techncialy have any number of annotaitons.

Alternativly we could keep it more how we are doing it in local tests at the moment ... that is we have the game server simply write a file to the disk which is the list of componenets. I think that would work with Entity File. Size is the main concern we want the players to be abel to build large complex worlds ... size of the resulting save data can there for be large (what large is we haven't defined yet, as a single text file possibly as large as a few MB but less than 10MB). The speed at which we load and save this data isn't a concern as we save data infrequently on the server to protect against unexpected shut down and of course we save on shut down, load on start up of the game server.

The goal here is to persist the state of the world assoceated with the group of players so that when all players are off line the world can shut down. When any one of the players comes back online we can spin up the world for them and load it from the last stored state.

dataentities
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sarah Zhang avatar image Sarah Zhang commented ·

We are researching this problem.

0 Likes 0 ·
James McGhee avatar image James McGhee Sarah Zhang commented ·

Thank you ... let us know if you need any additional information.

The project in question is still in a design mode but we have the basic data model pinned down. The components I noted will serialize to rather small JSON objects defining 1 to a small handful of primitive fields such as:
Rotation ... which is just a structure that serializes a quaternion
The typical object will have at least 3 components but can have quite a few as noted we support a component called annotation that lets users add messages to the object so technically speaking an object can have any number of them each one simply has a string on it.

In early testing serializing what we see to be a typical world as a single file yields a text file containing the JSON of all components to about 6 or 7 mb and has around 1000 or so components.

As noted the goal here is simply to persist the world for the group of players in an efficient way so worst case we can use a more traditional method to persist and use Entity Group + Entity Object just to store the key data to go fetch that world ... speed of read/write to the persisted data isn't a huge concern but is a nice to have.

0 Likes 0 ·

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

Thanks for the detailed explanation. Your solution is basically feasible. It seems you need to notice the usage limits of Entity Objects and Entity Files. You can navigate to https://developer.playfab.com/en-US/[YourTitleId]/limits to check the limits of your title.

By default, the maximum number of objects stored for one player entity is 5. And the maximum size of each object is 1000 bytes. The maximum number of files stored for one player entity is 10. The total title level entity files is 50,000 gigabytes.

>> Our components would be Entity Objects in that case. A world could consist of thousands of small components ... or we could serialize the object level reducing the number but increasing the size of each serialized element slightly ... a typical object would have a handful of components on it but could have many.

Considering that the maximum number of objects stored for the title player account entity is 5, so the latter is more feasible. You can store any number of JSON Objects in an entity object within the size limit.

Please feel free to let us know if you meet any other technical questions when you use PlayFab Entity Programming Model.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

James McGhee avatar image James McGhee commented ·

Thanks I think that gives me what we need ...

To spell it out for future readers

In our case this is going against an Entity Group which represents our session or 'world' not a specific player.
The Entity Group will store its state as an Entity File

1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.