template void ComponentManager::AddComponent(std::uint32_t id, Args&&... args) { std::type_index type = typeid(T); //Determine the type of T (this is used as the key of the unordered_map<>) if (mComponents.find(type) == mComponents.end()) { //Check if this component type is already in the unordered_map<> mComponents[type] = std::vector>>(); //If not, create a new (empty) vector<> of unique_ptr } if (id >= mComponents[type].size()) { //Resize the vector<> if the id is greater than the current size mComponents[type].resize(id + 1); //Initialize new slots to nullptr (resize does this automatically) } mComponents[type][id].push_back(std::make_unique(std::forward(args)...)); //Create a new component of type T using perfect forwarding and store its unique_ptr in the correct vector } template std::vector> ComponentManager::GetComponentsOfID(std::uint32_t id) { std::type_index type = typeid(T); std::vector> componentVector; if (mComponents.find(type) != mComponents.end()) { const auto& componentArray = mComponents[type]; if (id < componentArray.size()) { for (const auto& componentPtr : componentArray[id]) { // Use static_cast instead of dynamic_cast T* castedComponent = static_cast(componentPtr.get()); if (castedComponent) { // Ensure cast was successful componentVector.push_back(*castedComponent); // Add the raw pointer to the vector } } } } return componentVector; // Return empty vector if not found } /*// GetAllComponentIDs implementation template std::vector ComponentManager::GetAllComponentIDs() { std::type_index type = typeid(T); std::vector ids; if (mComponents.find(type) != mComponents.end()) { const auto& componentArray = mComponents[type]; for (std::uint32_t id = 0; id < componentArray.size(); ++id) { if (componentArray[id] != nullptr) { ids.push_back(id); // Collect IDs of non-null components } } } return ids; } // GetAllComponentPointer implementation template std::vector ComponentManager::GetAllComponentPointer() { std::type_index type = typeid(T); std::vector pointers; if (mComponents.find(type) != mComponents.end()) { const auto& componentArray = mComponents[type]; for (const auto& component : componentArray) { if (component != nullptr) { pointers.push_back(static_cast(component)); // Cast to the correct type } } } return pointers; }*/