Merge pull request #138 from SHADE-DP/SP3-6-c-scripting
Added proper implementation of IsActiveInHierarchy()
This commit is contained in:
commit
75e073d45b
|
@ -21,6 +21,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "ECS.hxx"
|
#include "ECS.hxx"
|
||||||
#include "Utility/Convert.hxx"
|
#include "Utility/Convert.hxx"
|
||||||
#include "Scripts/ScriptStore.hxx"
|
#include "Scripts/ScriptStore.hxx"
|
||||||
|
#include "Utility/Debug.hxx"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -63,7 +64,13 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
bool GameObject::IsActiveInHierarchy::get()
|
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)
|
bool ScriptStore::isEntityActive(Entity entity)
|
||||||
{
|
{
|
||||||
// Get native Entity
|
// Invalid entity
|
||||||
SHEntity* nativeEntity = SHEntityManager::GetEntityByID(entity);
|
if (!EntityUtils::IsValid(entity))
|
||||||
|
|
||||||
// Entity Validity Check
|
|
||||||
if (nativeEntity == nullptr)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check active state
|
return GameObject(entity).IsActiveInHierarchy;
|
||||||
return nativeEntity->GetActive();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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