Added implementation for GameObject.Find()

This commit is contained in:
Kah Wei 2022-10-31 15:28:28 +08:00
parent d03780a9b3
commit f91b1f00ad
1 changed files with 8 additions and 1 deletions

View File

@ -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> 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);
}
/*---------------------------------------------------------------------------------*/