diff --git a/SHADE_Managed/src/Engine/GameObject.cxx b/SHADE_Managed/src/Engine/GameObject.cxx index c9a3cebc..55d53d68 100644 --- a/SHADE_Managed/src/Engine/GameObject.cxx +++ b/SHADE_Managed/src/Engine/GameObject.cxx @@ -21,6 +21,7 @@ of DigiPen Institute of Technology is prohibited. #include "ECS.hxx" #include "Utility/Convert.hxx" #include "Scripts/ScriptStore.hxx" +#include "Utility/Debug.hxx" namespace SHADE { @@ -63,7 +64,13 @@ namespace SHADE } bool GameObject::IsActiveInHierarchy::get() { - return true; // TODO: Update once we have an equivalent on the Entity object + auto node = SHSceneManager::GetCurrentSceneGraph().GetNode(GetEntity()); + if (!node) + { + Debug::LogWarning("Attempting to access a GameObject's ActiveInHierarchy state which does not exist. Assuming inactive."); + return false; + } + return node->IsActive(); } /*---------------------------------------------------------------------------------*/ diff --git a/SHADE_Managed/src/Scripts/ScriptStore.cxx b/SHADE_Managed/src/Scripts/ScriptStore.cxx index 1c732358..d7492fdc 100644 --- a/SHADE_Managed/src/Scripts/ScriptStore.cxx +++ b/SHADE_Managed/src/Scripts/ScriptStore.cxx @@ -667,14 +667,10 @@ namespace SHADE bool ScriptStore::isEntityActive(Entity entity) { - // Get native Entity - SHEntity* nativeEntity = SHEntityManager::GetEntityByID(entity); - - // Entity Validity Check - if (nativeEntity == nullptr) + // Invalid entity + if (!EntityUtils::IsValid(entity)) return false; - // Check active state - return nativeEntity->GetActive(); + return GameObject(entity).IsActiveInHierarchy; } } diff --git a/TempScriptsFolder/PrintWhenActive.cs b/TempScriptsFolder/PrintWhenActive.cs new file mode 100644 index 00000000..41afdd58 --- /dev/null +++ b/TempScriptsFolder/PrintWhenActive.cs @@ -0,0 +1,11 @@ +using SHADE; + +public class PrintWhenActive : Script +{ + public PrintWhenActive(GameObject gameObj) : base(gameObj) { } + + protected override void update() + { + Debug.Log("Active!"); + } +} \ No newline at end of file