aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/ComponentManager.hpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-15 20:03:51 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-15 20:03:51 +0100
commit9f6475e7b0698c414138e2a8140b47f01ce9c5d1 (patch)
tree3dd74938da60a0de1a77360280c15ff8949d02cf /src/crepe/ComponentManager.hpp
parent424611c6016e4a189e3a887fabe8e45b637e80f4 (diff)
parentb597af6c64ccf50c7f92a2b78e7950ee3ab230f7 (diff)
Merge branch 'loek/wrap'
Diffstat (limited to 'src/crepe/ComponentManager.hpp')
-rw-r--r--src/crepe/ComponentManager.hpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/crepe/ComponentManager.hpp b/src/crepe/ComponentManager.hpp
index 98efb49..c537b03 100644
--- a/src/crepe/ComponentManager.hpp
+++ b/src/crepe/ComponentManager.hpp
@@ -61,8 +61,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 +92,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 +115,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 +125,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) {