aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/ComponentManager.hpp
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-11-19 20:49:09 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-11-19 20:49:09 +0100
commit0f9f379a4dec7ad9d1dce30af5e2259931692c5f (patch)
treed84a76559d99fd6a3541d0087538564d79e39470 /src/crepe/ComponentManager.hpp
parent38a2476bcfa41b6d83a9a72d35f5acb684dc87fd (diff)
parent0476a8e9dbe7afb422862f7b1c15aaed7f3c416e (diff)
merge with master
Diffstat (limited to 'src/crepe/ComponentManager.hpp')
-rw-r--r--src/crepe/ComponentManager.hpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/crepe/ComponentManager.hpp b/src/crepe/ComponentManager.hpp
index 98efb49..be99cac 100644
--- a/src/crepe/ComponentManager.hpp
+++ b/src/crepe/ComponentManager.hpp
@@ -40,7 +40,6 @@ T & ComponentManager::add_component(game_object_id_t id, Args &&... args) {
// Check if the vector size is not greater than get_instances_max
int max_instances = instance->get_instances_max();
if (max_instances != -1 && components[type][id].size() >= max_instances) {
- // TODO: Exception
throw std::runtime_error(
"Exceeded maximum number of instances for this component type");
}
@@ -61,8 +60,7 @@ void ComponentManager::delete_components_by_id(game_object_id_t id) {
// Find the type (in the unordered_map<>)
if (this->components.find(type) != this->components.end()) {
// Get the correct vector<>
- vector<vector<unique_ptr<Component>>> & component_array
- = this->components[type];
+ vector<vector<unique_ptr<Component>>> & component_array = this->components[type];
// Make sure that the id (that we are looking for) is within the boundaries of the vector<>
if (id < component_array.size()) {
@@ -93,12 +91,10 @@ ComponentManager::get_components_by_id(game_object_id_t id) const {
// Create an empty vector<>
vector<reference_wrapper<T>> component_vector;
- if (this->components.find(type) == this->components.end())
- return component_vector;
+ if (this->components.find(type) == this->components.end()) return component_vector;
// Get the correct vector<>
- const vector<vector<unique_ptr<Component>>> & component_array
- = this->components.at(type);
+ const vector<vector<unique_ptr<Component>>> & component_array = this->components.at(type);
// Make sure that the id (that we are looking for) is within the boundaries of the vector<>
if (id >= component_array.size()) return component_vector;
@@ -118,8 +114,7 @@ ComponentManager::get_components_by_id(game_object_id_t id) const {
}
template <typename T>
-std::vector<std::reference_wrapper<T>>
-ComponentManager::get_components_by_type() const {
+std::vector<std::reference_wrapper<T>> ComponentManager::get_components_by_type() const {
using namespace std;
// Determine the type of T (this is used as the key of the unordered_map<>)
@@ -129,12 +124,10 @@ ComponentManager::get_components_by_type() const {
vector<reference_wrapper<T>> component_vector;
// Find the type (in the unordered_map<>)
- if (this->components.find(type) == this->components.end())
- return component_vector;
+ if (this->components.find(type) == this->components.end()) return component_vector;
// Get the correct vector<>
- const vector<vector<unique_ptr<Component>>> & component_array
- = this->components.at(type);
+ const vector<vector<unique_ptr<Component>>> & component_array = this->components.at(type);
// Loop through the whole vector<>
for (const vector<unique_ptr<Component>> & component : component_array) {