Godot Version
Godot 4.4.1
Question
I’m making car game. It has some complex data structures that tries to emulate car parts. So we have:
-
Car(Resource) that is build from many parts (engine, suspension, etc)
-
Parts(Resources) that are build from many smaller parts (engine contains valves, camshafts, filters, etc).
To make different operations on those parts easier, they keep references to each other. So car has references to 1st level of parts. Those parts have references to lower level of parts, but also to the car. And of course lower level of parts (valves, filters) keeps references to their “upper” parts. It works quite well until I tried to make save / load. And those circural references are killing me. So I have some questions: -
Is it correct approach? Maybe I should store unique ids of those parts? And all the parts in some database. But then I’ll start having problems with synchronization, car dissapears, I need to make sure all of its parts are also removed. Part can be removed from car, then if car dissapears, part shouldn’t, etc. References make it simple, if there is no living reference to the object, it dissapears.
-
If this is correct approach, how should I approach saving the game. I can store object id instead of reference but according to the documentation if I load object from file, it’s Id will be different.
Any help / advices?