So I have this struct ComponentBase:
struct ComponentBase {
ComponentBase() = default;
};
Which is inherited by various other components. When you initialise an object, it may come with a couple of these subclassed components in a vector which each need to have a unique ID in the collection. I can't use typeid(obj) or typeid(obj).name() since pybind11 doesn't work with the first one and the strings are name scrambled with the second.
Its also pretty difficult to use a virtual function to do get_type() for the component since I have methods like this:
template <typename T>
inline auto get_component(const GameObjectID game_object_id) const -> std::shared_ptr<T> {
return std::static_pointer_cast<T>(get_component(game_object_id, GET_COMPONENT_TYPE_HERE));
}
[[nodiscard]] auto get_component(GameObjectID game_object_id, TODO component_type) const -> std::shared_ptr<ComponentBase>;
Which can't be passed an instance of the component since I'm trying to get that component. What would be the best way to solve this?