question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Persisting/serializing entities

See original GitHub issue

I am currently looking into a good way to persist all my entities. The main use case is saving&loading the game.

Now I could iterate over every entity and check for every possible component and store everything in some way. Then on loading I would have to reverse this process. But at the very best I don’t want to do this too “game specific” and would prefer a more generic way of doing this that other people can benefit from. (That also works with a pooled engine and hopefully on all plattforms too!)

At the end I want something like this:

data persistEntities(Engine/PooledEngine)
loadEntities(data, Engine/PooledEngine)

or 

data Engine.persistEntities()
Engine.loadEntities(data)

I think it would be good if one could mark every component that should be persisted with an annotation and/or interface and exclude fields with transient or an annotation. (e.g. a SpriteComponent with TextureRegions)

Maybe allow the components to handle the serialization by itself. (onSave, onLoad - similar to the android bundle concept))

I hope I get some input on this. And I intend to contribute this to Ashley or the community in some way.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:28 (22 by maintainers)

github_iconTop GitHub Comments

2reactions
dsaltarescommented, Aug 11, 2016

I know! I’m finding it hard to find the time. I would really appreciate some help on this.

2reactions
mattblcommented, Aug 11, 2016

Will there be any further improvement on this branch ? That would be such an interesting feature to be found in the master !

Read more comments on GitHub >

github_iconTop Results From Across the Web

JPA Entities and the Serializable Interface - Baeldung
Learn when and why to use the Serializable interface in JPA entities ... Each entity class consists of persistent fields and properties.
Read more >
Walkthrough: Persisting an Object using C# | Microsoft Learn
You can use binary serialization to persist an object's data between instances, which enables you to store values and retrieve them the next ......
Read more >
Persisting and retrieving serialized entity property with Entity ...
By applying that attribute, I want EF to serialize the instance of Bar with its Bazes into a single string field, and transparently...
Read more >
Serializing and deserializing entity instances - Second Edition
Serialization is defined as the process of converting an object into a stream of bytes (as a memory stream) so that it can...
Read more >
Serializing - MikroORM
The opposite situation where you want to define a property that lives only in memory (is not persisted into database) can be solved...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found