diff options
Diffstat (limited to 'src/crepe/manager/ComponentManager.cpp')
-rw-r--r-- | src/crepe/manager/ComponentManager.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/crepe/manager/ComponentManager.cpp b/src/crepe/manager/ComponentManager.cpp index 745ddae..245419d 100644 --- a/src/crepe/manager/ComponentManager.cpp +++ b/src/crepe/manager/ComponentManager.cpp @@ -46,14 +46,16 @@ void ComponentManager::delete_all_components() { this->next_id = 0; } -GameObject ComponentManager::new_object(const string & name, const string & tag, - const vec2 & position, double rotation, double scale) { +GameObject ComponentManager::new_object( + const string & name, const string & tag, const vec2 & position, double rotation, + double scale +) { // Find the first available id (taking persistent objects into account) while (this->persistent[this->next_id]) { this->next_id++; } - GameObject object{this->mediator, this->next_id, name, tag, position, rotation, scale}; + GameObject object {this->mediator, this->next_id, name, tag, position, rotation, scale}; this->next_id++; return object; @@ -64,23 +66,25 @@ void ComponentManager::set_persistent(game_object_id_t id, bool persistent) { } set<game_object_id_t> ComponentManager::get_objects_by_name(const string & name) const { - return this->get_objects_by_predicate<Metadata>( - [name](const Metadata & data) { return data.name == name; }); + return this->get_objects_by_predicate<Metadata>([name](const Metadata & data) { + return data.name == name; + }); } set<game_object_id_t> ComponentManager::get_objects_by_tag(const string & tag) const { - return this->get_objects_by_predicate<Metadata>( - [tag](const Metadata & data) { return data.tag == tag; }); + return this->get_objects_by_predicate<Metadata>([tag](const Metadata & data) { + return data.tag == tag; + }); } ComponentManager::Snapshot ComponentManager::save() { - Snapshot snapshot{}; + Snapshot snapshot {}; for (const auto & [type, by_id_index] : this->components) { for (game_object_id_t id = 0; id < by_id_index.size(); id++) { const auto & components = by_id_index[id]; for (size_t index = 0; index < components.size(); index++) { const Component & component = *components[index]; - snapshot.components.push_back(SnapshotComponent{ + snapshot.components.push_back(SnapshotComponent { .type = type, .id = id, .index = index, |