From f91b1f00ad887b08c228ced6693875691140cc08 Mon Sep 17 00:00:00 2001 From: Kah Wei Date: Mon, 31 Oct 2022 15:28:28 +0800 Subject: [PATCH] Added implementation for GameObject.Find() --- SHADE_Managed/src/Engine/GameObject.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/SHADE_Managed/src/Engine/GameObject.cxx b/SHADE_Managed/src/Engine/GameObject.cxx index 8c78e399..c9a3cebc 100644 --- a/SHADE_Managed/src/Engine/GameObject.cxx +++ b/SHADE_Managed/src/Engine/GameObject.cxx @@ -19,6 +19,7 @@ of DigiPen Institute of Technology is prohibited. #include "ECS_Base/Managers/SHEntityManager.h" // Project Headers #include "ECS.hxx" +#include "Utility/Convert.hxx" #include "Scripts/ScriptStore.hxx" namespace SHADE @@ -39,7 +40,13 @@ namespace SHADE System::Nullable GameObject::Find(System::String ^ name) { // Search the GameObjectLibrary for an Entity with the specified name - throw gcnew System::NotImplementedException(); + const auto ENTITY_ID = SHEntityManager::GetEntityByName(Convert::ToNative(name)); + if (ENTITY_ID == MAX_EID) + { + return {}; + } + + return GameObject(ENTITY_ID); } /*---------------------------------------------------------------------------------*/