From 7d8af5f56f9359fff792470fbb55154268b36458 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 25 Oct 2024 21:21:27 +0200 Subject: `make format` --- mwe/events/include/customTypes.h | 55 +++++++++++++++++++-------------------- mwe/events/include/event.h | 12 ++++----- mwe/events/include/eventManager.h | 12 ++++++--- 3 files changed, 40 insertions(+), 39 deletions(-) (limited to 'mwe/events/include') diff --git a/mwe/events/include/customTypes.h b/mwe/events/include/customTypes.h index 7217f8a..a5d8dc9 100644 --- a/mwe/events/include/customTypes.h +++ b/mwe/events/include/customTypes.h @@ -1,39 +1,38 @@ #pragma once #include struct Vector2 { - float x; // X component of the vector - float y; // Y component of the vector + float x; // X component of the vector + float y; // Y component of the vector - // Vector subtraction - Vector2 operator-(const Vector2& other) const { - return {x - other.x, y - other.y}; - } + // Vector subtraction + Vector2 operator-(const Vector2 & other) const { + return {x - other.x, y - other.y}; + } - // Vector addition - Vector2 operator+(const Vector2& other) const { - return {x + other.x, y + other.y}; - } + // Vector addition + Vector2 operator+(const Vector2 & other) const { + return {x + other.x, y + other.y}; + } - // Scalar multiplication - Vector2 operator*(float scalar) const { - return {x * scalar, y * scalar}; - } + // Scalar multiplication + Vector2 operator*(float scalar) const { return {x * scalar, y * scalar}; } - // Normalize the vector - Vector2 normalize() const { - float length = std::sqrt(x * x + y * y); - if (length == 0) return {0, 0}; // Prevent division by zero - return {x / length, y / length}; - } + // Normalize the vector + Vector2 normalize() const { + float length = std::sqrt(x * x + y * y); + if (length == 0) return {0, 0}; // Prevent division by zero + return {x / length, y / length}; + } }; struct Collision { - int objectIdA; // ID of the first object - int objectIdB; // ID of the second object - Vector2 contactPoint; // Point of contact - Vector2 contactNormal; // Normal vector at the contact point - - // Constructor to initialize a Collision - Collision(int idA, int idB, const Vector2& point, const Vector2& normal, float depth) - : objectIdA(idA), objectIdB(idB), contactPoint(point), contactNormal(normal) {} + int objectIdA; // ID of the first object + int objectIdB; // ID of the second object + Vector2 contactPoint; // Point of contact + Vector2 contactNormal; // Normal vector at the contact point + // Constructor to initialize a Collision + Collision(int idA, int idB, const Vector2 & point, const Vector2 & normal, + float depth) + : objectIdA(idA), objectIdB(idB), contactPoint(point), + contactNormal(normal) {} }; diff --git a/mwe/events/include/event.h b/mwe/events/include/event.h index 0208085..730ee4b 100644 --- a/mwe/events/include/event.h +++ b/mwe/events/include/event.h @@ -1,12 +1,11 @@ #pragma once +#include "customTypes.h" #include "keyCodes.h" #include #include #include #include #include -#include "keyCodes.h" -#include "customTypes.h" class UUIDGenerator { public: @@ -93,13 +92,12 @@ private: }; class CollisionEvent : public Event { public: - CollisionEvent(Collision); + CollisionEvent(Collision); - REGISTER_EVENT_TYPE(CollisionEvent) + REGISTER_EVENT_TYPE(CollisionEvent) - Collision getCollisionData() const; + Collision getCollisionData() const; private: - Collision collisionData; - + Collision collisionData; }; diff --git a/mwe/events/include/eventManager.h b/mwe/events/include/eventManager.h index 61e8c01..508a5e2 100644 --- a/mwe/events/include/eventManager.h +++ b/mwe/events/include/eventManager.h @@ -28,10 +28,14 @@ public: void dispatchEvents(); private: - EventManager() = default; - std::vector, int>> eventsQueue; - std::unordered_map>> subscribers; - std::unordered_map>>> subscribersByEventId; + EventManager() = default; + std::vector, int>> eventsQueue; + std::unordered_map>> + subscribers; + std::unordered_map< + int, std::unordered_map< + int, std::vector>>> + subscribersByEventId; }; template -- cgit v1.2.3