/************************************************************************************//*!
\file ScriptStore.hxx
\author Tng Kah Wei, kahwei.tng, 390009620
\par email: kahwei.tng\@digipen.edu
\date Oct 28, 2021
\brief Contains the definitions of the GameObject managed class which define an
abstraction for working with Entities in managed code.
Note: This file is written in C++17/CLI.
Copyright (C) 2021 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent
of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
#pragma once
// Project Includes
#include "Engine/Entity.hxx"
#include "Script.hxx"
#include "Serialization/SHSerialization.h"
namespace SHADE
{
///
/// Responsible for managing all scripts attached to Entities as well as executing
/// all lifecycle functions of scripts.
///
public ref class ScriptStore abstract sealed
{
public:
/*-----------------------------------------------------------------------------*/
/* Scripts Manipulation Functions */
/*-----------------------------------------------------------------------------*/
///
/// Adds a Script to a specified Entity.
///
///
/// Type of script to add.
/// This needs to be a default constructable PlushieScript.
///
/// The entity to add a script to.
/// Reference to the script added.
///
/// If the specified Entity is invalid.
///
generic where T : ref class, Script
static T AddScript(Entity entity);
///
/// Adds a Script to a specified Entity.
///
/// This function is meant for consumption from native code. If you are writing
/// in C# or C++/CLI, use AddScript<T>() instead as it is faster.
///
/// The entity to add a script to.
/// The entity to add a script to.
///
/// True if successfully added. False otherwise with the error logged to the
/// console.
///
static bool AddScriptViaName(Entity entity, System::String^ scriptName);
///
/// Adds a Script to a specified Entity.
///
/// This function is meant for consumption from native code or for serialisation
/// purposes. If you are writing in C# or C++/CLI and not doing serialisation,
/// use AddScript<T>() instead as it is faster.
///
/// The entity to add a script to.
/// The entity to add a script to.
///
/// Out parameter handle to the Script that was created.
///
///
/// True if successfully added. False otherwise with the error logged to the
/// console.
///
static bool AddScriptViaNameWithRef(Entity entity, System::String^ scriptName, [System::Runtime::InteropServices::Out] Script^% createdScript);
///
/// Retrieves the first Script from the specified Entity that matches the
/// specified type.
///
///
/// Type of script to get.
/// This needs to be a default constructable Script.
///
///
/// The entity which the script to retrieve is attached.
///
///
/// Reference to the script. This can be null if no script of the specified
/// type is attached.
///
///
/// If the specified Entity is invalid.
///
generic where T : ref class, Script
static T GetScript(Entity entity);
///
/// Retrieves the first Script from the specified Entity's children that matches
/// the specified type.
///
///
/// Type of script to get.
/// This needs to be a default constructable Script.
///
///
/// The entity which the script to retrieve is attached.
///
///
/// Reference to the script. This can be null if no script of the specified
/// type is attached.
///
///
/// If the specified Entity is invalid.
///
generic where T : ref class, Script
static T GetScriptInChildren(Entity entity);
///
/// Retrieves a immutable list of scripts from the specified Entity that
/// matches the specified type.
///
/// Note that this function allocates. It should be used sparingly.
///
///
/// Type of scripts to get.
/// This needs to be a default constructable Script.
///
///
/// The entity which the scripts to retrieve are attached.
///
///
/// Immutable list of references to scripts of the specified type.
///
generic where T : ref class, Script
static System::Collections::Generic::IEnumerable ^ GetScripts(Entity entity);
///
/// Retrieves an immutable list of all scripts attached to a specified Entity.
///
///
/// The entity which the scripts to retrieve are attached.
///
///
/// Immutable list of references to scripts attached to the specified Entity.
/// This can also be null if there are no scripts at all or an invalid Entity
/// was specified.
///
static System::Collections::Generic::IEnumerable