Merge pull request #136 from SHADE-DP/SP3-6-c-scripting
Added Application, GameObject.Find(), implicit null checks for scripts and components and fixed bugs with Script retrieval and deletion
This commit is contained in:
commit
69fbd4167d
|
@ -15,7 +15,7 @@
|
||||||
#include "ECS_Base/System/SHSystemRoutine.h"
|
#include "ECS_Base/System/SHSystemRoutine.h"
|
||||||
#include "Resource/SHHandle.h"
|
#include "Resource/SHHandle.h"
|
||||||
#include "EditorWindow/SHEditorWindow.h"
|
#include "EditorWindow/SHEditorWindow.h"
|
||||||
#include "Tools/SHLogger.h"
|
#include "Tools/SHLog.h"
|
||||||
#include "Gizmos/SHTransformGizmo.h"
|
#include "Gizmos/SHTransformGizmo.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SHLOG_WARNING("Attempt to create duplicate of Editor window type")
|
SHLog::Warning("Attempt to create duplicate of Editor window type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -293,6 +293,10 @@ namespace SHADE
|
||||||
|
|
||||||
//Handle<SHVkRenderpass> GetRenderPass() const { return renderPass; }
|
//Handle<SHVkRenderpass> GetRenderPass() const { return renderPass; }
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Getters */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
SHWindow* GetWindow() noexcept { return window; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
@ -320,7 +324,7 @@ namespace SHADE
|
||||||
SHWindow* window = nullptr;
|
SHWindow* window = nullptr;
|
||||||
|
|
||||||
// Middle End Resources
|
// Middle End Resources
|
||||||
SHResourceHub resourceManager;
|
SHResourceHub resourceManager;
|
||||||
SHMeshLibrary meshLibrary;
|
SHMeshLibrary meshLibrary;
|
||||||
SHTextureLibrary texLibrary;
|
SHTextureLibrary texLibrary;
|
||||||
SHSamplerCache samplerCache;
|
SHSamplerCache samplerCache;
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file SHGraphicsSystemInterface.cpp
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Oct 31, 2022
|
||||||
|
\brief Contains the definitions of the functions of the static
|
||||||
|
SHGraphicsSystemInterface class.
|
||||||
|
|
||||||
|
Copyright (C) 2022 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.
|
||||||
|
*//*************************************************************************************/
|
||||||
|
// Precompiled Headers
|
||||||
|
#include "SHpch.h"
|
||||||
|
// Primary Header
|
||||||
|
#include "SHGraphicsSystemInterface.h"
|
||||||
|
// Project Includes
|
||||||
|
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||||
|
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
|
||||||
|
#include "Graphics/Windowing/SHWindow.h"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
/* Static Usage Functions */
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
uint32_t SHGraphicsSystemInterface::GetWindowWidth()
|
||||||
|
{
|
||||||
|
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
|
||||||
|
if (gfxSystem)
|
||||||
|
{
|
||||||
|
const auto WND = gfxSystem->GetWindow();
|
||||||
|
return WND->GetWindowSize().first;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHLOG_WARNING("[SHGraphicsSystemInterface] Failed to get window width. Value of 0 returned instead.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t SHGraphicsSystemInterface::GetWindowHeight()
|
||||||
|
{
|
||||||
|
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
|
||||||
|
if (gfxSystem)
|
||||||
|
{
|
||||||
|
const auto WND = gfxSystem->GetWindow();
|
||||||
|
return WND->GetWindowSize().second;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHLOG_WARNING("[SHGraphicsSystemInterface] Failed to get window height. Value of 0 returned instead.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SHGraphicsSystemInterface::IsFullscreen()
|
||||||
|
{
|
||||||
|
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
|
||||||
|
if (gfxSystem)
|
||||||
|
{
|
||||||
|
const auto WND = gfxSystem->GetWindow();
|
||||||
|
return WND->GetWindowData().isFullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHLOG_WARNING("[SHGraphicsSystemInterface] Failed to get window fullscreen status. Value of false returned instead.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHGraphicsSystemInterface::CloseWindow()
|
||||||
|
{
|
||||||
|
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
|
||||||
|
if (gfxSystem)
|
||||||
|
{
|
||||||
|
auto WND = gfxSystem->GetWindow();
|
||||||
|
return WND->Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
SHLOG_WARNING("[SHGraphicsSystemInterface] Failed to close window.");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file SHGraphicsSystemInterface.h
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Oct 31, 2022
|
||||||
|
\brief Contains the definition of the SHGraphicsSystemInterface static class.
|
||||||
|
|
||||||
|
Copyright (C) 2022 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
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Static class that wraps up certain functions in the SHGraphicsSystem so that
|
||||||
|
/// accessing it from SHADE_Managed would not cause issues due to C++20 features.
|
||||||
|
/// </summary>
|
||||||
|
class SH_API SHGraphicsSystemInterface final
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Constructor */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
SHGraphicsSystemInterface() = delete;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Static Usage Functions */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the current window width.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The current window width.</returns>
|
||||||
|
static uint32_t GetWindowWidth();
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the current window height.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The current window height.</returns>
|
||||||
|
static uint32_t GetWindowHeight();
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the current window fullscreen status.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The current window fullscreen status..</returns>
|
||||||
|
static bool IsFullscreen();
|
||||||
|
/// <summary>
|
||||||
|
/// Closes the current window, and depending on the implementation, should also
|
||||||
|
/// close the application.
|
||||||
|
/// </summary>
|
||||||
|
static void CloseWindow();
|
||||||
|
};
|
||||||
|
}
|
|
@ -260,7 +260,7 @@ namespace SHADE
|
||||||
return wndHWND;
|
return wndHWND;
|
||||||
}
|
}
|
||||||
|
|
||||||
const WindowData SHWindow::GetWindowData()
|
const WindowData SHWindow::GetWindowData() const
|
||||||
{
|
{
|
||||||
return wndData;
|
return wndData;
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ namespace SHADE
|
||||||
|
|
||||||
HWND GetHWND();
|
HWND GetHWND();
|
||||||
|
|
||||||
const WindowData GetWindowData();
|
const WindowData GetWindowData() const;
|
||||||
|
|
||||||
CALLBACKID RegisterWindowSizeCallback(WindowResizeCallbackFn);
|
CALLBACKID RegisterWindowSizeCallback(WindowResizeCallbackFn);
|
||||||
void UnregisterWindowSizeCallback(CALLBACKID const& callbackid);
|
void UnregisterWindowSizeCallback(CALLBACKID const& callbackid);
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace SHADE
|
||||||
/* System Routine Functions - FrameCleanUpRoutine */
|
/* System Routine Functions - FrameCleanUpRoutine */
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
SHScriptEngine::FrameCleanUpRoutine::FrameCleanUpRoutine()
|
SHScriptEngine::FrameCleanUpRoutine::FrameCleanUpRoutine()
|
||||||
: SHSystemRoutine("Script Engine Frame Clean Up", false)
|
: SHSystemRoutine("Script Engine Frame Clean Up", true)
|
||||||
{}
|
{}
|
||||||
void SHScriptEngine::FrameCleanUpRoutine::Execute(double) noexcept
|
void SHScriptEngine::FrameCleanUpRoutine::Execute(double) noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ Copyright (C) 2022 DigiPen Institute of Technology.
|
||||||
Reproduction or disclosure of this file or its contents without the prior written consent
|
Reproduction or disclosure of this file or its contents without the prior written consent
|
||||||
of DigiPen Institute of Technology is prohibited.
|
of DigiPen Institute of Technology is prohibited.
|
||||||
*//*************************************************************************************/
|
*//*************************************************************************************/
|
||||||
|
#pragma once
|
||||||
// Standard Library
|
// Standard Library
|
||||||
#include <string>
|
#include <string>
|
||||||
// Project Headers
|
// Project Headers
|
||||||
|
|
|
@ -25,11 +25,16 @@ project "SHADE_Managed"
|
||||||
includedirs
|
includedirs
|
||||||
{
|
{
|
||||||
"%{prj.location}/src",
|
"%{prj.location}/src",
|
||||||
|
}
|
||||||
|
|
||||||
|
externalincludedirs
|
||||||
|
{
|
||||||
"%{IncludeDir.spdlog}/include",
|
"%{IncludeDir.spdlog}/include",
|
||||||
"%{IncludeDir.imgui}",
|
"%{IncludeDir.imgui}",
|
||||||
"%{IncludeDir.imguizmo}",
|
"%{IncludeDir.imguizmo}",
|
||||||
"%{IncludeDir.imnodes}",
|
"%{IncludeDir.imnodes}",
|
||||||
"%{IncludeDir.yamlcpp}",
|
"%{IncludeDir.yamlcpp}",
|
||||||
|
"%{IncludeDir.SDL}\\include",
|
||||||
"%{IncludeDir.RTTR}/include",
|
"%{IncludeDir.RTTR}/include",
|
||||||
"%{IncludeDir.dotnet}\\include",
|
"%{IncludeDir.dotnet}\\include",
|
||||||
"%{IncludeDir.reactphysics3d}\\include",
|
"%{IncludeDir.reactphysics3d}\\include",
|
||||||
|
@ -38,13 +43,16 @@ project "SHADE_Managed"
|
||||||
|
|
||||||
libdirs
|
libdirs
|
||||||
{
|
{
|
||||||
"%{IncludeDir.RTTR}/lib"
|
"%{IncludeDir.RTTR}/lib",
|
||||||
|
"%{IncludeDir.SDL}/lib"
|
||||||
}
|
}
|
||||||
|
|
||||||
links
|
links
|
||||||
{
|
{
|
||||||
"yaml-cpp",
|
"yaml-cpp",
|
||||||
"imgui",
|
"imgui",
|
||||||
|
"SDL2.lib",
|
||||||
|
"SDL2main.lib",
|
||||||
"SHADE_Engine",
|
"SHADE_Engine",
|
||||||
"SHADE_CSharp"
|
"SHADE_CSharp"
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -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 */
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file Application.cxx
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Oct 31, 2022
|
||||||
|
\brief Contains the definitions of the functions in the static managed
|
||||||
|
Application class.
|
||||||
|
|
||||||
|
Note: This file is written in C++17/CLI.
|
||||||
|
|
||||||
|
Copyright (C) 2022 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.
|
||||||
|
*//*************************************************************************************/
|
||||||
|
// Precompiled Headers
|
||||||
|
#include "SHpch.h"
|
||||||
|
// Primary Header
|
||||||
|
#include "Application.hxx"
|
||||||
|
// External Dependencies
|
||||||
|
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||||
|
#include "Editor/SHEditor.h"
|
||||||
|
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystemInterface.h"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Properties */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
bool Application::IsPlaying::get()
|
||||||
|
{
|
||||||
|
auto editor = SHSystemManager::GetSystem<SHEditor>();
|
||||||
|
if (editor)
|
||||||
|
return editor->editorState == SHEditor::State::PLAY
|
||||||
|
||
|
||||||
|
editor->editorState == SHEditor::State::PAUSE;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool Application::IsPaused::get()
|
||||||
|
{
|
||||||
|
auto editor = SHSystemManager::GetSystem<SHEditor>();
|
||||||
|
if (editor)
|
||||||
|
return editor->editorState == SHEditor::State::PAUSE;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int Application::WindowWidth::get()
|
||||||
|
{
|
||||||
|
return SHGraphicsSystemInterface::GetWindowWidth();
|
||||||
|
}
|
||||||
|
int Application::WindowHeight::get()
|
||||||
|
{
|
||||||
|
return SHGraphicsSystemInterface::GetWindowWidth();
|
||||||
|
}
|
||||||
|
bool Application::IsFullscreen::get()
|
||||||
|
{
|
||||||
|
return SHGraphicsSystemInterface::IsFullscreen();
|
||||||
|
}
|
||||||
|
/*void Application::IsFullscreen::set(bool value)
|
||||||
|
{
|
||||||
|
return SHGraphicsSystemInterface::SetFullscreen(value);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Usage Functions */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
void Application::Quit()
|
||||||
|
{
|
||||||
|
SHGraphicsSystemInterface::CloseWindow();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file Application.hxx
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Oct 31, 2022
|
||||||
|
\brief Contains the definitions of a managed static Application class.
|
||||||
|
|
||||||
|
Note: This file is written in C++17/CLI.
|
||||||
|
|
||||||
|
Copyright (C) 2022 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
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Static class that contains useful properties for querying the state of the
|
||||||
|
/// engine.
|
||||||
|
/// </summary>
|
||||||
|
public ref class Application abstract sealed
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Properties */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Whether or not the engine is playing. This will always be true on Publish.
|
||||||
|
/// On Debug/Release builds, this is true when the editor is in Play Mode. It
|
||||||
|
/// will also be true even if the editor is in Play Mode but is paused.
|
||||||
|
/// </summary>
|
||||||
|
static property bool IsPlaying
|
||||||
|
{
|
||||||
|
bool get();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Whether or not the engine is in a paused state where script updates and
|
||||||
|
/// physics are not in play.
|
||||||
|
/// </summary>
|
||||||
|
static property bool IsPaused
|
||||||
|
{
|
||||||
|
bool get();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the designated width of the current window.
|
||||||
|
/// </summary>
|
||||||
|
static property int WindowWidth
|
||||||
|
{
|
||||||
|
int get();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the designated height of the current window.
|
||||||
|
/// </summary>
|
||||||
|
static property int WindowHeight
|
||||||
|
{
|
||||||
|
int get();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Whether or not the application is currently in fullscreen mode or not.
|
||||||
|
/// </summary>
|
||||||
|
static property bool IsFullscreen
|
||||||
|
{
|
||||||
|
bool get();
|
||||||
|
// TODO: once implemented on SHADE_Engine
|
||||||
|
//void set(bool value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Usage Functions */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Marks the application to stop at the end of the current frame.
|
||||||
|
/// </summary>
|
||||||
|
static void Quit();
|
||||||
|
};
|
||||||
|
}
|
|
@ -19,6 +19,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "ECS_Base/Managers/SHEntityManager.h"
|
#include "ECS_Base/Managers/SHEntityManager.h"
|
||||||
// Project Headers
|
// Project Headers
|
||||||
#include "ECS.hxx"
|
#include "ECS.hxx"
|
||||||
|
#include "Utility/Convert.hxx"
|
||||||
#include "Scripts/ScriptStore.hxx"
|
#include "Scripts/ScriptStore.hxx"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
|
@ -39,7 +40,13 @@ namespace SHADE
|
||||||
System::Nullable<GameObject> GameObject::Find(System::String ^ name)
|
System::Nullable<GameObject> GameObject::Find(System::String ^ name)
|
||||||
{
|
{
|
||||||
// Search the GameObjectLibrary for an Entity with the specified name
|
// Search the GameObjectLibrary for an Entity with the specified name
|
||||||
throw gcnew System::NotImplementedException();
|
const auto ENTITY_ID = SHEntityManager::GetEntityByName(Convert::ToNative(name));
|
||||||
|
if (ENTITY_ID == MAX_EID)
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return GameObject(ENTITY_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -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 */
|
||||||
|
|
|
@ -27,6 +27,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "Script.hxx"
|
#include "Script.hxx"
|
||||||
#include "Engine/Entity.hxx"
|
#include "Engine/Entity.hxx"
|
||||||
#include "Serialisation/ReflectionUtilities.hxx"
|
#include "Serialisation/ReflectionUtilities.hxx"
|
||||||
|
#include "Engine/Application.hxx"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -373,7 +374,10 @@ namespace SHADE
|
||||||
while (disposalQueue.Count > 0)
|
while (disposalQueue.Count > 0)
|
||||||
{
|
{
|
||||||
Script^ script = disposalQueue.Dequeue();
|
Script^ script = disposalQueue.Dequeue();
|
||||||
script->OnDestroy();
|
if (Application::IsPlaying)
|
||||||
|
{
|
||||||
|
script->OnDestroy();
|
||||||
|
}
|
||||||
auto entity = script->Owner.GetEntity();
|
auto entity = script->Owner.GetEntity();
|
||||||
auto scriptList = scripts[script->Owner.GetEntity()];
|
auto scriptList = scripts[script->Owner.GetEntity()];
|
||||||
scriptList->Remove(script);
|
scriptList->Remove(script);
|
||||||
|
@ -388,7 +392,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
SAFE_NATIVE_CALL_BEGIN
|
SAFE_NATIVE_CALL_BEGIN
|
||||||
// Run the deinit all scripts if needed
|
// Run the deinit all scripts if needed
|
||||||
//if (Application::IsPlaying)
|
if (Application::IsPlaying)
|
||||||
{
|
{
|
||||||
Debug::Log("Running OnDestroy() for scripts.");
|
Debug::Log("Running OnDestroy() for scripts.");
|
||||||
for each (System::Collections::Generic::KeyValuePair<Entity, ScriptList^> entity in scripts)
|
for each (System::Collections::Generic::KeyValuePair<Entity, ScriptList^> entity in scripts)
|
||||||
|
|
Loading…
Reference in New Issue