Hello forum!
I have a structure for my game-field, similar to a scene-graph one could say. Every object in this scene-graph has the base-class Scene_Graph_Object.
Now, when the savefile is being deserialised, an object builds all of these Scene_Graph_Objects from the file.
Nonetheless, there is one thing separating these Scene_Graph_Objects, their purpose within the game-field. Some have no function, some are purely visual, others are playable, ... They are being sorted into different vectors depending on their category, more precisely put: Scene_Graph_Objects could be downcast to Visual_Only_Scene_Graph_Object, Playable_Scene_Graph_Object, ...
And this brings up my question: Where should this differentiation happening?
Deserialise -> Create Visual_Only_Scene_Graph_Object, Playable_Scene_Graph_Object, ... save them as Scene_Graph_Object base, and send that to the game-field-builder? I feel like all these up- and downcasting isn't really a pretty thing to do. Also considered to use some flags instead. As in an enum that all Scene_Graph_Objects own and can be checked once they are meant to be sorted into the scene-graph.
The reason behind these categories is, that they help me to build a pretty simple and tailored game-field, but somewhat I think that inheritance is not really bringing up any advantages, because inherited classes do not really extend the usage but only categorise the scene-graph-objects.
Would be quite happy to hear what you think : )
↧