diff --git a/SHADE_Managed/src/Engine/ECS.cxx b/SHADE_Managed/src/Engine/ECS.cxx index e4405006..36bef851 100644 --- a/SHADE_Managed/src/Engine/ECS.cxx +++ b/SHADE_Managed/src/Engine/ECS.cxx @@ -21,6 +21,9 @@ of DigiPen Institute of Technology is prohibited. #include // External Dependencies #include "ECS_Base/Managers/SHEntityManager.h" +#include "Scene/SHSceneManager.h" +#include "Scene/SHSceneGraph.h" +#include "Tools/SHLog.h" // Project Headers #include "Utility/Convert.hxx" #include "Utility/Debug.hxx" @@ -124,27 +127,31 @@ namespace SHADE return T(); } - // Get Transform component and get the children list - throw gcnew System::NotImplementedException; - //Pls::Transform* tf = Pls::ECS::GetComponent(entity); - //if (tf == nullptr) - // return T(); + // Get Entity's SceneGraphNode + SHSceneNode* sceneGraphNode = SHSceneManager::GetCurrentSceneGraph().GetNode(entity); + if (sceneGraphNode == nullptr) + { + std::ostringstream oss; + oss << "[ECS_CLI] Failed to retrieve SceneGraphNode of entity #" << entity << ". This should not happen!"; + SHLog::Warning(oss.str()); + return T(); + } - //// Search direct children first - //for (const auto& child : tf->GetChildren()) - //{ - // T component = GetComponent(child); - // if (component != nullptr) - // return component; - //} + // Search direct children first + for (const auto& child : sceneGraphNode->GetChildren()) + { + T component = GetComponent(child->GetEntityID()); + if (component != nullptr) + return component; + } - //// Search their children - //for (const auto& child : tf->GetChildren()) - //{ - // T script = GetComponentInChildren(child); - // if (script != nullptr) - // return script; - //} + // Search their children + for (const auto& child : sceneGraphNode->GetChildren()) + { + T component = GetComponentInChildren(child->GetEntityID()); + if (component != nullptr) + return component; + } // None here return T(); diff --git a/SHADE_Managed/src/Engine/GameObject.cxx b/SHADE_Managed/src/Engine/GameObject.cxx index 1fbc3b4a..8c78e399 100644 --- a/SHADE_Managed/src/Engine/GameObject.cxx +++ b/SHADE_Managed/src/Engine/GameObject.cxx @@ -56,7 +56,7 @@ namespace SHADE } bool GameObject::IsActiveInHierarchy::get() { - throw gcnew System::NotImplementedException(); + return true; // TODO: Update once we have an equivalent on the Entity object } /*---------------------------------------------------------------------------------*/ diff --git a/SHADE_Managed/src/Scripts/ScriptStore.cxx b/SHADE_Managed/src/Scripts/ScriptStore.cxx index d30cad6b..089da002 100644 --- a/SHADE_Managed/src/Scripts/ScriptStore.cxx +++ b/SHADE_Managed/src/Scripts/ScriptStore.cxx @@ -20,6 +20,7 @@ of DigiPen Institute of Technology is prohibited. #include // External Dependencies #include "ECS_Base/Managers/SHEntityManager.h" +#include "Tools/SHLog.h" // Project Headers #include "Utility/Debug.hxx" #include "Utility/Convert.hxx" @@ -147,7 +148,6 @@ namespace SHADE // Check if entity exists and is a valid GameObject if (!EntityUtils::IsValid(entity)) throw gcnew System::ArgumentException("Invalid Entity provided to get a Script from."); - // Check if entity exists in the script storage if (!scripts.ContainsKey(entity)) @@ -155,27 +155,31 @@ namespace SHADE return T(); } - // Get Transform component and get the children list - throw gcnew System::NotImplementedException; - //Pls::Transform* tf = Pls::ECS::GetComponent(Convert::ToNative(entity)); - //if (tf == nullptr) - // return T(); + // Get Entity's SceneGraphNode + SHSceneNode* sceneGraphNode = SHSceneManager::GetCurrentSceneGraph().GetNode(entity); + if (sceneGraphNode == nullptr) + { + std::ostringstream oss; + oss << "[ECS_CLI] Failed to retrieve SceneGraphNode of entity #" << entity << ". This should not happen!"; + SHLog::Warning(oss.str()); + return T(); + } - //// Search direct children first - //for (const auto& child : tf->GetChildren()) - //{ - // T script = GetScript(Convert::ToCLI(child)); - // if (script != nullptr) - // return script; - //} + // Search direct children first + for (const auto& child : sceneGraphNode->GetChildren()) + { + T script = GetScript(child->GetEntityID()); + if (script != nullptr) + return script; + } - //// Search their children - //for (const auto& child : tf->GetChildren()) - //{ - // T script = GetScriptInChildren(Convert::ToCLI(child)); - // if (script != nullptr) - // return script; - //} + // Search their children + for (const auto& child : sceneGraphNode->GetChildren()) + { + T script = GetScript(child->GetEntityID()); + if (script != nullptr) + return script; + } // None here return T(); @@ -232,7 +236,6 @@ namespace SHADE // Check if entity exists if (!EntityUtils::IsValid(entity)) throw gcnew System::ArgumentException("Invalid Entity provided to remove a Script from."); - // Check if entity exists in the script storage if (!scripts.ContainsKey(entity)) @@ -263,8 +266,7 @@ namespace SHADE Debug::LogError("[ScriptStore] Attempted to remove a Script from an invalid Entity!"); return false; } - - + // Check if entity exists in the script storage if (!scripts.ContainsKey(entity)) {