Added implementation for scripts and component functions for scripts

This commit is contained in:
Kah Wei 2022-10-31 15:07:10 +08:00
parent 66529474cd
commit b04565c9dc
4 changed files with 37 additions and 13 deletions

View File

@ -67,6 +67,11 @@ namespace SHADE
ScriptStore::RemoveScript<T>(owner.GetEntity()); ScriptStore::RemoveScript<T>(owner.GetEntity());
} }
BaseComponent::operator bool(BaseComponent^ c)
{
return c != nullptr;
}
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* Constructors */ /* Constructors */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/

View File

@ -101,6 +101,15 @@ namespace SHADE
generic<typename T> where T : ref class, Script generic<typename T> where T : ref class, Script
void RemoveScript(); void RemoveScript();
/*-----------------------------------------------------------------------------*/
/* Operator Overloads */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Implicit conversion operator to enable checking if a component is null.
/// </summary>
/// <param name="c">Component to check.</param>
static operator bool(BaseComponent^ c);
protected: protected:
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Constructors */ /* Constructors */

View File

@ -18,6 +18,8 @@ of DigiPen Institute of Technology is prohibited.
#include "Script.hxx" #include "Script.hxx"
// Project Headers // Project Headers
#include "Utility/Debug.hxx" #include "Utility/Debug.hxx"
#include "ScriptStore.hxx"
#include "Engine/ECS.hxx"
namespace SHADE namespace SHADE
{ {
@ -49,8 +51,7 @@ namespace SHADE
generic <typename T> generic <typename T>
void Script::RemoveComponent() void Script::RemoveComponent()
{ {
throw gcnew System::NotImplementedException; owner.RemoveComponent<T>();
//ECS::RemoveComponent<T>(owner.GetNativeEntity());
} }
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
@ -59,35 +60,35 @@ namespace SHADE
generic <typename T> generic <typename T>
T Script::AddScript() T Script::AddScript()
{ {
throw gcnew System::NotImplementedException; return ScriptStore::AddScript<T>(owner.GetEntity());
//return ScriptStore::AddScript<T>(owner.GetEntity());
} }
generic <typename T> generic <typename T>
T Script::GetScript() T Script::GetScript()
{ {
throw gcnew System::NotImplementedException; return ScriptStore::GetScript<T>(owner.GetEntity());
//return ScriptStore::GetScript<T>(owner.GetEntity());
} }
generic <typename T> generic <typename T>
T Script::GetScriptInChildren() T Script::GetScriptInChildren()
{ {
throw gcnew System::NotImplementedException; return ScriptStore::GetScriptInChildren<T>(owner.GetEntity());
//return ScriptStore::GetScriptInChildren<T>(owner.GetEntity());
} }
generic <typename T> generic <typename T>
System::Collections::Generic::IEnumerable<T>^ Script::GetScripts() System::Collections::Generic::IEnumerable<T>^ Script::GetScripts()
{ {
throw gcnew System::NotImplementedException; return ScriptStore::GetScripts<T>(owner.GetEntity());
//return ScriptStore::GetScripts<T>(owner.GetEntity());
} }
generic <typename T> generic <typename T>
void Script::RemoveScript() void Script::RemoveScript()
{ {
throw gcnew System::NotImplementedException; ScriptStore::RemoveScript<T>(owner.GetEntity());
//ScriptStore::RemoveScript<T>(owner.GetEntity()); }
Script::operator bool(Script^ s)
{
return s != nullptr;
} }
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/

View File

@ -153,6 +153,15 @@ namespace SHADE
generic<typename T> where T : ref class, Script generic<typename T> where T : ref class, Script
void RemoveScript(); void RemoveScript();
/*-----------------------------------------------------------------------------*/
/* Operator Overloads */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Implicit conversion operator to enable checking if a component is null.
/// </summary>
/// <param name="c">Component to check.</param>
static operator bool(Script^ s);
internal: internal:
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* "All-Time" Lifecycle Functions */ /* "All-Time" Lifecycle Functions */