From 4f63558f4021d2fea154b59f83cfa0ec77022bae Mon Sep 17 00:00:00 2001 From: maverickdgg Date: Mon, 9 Jan 2023 10:44:36 +0800 Subject: [PATCH 1/2] Added GetComponents to Component Manager --- .../ECS_Base/Managers/SHComponentManager.h | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/SHADE_Engine/src/ECS_Base/Managers/SHComponentManager.h b/SHADE_Engine/src/ECS_Base/Managers/SHComponentManager.h index 8921fbce..9fcbf6f8 100644 --- a/SHADE_Engine/src/ECS_Base/Managers/SHComponentManager.h +++ b/SHADE_Engine/src/ECS_Base/Managers/SHComponentManager.h @@ -23,7 +23,7 @@ #include "SH_API.h" #include "Events/SHEventManager.hpp" - +#include #include namespace SHADE @@ -151,6 +151,32 @@ namespace SHADE return (componentSet.GetSparseSet()->GetElement_s(EntityHandleGenerator::GetIndex(entityID))); } + /*!************************************************************************* + * \brief + * Gets the Component of the entity with the specified entityID + * + * This is the safe version of GetComponent_s which does a HasComponent to make + * sure that the entity has such a component and returns nullptr if it doesn't + * + * This safe version also checks if the sparse set of this component type + * has been created in SHComponentManager and creates one if it doesn't + * + * @tparam T... + * Pack of Types for all the Components to get. + * \param entityID + * EntityID of the entity that we are trying to get the component of. + * \return + * A tuple of pointers to all the components specified. + * Returns nullptr if the entity does not contain such a component. + ***************************************************************************/ + + template + static std::enable_if_t<(... && std::is_base_of_v), std::tuple> GetComponents(EntityID entityID) noexcept + { + return std::make_tuple(GetComponent_s(entityID)...); + } + + /*!************************************************************************* * \brief * Gets the Component of the entity with the specified entityID -- 2.40.1 From 356ec24cc20f93693cef18aa6ff165c3f1cfa299 Mon Sep 17 00:00:00 2001 From: mushgunAX Date: Mon, 9 Jan 2023 17:21:24 +0800 Subject: [PATCH 2/2] Change default pathing for binding file I/O --- Assets/Bindings.SHConfig | 51 ------------------------- SHADE_Engine/src/Input/SHInputManager.h | 5 ++- 2 files changed, 3 insertions(+), 53 deletions(-) diff --git a/Assets/Bindings.SHConfig b/Assets/Bindings.SHConfig index e0023603..573541ac 100644 --- a/Assets/Bindings.SHConfig +++ b/Assets/Bindings.SHConfig @@ -1,52 +1 @@ -4 -Horizontal -0 -0 -5 -0.2 -5 -0 -2 -39 -68 -2 -37 -65 -2 -3 -16 -1 -2 -Mouse Wheel -3 -0 -1 -0.2 -1 -0 -0 -0 -0 -0 -Mouse X -1 -0 -1 -0.2 -1 -0 -0 -0 -0 -0 -Mouse Y -2 -0 -1 -0.2 -1 -0 -0 -0 -0 0 diff --git a/SHADE_Engine/src/Input/SHInputManager.h b/SHADE_Engine/src/Input/SHInputManager.h index 30ee00e8..680035c3 100644 --- a/SHADE_Engine/src/Input/SHInputManager.h +++ b/SHADE_Engine/src/Input/SHInputManager.h @@ -14,6 +14,7 @@ #include #include #include "../../SHADE_Managed/src/SHpch.h" +#include "../../SHADE_Engine/src/Assets/SHAssetMacros.h" #include "SH_API.h" #pragma comment(lib, "xinput.lib") @@ -686,11 +687,11 @@ namespace SHADE /*------------------------------------------------------------------------*/ //Save bindings registered into a file - static void SaveBindings(std::string const& targetFile = "../../Assets/Bindings.SHConfig") noexcept; + static void SaveBindings(std::string const& targetFile = std::string(ASSET_ROOT) + "/Bindings.SHConfig") noexcept; //Load and register bindings from a file //If specified file exists, the current list of bindings will be overwritten, so save them somewhere else before loading - static void LoadBindings(std::string const& sourceFile = "../../Assets/Bindings.SHConfig") noexcept; + static void LoadBindings(std::string const& sourceFile = std::string(ASSET_ROOT) + "/Bindings.SHConfig") noexcept; /*------------------------------------------------------------------------*/ /* Binding Functions */ -- 2.40.1