Added proper implementation of IsActiveInHierarchy()
This commit is contained in:
parent
f91b1f00ad
commit
2ffba202f7
|
@ -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();
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
using SHADE;
|
||||
|
||||
public class PrintWhenActive : Script
|
||||
{
|
||||
public PrintWhenActive(GameObject gameObj) : base(gameObj) { }
|
||||
|
||||
protected override void update()
|
||||
{
|
||||
Debug.Log("Active!");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue