Added Awake, Start, Update, LateUpdate, OnDestroy calls via SystemRoutines

This commit is contained in:
Kah Wei 2022-09-16 17:02:36 +08:00
parent 0f63ee10d0
commit c83a5a379e
6 changed files with 107 additions and 6 deletions

View File

@ -34,11 +34,19 @@ namespace Sandbox
SDL_Init(SDL_INIT_VIDEO);
window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
// Create Systems
SHADE::SHSystemManager::CreateSystem<SHADE::SHGraphicsSystem>();
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem<SHADE::SHGraphicsSystem>());
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHGraphicsSystem, SHADE::SHGraphicsSystem::SHGraphicsSystemRoutine>(1);
SHADE::SHSystemManager::CreateSystem<SHADE::SHScriptEngine>();
// Create Routines
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHScriptEngine, SHADE::SHScriptEngine::FrameSetUpRoutine>();
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHScriptEngine, SHADE::SHScriptEngine::UpdateRoutine>();
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHScriptEngine, SHADE::SHScriptEngine::LateUpdateRoutine>();
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHGraphicsSystem, SHADE::SHGraphicsSystem::SHGraphicsSystemRoutine>(1);
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHScriptEngine, SHADE::SHScriptEngine::FrameCleanUpRoutine>();
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem<SHADE::SHGraphicsSystem>());
graphicsSystem->SetWindow(&window);
SDL_CreateWindowFrom(window.GetHWND());

View File

@ -11,13 +11,14 @@
#pragma once
#include "../SHECSMacros.h"
#include "SH_API.h"
namespace SHADE
{
class SHSystemManager;
class SHSystem
class SH_API SHSystem
{
private:
SystemID systemID;

View File

@ -7,6 +7,7 @@
#include "SHRoutineStats.h"
#include "SHSystem.h"
#include <string>
#include "SH_API.h"
namespace SHADE
@ -15,7 +16,7 @@ namespace SHADE
class SHSystemManager;
class SHSystemRoutine
class SH_API SHSystemRoutine
{
friend class SHSystemManager;
protected:

View File

@ -483,5 +483,4 @@ namespace SHADE
}
}
}
}

View File

@ -19,6 +19,7 @@ of DigiPen Institute of Technology is prohibited.
#include "ECS_Base/SHECSMacros.h"
#include "ECS_Base/Entity/SHEntity.h"
#include "ECS_Base/System/SHSystem.h"
#include "ECS_Base/System/SHSystemRoutine.h"
#include "SH_API.h"
namespace SHADE
@ -27,9 +28,37 @@ namespace SHADE
/// Manages initialisation of the DotNetRuntime and interfacing with CLR code written
/// and executed on .NET.
/// </summary>
class SH_API SHScriptEngine : public SHSystem
class SH_API SHScriptEngine final : public SHSystem
{
public:
/*-----------------------------------------------------------------------------*/
/* Type Definitions */
/*-----------------------------------------------------------------------------*/
class SH_API FrameSetUpRoutine final : public SHSystemRoutine
{
public:
FrameSetUpRoutine();
void Execute(double dt) noexcept override final;
};
class SH_API UpdateRoutine final : public SHSystemRoutine
{
public:
UpdateRoutine();
void Execute(double dt) noexcept override final;
};
class SH_API LateUpdateRoutine final : public SHSystemRoutine
{
public:
LateUpdateRoutine();
void Execute(double dt) noexcept override final;
};
class SH_API FrameCleanUpRoutine final : public SHSystemRoutine
{
public:
FrameCleanUpRoutine();
void Execute(double dt) noexcept override final;
};
/*-----------------------------------------------------------------------------*/
/* Constructor */
/*-----------------------------------------------------------------------------*/

View File

@ -0,0 +1,63 @@
/************************************************************************************//*!
\file SHScriptEngineRoutines.cpp
\author Tng Kah Wei, kahwei.tng, 390009620
\par email: kahwei.tng\@digipen.edu
\date Sep 17, 2021
\brief Contains the implementation or functions of SystemRoutines in the
SHScriptEngine class.
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.
*//*************************************************************************************/
// Precompiled Headers
#include <SHpch.h>
// Primary Header
#include "SHScriptEngine.h"
namespace SHADE
{
/*-----------------------------------------------------------------------------------*/
/* System Routine Functions - FrameSetUpRoutine */
/*-----------------------------------------------------------------------------------*/
SHScriptEngine::FrameSetUpRoutine::FrameSetUpRoutine()
: SHSystemRoutine("Script Engine Frame Set Up", false)
{}
void SHScriptEngine::FrameSetUpRoutine::Execute(double) noexcept
{
reinterpret_cast<SHScriptEngine*>(system)->csScriptsFrameSetUp();
}
/*-----------------------------------------------------------------------------------*/
/* System Routine Functions - UpdateRoutine */
/*-----------------------------------------------------------------------------------*/
SHScriptEngine::UpdateRoutine::UpdateRoutine()
: SHSystemRoutine("Script Engine Update", false)
{}
void SHScriptEngine::UpdateRoutine::Execute(double) noexcept
{
reinterpret_cast<SHScriptEngine*>(system)->csScriptsExecuteUpdate();
}
/*-----------------------------------------------------------------------------------*/
/* System Routine Functions - LateUpdateRoutine */
/*-----------------------------------------------------------------------------------*/
SHScriptEngine::LateUpdateRoutine::LateUpdateRoutine()
: SHSystemRoutine("Script Engine Late Update", false)
{}
void SHScriptEngine::LateUpdateRoutine::Execute(double) noexcept
{
reinterpret_cast<SHScriptEngine*>(system)->csScriptsExecuteLateUpdate();
}
/*-----------------------------------------------------------------------------------*/
/* System Routine Functions - FrameCleanUpRoutine */
/*-----------------------------------------------------------------------------------*/
SHScriptEngine::FrameCleanUpRoutine::FrameCleanUpRoutine()
: SHSystemRoutine("Script Engine Frame Clean Up", false)
{}
void SHScriptEngine::FrameCleanUpRoutine::Execute(double) noexcept
{
reinterpret_cast<SHScriptEngine*>(system)->csScriptsFrameCleanUp();
}
}