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());
}
BaseComponent::operator bool(BaseComponent^ c)
{
return c != nullptr;
}
/*---------------------------------------------------------------------------------*/
/* Constructors */
/*---------------------------------------------------------------------------------*/

View File

@ -101,6 +101,15 @@ namespace SHADE
generic<typename T> where T : ref class, Script
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:
/*-----------------------------------------------------------------------------*/
/* Constructors */

View File

@ -18,6 +18,8 @@ of DigiPen Institute of Technology is prohibited.
#include "Script.hxx"
// Project Headers
#include "Utility/Debug.hxx"
#include "ScriptStore.hxx"
#include "Engine/ECS.hxx"
namespace SHADE
{
@ -49,8 +51,7 @@ namespace SHADE
generic <typename T>
void Script::RemoveComponent()
{
throw gcnew System::NotImplementedException;
//ECS::RemoveComponent<T>(owner.GetNativeEntity());
owner.RemoveComponent<T>();
}
/*---------------------------------------------------------------------------------*/
@ -59,37 +60,37 @@ namespace SHADE
generic <typename T>
T Script::AddScript()
{
throw gcnew System::NotImplementedException;
//return ScriptStore::AddScript<T>(owner.GetEntity());
return ScriptStore::AddScript<T>(owner.GetEntity());
}
generic <typename T>
T Script::GetScript()
{
throw gcnew System::NotImplementedException;
//return ScriptStore::GetScript<T>(owner.GetEntity());
return ScriptStore::GetScript<T>(owner.GetEntity());
}
generic <typename T>
T Script::GetScriptInChildren()
{
throw gcnew System::NotImplementedException;
//return ScriptStore::GetScriptInChildren<T>(owner.GetEntity());
return ScriptStore::GetScriptInChildren<T>(owner.GetEntity());
}
generic <typename T>
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>
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;
}
/*---------------------------------------------------------------------------------*/
/* "All-time" Lifecycle Functions */
/*---------------------------------------------------------------------------------*/

View File

@ -153,6 +153,15 @@ namespace SHADE
generic<typename T> where T : ref class, Script
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:
/*-----------------------------------------------------------------------------*/
/* "All-Time" Lifecycle Functions */