zakarumych / edict

Other
82 stars 6 forks source link

Serializing/Deserializing Relations #25

Open TheSamsa opened 6 days ago

TheSamsa commented 6 days ago

Hey,

right now I'm trying out some ECS for a little pet project of mine. Even though it is no game I thought I try out some ECS out of curiosity. I fiddled around a bit to get the serialization working, after which I was testing if Relations can also be serialized. Because somewhere in the docs I read relations are special components. But after a short test it seems they are not beeing serialized. Is this intentional or did I do something wrong?

Also, as far as I could see I can only serialize 16 components for any Entity (A, B, ..., P). Any way to increase the components serialized?

zakarumych commented 6 days ago

Hi!

Serialization currently serializes only components, relation are special components under the hood, but you can't name them to serialize. So relations serialization would have to be handled in the serialization module.

It is the most undeveloped feature :)

TheSamsa commented 6 days ago

Thank you!

I am however not sure what you mean by "So relations serialization would have to be handled in the serialization module." Is it possible to serialize relations right now, or do you mean it's something that has to be prepared first?

zakarumych commented 6 days ago

It is something that needs to be handled on library. So currently you can't serialize relations

TheSamsa commented 6 days ago

Thanks again.

Some ideas about this, or is this not yet fleshed out? Maybe I can look into this!

zakarumych commented 6 days ago

Just an oversight mostly. Inside the lib it is possible to manipulate relations as components.

The only problem is to decide when to serialize relation. Should it be serialized if only one entity of the pair passes the filter. If yes, should the other one forced to be serialized? With or without its own components? etc

TheSamsa commented 6 days ago

I will look into the implementation, maybe I can provide something. Not sure though.

And just as a gut feeling: The relation should be serialized if only one entity is filtered. And the other one should not be serialized, since it didn't pass the filter.

zakarumych commented 6 days ago

If only one entity and relation will get serialized, then on deserialization, if second entity is not already present, relation must be dropped immediately, as relation can exist only on both entities at once.