Merge remote-tracking branch 'origin/main' into SP3-2-Physics

This commit is contained in:
Diren D Bharwani 2022-10-31 16:53:41 +08:00
commit 3d53a7cd40
3 changed files with 22 additions and 8 deletions

View File

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

View File

@ -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;
}
}

View File

@ -0,0 +1,11 @@
using SHADE;
public class PrintWhenActive : Script
{
public PrintWhenActive(GameObject gameObj) : base(gameObj) { }
protected override void update()
{
Debug.Log("Active!");
}
}