I am currently working on a Component based game engine written in c++. All components inherit from a component base class. All components in the scene are upcasted into a vector of Components were they can be iterated over and Update()
and such can be called.
I am trying to come up with a communication system for the components. If I have a function called GetComponent<Type>()
Like Unity will I be able to return a component from what is used to be before it was upcasted.
So basically i have an upcasted component and I want to reverse it so it is its original class and then return it via the function(as the class it used to be). Is this possible? If it were possible how would the component know what class it used to be?
Are there any examples of doing this I can learn from?