Leakoo
thinmatrix from patreon
thinmatrix patreon

September Update - Save System Changes

🕑 Added 2021-09-30 16:13:58 +0000 UTC
September Update - Save System Changes

Comments

KC Oaks

I came to suggest something similar to what Kenneth suggested. I have an application that also requires serializing object graphs. I write out all of the distinct entities, each with an identifier, in a flat list and store the relationships separately. Upon loading, I load all of the entities, build a dictionary, and then create the relationships by looking up each (already instantiated) entity.

ThinMatrix

Ah I see, that makes sense

If you generate and store the identifier immediately before serializing the entity, then when you are about to serialize the reference to the first entity in the second entity, it will already have the identifier ready to go.

ThinMatrix

Oh that's clever, I hadn't considered that! But how would it work with a circular reference, if two entities both reference each other?

Nice write up! Another way to tackle the reference issue, is to serialize the entities instantly when you hit a reference, with a unique identifier, and then only serializing the identifier for any subsequent reference. This way you're guaranteed that the entity is already loaded when it is needed during deserialization. Can't wait for the next devlog!


More Creators