diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-27 14:46:56 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-27 14:46:56 +0100 |
commit | 8554de0ebd75aea3c4b25d2fc211ad3a904f741b (patch) | |
tree | eea2d04de123e560f3c6b69fea0f4ef3f4f86c68 /src | |
parent | e8b93d0ffaccf523139f75ff9b9dc43647e90746 (diff) |
added RefVector
Diffstat (limited to 'src')
-rw-r--r-- | src/crepe/system/InputSystem.cpp | 11 | ||||
-rw-r--r-- | src/crepe/system/InputSystem.h | 4 |
2 files changed, 7 insertions, 8 deletions
diff --git a/src/crepe/system/InputSystem.cpp b/src/crepe/system/InputSystem.cpp index 590be8d..dc5efff 100644 --- a/src/crepe/system/InputSystem.cpp +++ b/src/crepe/system/InputSystem.cpp @@ -89,9 +89,8 @@ void InputSystem::update() { void InputSystem::handle_move(const SDLContext::EventData & event_data) { ComponentManager & mgr = this->component_manager; - std::vector<std::reference_wrapper<Button>> buttons = mgr.get_components_by_type<Button>(); - std::vector<std::reference_wrapper<Transform>> transforms - = mgr.get_components_by_type<Transform>(); + RefVector<Button> buttons = mgr.get_components_by_type<Button>(); + RefVector<Transform> transforms = mgr.get_components_by_type<Transform>(); for (Button & button : buttons) { OptionalRef<Transform> transform = find_transform_for_button(button, transforms); @@ -108,8 +107,8 @@ void InputSystem::handle_move(const SDLContext::EventData & event_data) { void InputSystem::handle_click(const SDLContext::EventData & event_data) { ComponentManager & mgr = this->component_manager; - std::vector<std::reference_wrapper<Button>> buttons = mgr.get_components_by_type<Button>(); - std::vector<std::reference_wrapper<Transform>> transforms = mgr.get_components_by_type<Transform>(); + RefVector<Button> buttons = mgr.get_components_by_type<Button>(); + RefVector<Transform> transforms = mgr.get_components_by_type<Transform>(); for (Button & button : buttons) { OptionalRef<Transform> transform_ref = find_transform_for_button(button, transforms); @@ -122,7 +121,7 @@ void InputSystem::handle_click(const SDLContext::EventData & event_data) { OptionalRef<Transform> InputSystem::find_transform_for_button( - Button & button, std::vector<std::reference_wrapper<Transform>> & transforms) { + Button & button, RefVector<Transform>& transforms) { for (auto& transform : transforms) { if (button.game_object_id == transform.get().game_object_id) { diff --git a/src/crepe/system/InputSystem.h b/src/crepe/system/InputSystem.h index 8b47e49..a2a81bd 100644 --- a/src/crepe/system/InputSystem.h +++ b/src/crepe/system/InputSystem.h @@ -2,6 +2,7 @@ #include "facade/SDLContext.h" #include "util/OptionalRef.h" +#include "types.h" #include "System.h" @@ -61,8 +62,7 @@ private: * \return A pointer to the transform of the button, or nullptr if not found. */ OptionalRef<Transform> - find_transform_for_button(Button & button, - std::vector<std::reference_wrapper<Transform>> & transforms); + find_transform_for_button(Button & button, RefVector<Transform>& transforms); /** * \brief Checks if the mouse position is inside the bounds of the button. |