I have a GameObject class, which contains Components, like:
- Renderer
- Camera
- Behaviour
- Rigidbody
First I inherited all of them from Component which has an Update() method, and it is called every frame on every game objects' every component.
But then I noticed, that** Renderer and Camera's Update method is unused**. (There are classes like RenderData & CameraData which are isolated and made from primitives, and upon creation of these Components, these Data's pointer is sent to the GraphicsEngine which will process them every frame.)
So having an unused method is bad. So I created a DynamicComponent class, which inherits from Component, and Behaviour & Rigidbody classes are inherited from it.
I moved the Update() from Component to DynamicComponent, and I have now 2 containers at gameobjects:
Components (for components which are inherited directly from Component)
Dynamic Components (for components which are inherited from D.Comp.)
And every frame I only call DynamicComponents' Update().
Now I'm having another issue. There is the Behaviour class, where should be a Start() method, which is called on every Behaviour when the scene is fully initalized.
That means that I should have a Components, D.Components and also a Behaviours container at game objects.
This looks very bad to me.
Having a Component class, with Start(), Update(), etc is very simple and makes a very clean code, but this means that only a few derived classes implement its virtual methods.
What should I do?