yohamta / donburi

Just another ECS library for Go/Ebitengine
https://pkg.go.dev/github.com/yohamta/donburi
Other
232 stars 21 forks source link

What are the options for serializing all of the entities and their components? #140

Open etareduction opened 2 weeks ago

etareduction commented 2 weeks ago

I want to implement some dev tools and a simple save-and-restore system. How can i go about serializing entities and their components, and then restoring the world with the same entity id's?

yohamta commented 2 weeks ago

Hi, I thought we had already discussed a similar topic here. Could you please take a look to see if it helps with developing the save-and-restore system? If it doesn’t, I’m totally happy to discuss further additional functionality.

etareduction commented 2 weeks ago

Hi, I thought we had already discussed a similar topic here. Could you please take a look to see if it helps with developing the save-and-restore system? If it doesn’t, I’m totally happy to discuss further additional functionality.

* [Getting a list of entity's components #125](https://github.com/yohamta/donburi/issues/125)

I've read through that discussion before asking but it seems to focus only on data retrieval. I think i need some generic solution for populating the world with deserialized entities and their components while also preserving their entity ids (so references won't break).

yohamta commented 2 weeks ago

Thank you, I understand. Do you know how does bevy support such functionality, by the way? One idea I just thought of is as follows:

etareduction commented 2 weeks ago

Thank you, I understand. Do you know how does bevy support such functionality, by the way? One idea I just thought of is as follows:

* Implement a serialization function specifically for the `World` object, such as `MarshalToJSON` and `UnmarshalJSON`.

I was thinking of storing data in some other formats. But i can use JSON as an intermediate format, that sounds good to me. I think serialization and deserialization of entities that keeps their entity ID's intact is a primary concern to this.

yohamta commented 2 weeks ago

Great, I think we can implement this functionality. Would you please create a PR when you have a chance? I'm available to help if you encounter any problems or have questions during the implementation. Thanks!

etareduction commented 2 weeks ago

Great, I think we can implement this functionality. Would you please create a PR when you have a chance? I'm available to help if you encounter any problems or have questions during the implementation. Thanks!

Sure, I'll try when i get a bit more free time