From 61148c757a1f742ff09e40e5347e74e638c7371c Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sun, 22 Dec 2024 12:32:22 +0100 Subject: update clang-format options --- src/crepe/manager/ComponentManager.cpp | 22 +++++++++++++--------- src/crepe/manager/ComponentManager.h | 7 ++++--- src/crepe/manager/ComponentManager.hpp | 20 ++++++++++++-------- src/crepe/manager/EventManager.h | 4 ++-- src/crepe/manager/EventManager.hpp | 14 ++++++++------ src/crepe/manager/LoopTimerManager.cpp | 6 +++--- src/crepe/manager/LoopTimerManager.h | 12 ++++++------ src/crepe/manager/ResourceManager.hpp | 13 ++++++++----- src/crepe/manager/SceneManager.cpp | 10 ++++++---- src/crepe/manager/SystemManager.hpp | 10 ++++++---- 10 files changed, 68 insertions(+), 50 deletions(-) (limited to 'src/crepe/manager') 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 ComponentManager::get_objects_by_name(const string & name) const { - return this->get_objects_by_predicate( - [name](const Metadata & data) { return data.name == name; }); + return this->get_objects_by_predicate([name](const Metadata & data) { + return data.name == name; + }); } set ComponentManager::get_objects_by_tag(const string & tag) const { - return this->get_objects_by_predicate( - [tag](const Metadata & data) { return data.tag == tag; }); + return this->get_objects_by_predicate([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, diff --git a/src/crepe/manager/ComponentManager.h b/src/crepe/manager/ComponentManager.h index c3a5b4a..2eb1f7e 100644 --- a/src/crepe/manager/ComponentManager.h +++ b/src/crepe/manager/ComponentManager.h @@ -38,9 +38,10 @@ public: * * \note This method automatically assigns a new entity ID */ - GameObject new_object(const std::string & name, const std::string & tag = "", - const vec2 & position = {0, 0}, double rotation = 0, - double scale = 1); + GameObject new_object( + const std::string & name, const std::string & tag = "", const vec2 & position = {0, 0}, + double rotation = 0, double scale = 1 + ); public: /** diff --git a/src/crepe/manager/ComponentManager.hpp b/src/crepe/manager/ComponentManager.hpp index 9e70865..6d32edb 100644 --- a/src/crepe/manager/ComponentManager.hpp +++ b/src/crepe/manager/ComponentManager.hpp @@ -11,8 +11,10 @@ template T & ComponentManager::add_component(game_object_id_t id, Args &&... args) { using namespace std; - static_assert(is_base_of::value, - "add_component must recieve a derivative class of Component"); + static_assert( + is_base_of::value, + "add_component must recieve a derivative class of Component" + ); // Determine the type of T (this is used as the key of the unordered_map<>) type_index type = typeid(T); @@ -40,8 +42,8 @@ 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) { - throw std::runtime_error( - "Exceeded maximum number of instances for this component type"); + throw std::runtime_error("Exceeded maximum number of instances for this component type" + ); } // store its unique_ptr in the vector<> @@ -95,8 +97,10 @@ template RefVector ComponentManager::get_components_by_id(game_object_id_t id) const { using namespace std; - static_assert(is_base_of::value, - "get_components_by_id must recieve a derivative class of Component"); + static_assert( + is_base_of::value, + "get_components_by_id must recieve a derivative class of Component" + ); type_index type = typeid(T); if (!this->components.contains(type)) return {}; @@ -170,8 +174,8 @@ ComponentManager::get_objects_by_predicate(const std::function } template -RefVector -ComponentManager::get_components_by_ids(const std::set & ids) const { +RefVector ComponentManager::get_components_by_ids(const std::set & ids +) const { using namespace std; RefVector out = {}; diff --git a/src/crepe/manager/EventManager.h b/src/crepe/manager/EventManager.h index 0a57fb1..5766a0c 100644 --- a/src/crepe/manager/EventManager.h +++ b/src/crepe/manager/EventManager.h @@ -49,8 +49,8 @@ public: * \return A unique subscription ID associated with the registered callback. */ template - subscription_t subscribe(const EventHandler & callback, - event_channel_t channel = CHANNEL_ALL); + subscription_t + subscribe(const EventHandler & callback, event_channel_t channel = CHANNEL_ALL); /** * \brief Unsubscribe a previously registered callback. diff --git a/src/crepe/manager/EventManager.hpp b/src/crepe/manager/EventManager.hpp index b2090d0..1f44943 100644 --- a/src/crepe/manager/EventManager.hpp +++ b/src/crepe/manager/EventManager.hpp @@ -5,22 +5,24 @@ namespace crepe { template -subscription_t EventManager::subscribe(const EventHandler & callback, - event_channel_t channel) { +subscription_t +EventManager::subscribe(const EventHandler & callback, event_channel_t channel) { subscription_counter++; std::type_index event_type = typeid(EventType); std::unique_ptr> handler = std::make_unique>(callback); std::vector & handlers = this->subscribers[event_type]; - handlers.emplace_back(CallbackEntry{ - .callback = std::move(handler), .channel = channel, .id = subscription_counter}); + handlers.emplace_back(CallbackEntry { + .callback = std::move(handler), .channel = channel, .id = subscription_counter + }); return subscription_counter; } template void EventManager::queue_event(const EventType & event, event_channel_t channel) { - static_assert(std::is_base_of::value, - "EventType must derive from Event"); + static_assert( + std::is_base_of::value, "EventType must derive from Event" + ); this->events_queue.push_back(QueueEntry{ // unique_ptr w/ custom destructor implementation is used because the base Event interface // can't be polymorphic (= have default virtual destructor) diff --git a/src/crepe/manager/LoopTimerManager.cpp b/src/crepe/manager/LoopTimerManager.cpp index e78f92f..b4cd07f 100644 --- a/src/crepe/manager/LoopTimerManager.cpp +++ b/src/crepe/manager/LoopTimerManager.cpp @@ -17,9 +17,9 @@ LoopTimerManager::LoopTimerManager(Mediator & mediator) : Manager(mediator) { void LoopTimerManager::start() { this->last_frame_time = std::chrono::steady_clock::now(); - this->elapsed_time = elapsed_time_t{0}; - this->elapsed_fixed_time = elapsed_time_t{0}; - this->delta_time = duration_t{0}; + this->elapsed_time = elapsed_time_t {0}; + this->elapsed_fixed_time = elapsed_time_t {0}; + this->delta_time = duration_t {0}; } void LoopTimerManager::update() { diff --git a/src/crepe/manager/LoopTimerManager.h b/src/crepe/manager/LoopTimerManager.h index 2f1e6b6..279d6b2 100644 --- a/src/crepe/manager/LoopTimerManager.h +++ b/src/crepe/manager/LoopTimerManager.h @@ -157,17 +157,17 @@ private: //! Time scale for speeding up or slowing down the game (0 = pause, < 1 = slow down, 1 = normal speed, > 1 = speed up). float time_scale = 1; //! Maximum delta time in seconds to avoid large jumps. - duration_t maximum_delta_time{0.25}; + duration_t maximum_delta_time {0.25}; //! Delta time for the current frame in seconds. - duration_t delta_time{0.0}; + duration_t delta_time {0.0}; //! Target time per frame in seconds - duration_t frame_target_time{1.0 / target_fps}; + duration_t frame_target_time {1.0 / target_fps}; //! Fixed delta time for fixed updates in seconds. - duration_t fixed_delta_time{1.0 / 50.0}; + duration_t fixed_delta_time {1.0 / 50.0}; //! Total elapsed game time in microseconds. - elapsed_time_t elapsed_time{0}; + elapsed_time_t elapsed_time {0}; //! Total elapsed time for fixed updates in microseconds. - elapsed_time_t elapsed_fixed_time{0}; + elapsed_time_t elapsed_fixed_time {0}; typedef std::chrono::steady_clock::time_point time_point_t; //! Time of the last frame. diff --git a/src/crepe/manager/ResourceManager.hpp b/src/crepe/manager/ResourceManager.hpp index cf5c949..4ca6be0 100644 --- a/src/crepe/manager/ResourceManager.hpp +++ b/src/crepe/manager/ResourceManager.hpp @@ -9,17 +9,20 @@ namespace crepe { template T & ResourceManager::get(const Asset & asset) { using namespace std; - static_assert(is_base_of::value, - "cache must recieve a derivative class of Resource"); + static_assert( + is_base_of::value, "cache must recieve a derivative class of Resource" + ); CacheEntry & entry = this->get_entry(asset); if (entry.resource == nullptr) entry.resource = make_unique(asset, this->mediator); T * concrete_resource = dynamic_cast(entry.resource.get()); if (concrete_resource == nullptr) - throw runtime_error(format("ResourceManager: mismatch between requested type and " - "actual type of resource ({})", - asset.get_path())); + throw runtime_error(format( + "ResourceManager: mismatch between requested type and " + "actual type of resource ({})", + asset.get_path() + )); return *concrete_resource; } diff --git a/src/crepe/manager/SceneManager.cpp b/src/crepe/manager/SceneManager.cpp index d4ca90b..e6f92db 100644 --- a/src/crepe/manager/SceneManager.cpp +++ b/src/crepe/manager/SceneManager.cpp @@ -17,10 +17,12 @@ void SceneManager::load_next_scene() { // next scene not set if (this->next_scene.empty()) return; - auto it = find_if(this->scenes.begin(), this->scenes.end(), - [&next_scene = this->next_scene](unique_ptr & scene) { - return scene.get()->get_name() == next_scene; - }); + auto it = find_if( + this->scenes.begin(), this->scenes.end(), + [&next_scene = this->next_scene](unique_ptr & scene) { + return scene.get()->get_name() == next_scene; + } + ); // next scene not found if (it == this->scenes.end()) return; diff --git a/src/crepe/manager/SystemManager.hpp b/src/crepe/manager/SystemManager.hpp index 8d06eb1..addd274 100644 --- a/src/crepe/manager/SystemManager.hpp +++ b/src/crepe/manager/SystemManager.hpp @@ -11,8 +11,9 @@ namespace crepe { template T & SystemManager::get_system() { using namespace std; - static_assert(is_base_of::value, - "get_system must recieve a derivative class of System"); + static_assert( + is_base_of::value, "get_system must recieve a derivative class of System" + ); const type_info & type = typeid(T); if (!this->systems.contains(type)) @@ -28,8 +29,9 @@ T & SystemManager::get_system() { template void SystemManager::load_system() { using namespace std; - static_assert(is_base_of::value, - "load_system must recieve a derivative class of System"); + static_assert( + is_base_of::value, "load_system must recieve a derivative class of System" + ); const type_info & type = typeid(T); if (this->systems.contains(type)) -- cgit v1.2.3