diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp index a89ea833..8f17863f 100644 --- a/SHADE_Application/src/Application/SBApplication.cpp +++ b/SHADE_Application/src/Application/SBApplication.cpp @@ -34,11 +34,19 @@ namespace Sandbox SDL_Init(SDL_INIT_VIDEO); window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow); + + // Create Systems SHADE::SHSystemManager::CreateSystem(); - SHADE::SHGraphicsSystem* graphicsSystem = static_cast(SHADE::SHSystemManager::GetSystem()); - SHADE::SHSystemManager::RegisterRoutine(1); SHADE::SHSystemManager::CreateSystem(); + // Create Routines + SHADE::SHSystemManager::RegisterRoutine(); + SHADE::SHSystemManager::RegisterRoutine(); + SHADE::SHSystemManager::RegisterRoutine(); + SHADE::SHSystemManager::RegisterRoutine(1); + SHADE::SHSystemManager::RegisterRoutine(); + + SHADE::SHGraphicsSystem* graphicsSystem = static_cast(SHADE::SHSystemManager::GetSystem()); graphicsSystem->SetWindow(&window); SDL_CreateWindowFrom(window.GetHWND()); diff --git a/SHADE_Engine/src/ECS_Base/System/SHSystem.h b/SHADE_Engine/src/ECS_Base/System/SHSystem.h index 19b16f72..93ea6a59 100644 --- a/SHADE_Engine/src/ECS_Base/System/SHSystem.h +++ b/SHADE_Engine/src/ECS_Base/System/SHSystem.h @@ -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; diff --git a/SHADE_Engine/src/ECS_Base/System/SHSystemRoutine.h b/SHADE_Engine/src/ECS_Base/System/SHSystemRoutine.h index cdb62438..2b6d8dc1 100644 --- a/SHADE_Engine/src/ECS_Base/System/SHSystemRoutine.h +++ b/SHADE_Engine/src/ECS_Base/System/SHSystemRoutine.h @@ -7,6 +7,7 @@ #include "SHRoutineStats.h" #include "SHSystem.h" #include +#include "SH_API.h" namespace SHADE @@ -15,7 +16,7 @@ namespace SHADE class SHSystemManager; - class SHSystemRoutine + class SH_API SHSystemRoutine { friend class SHSystemManager; protected: diff --git a/SHADE_Engine/src/Scripting/SHScriptEngine.cpp b/SHADE_Engine/src/Scripting/SHScriptEngine.cpp index c5490b1e..78b4d544 100644 --- a/SHADE_Engine/src/Scripting/SHScriptEngine.cpp +++ b/SHADE_Engine/src/Scripting/SHScriptEngine.cpp @@ -483,5 +483,4 @@ namespace SHADE } } } - } diff --git a/SHADE_Engine/src/Scripting/SHScriptEngine.h b/SHADE_Engine/src/Scripting/SHScriptEngine.h index 4988f594..f3d69dd5 100644 --- a/SHADE_Engine/src/Scripting/SHScriptEngine.h +++ b/SHADE_Engine/src/Scripting/SHScriptEngine.h @@ -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. /// - 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 */ /*-----------------------------------------------------------------------------*/ diff --git a/SHADE_Engine/src/Scripting/SHScriptEngineRoutines.cpp b/SHADE_Engine/src/Scripting/SHScriptEngineRoutines.cpp new file mode 100644 index 00000000..5467fc56 --- /dev/null +++ b/SHADE_Engine/src/Scripting/SHScriptEngineRoutines.cpp @@ -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 +// 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(system)->csScriptsFrameSetUp(); + } + + /*-----------------------------------------------------------------------------------*/ + /* System Routine Functions - UpdateRoutine */ + /*-----------------------------------------------------------------------------------*/ + SHScriptEngine::UpdateRoutine::UpdateRoutine() + : SHSystemRoutine("Script Engine Update", false) + {} + void SHScriptEngine::UpdateRoutine::Execute(double) noexcept + { + reinterpret_cast(system)->csScriptsExecuteUpdate(); + } + + /*-----------------------------------------------------------------------------------*/ + /* System Routine Functions - LateUpdateRoutine */ + /*-----------------------------------------------------------------------------------*/ + SHScriptEngine::LateUpdateRoutine::LateUpdateRoutine() + : SHSystemRoutine("Script Engine Late Update", false) + {} + void SHScriptEngine::LateUpdateRoutine::Execute(double) noexcept + { + reinterpret_cast(system)->csScriptsExecuteLateUpdate(); + } + + /*-----------------------------------------------------------------------------------*/ + /* System Routine Functions - FrameCleanUpRoutine */ + /*-----------------------------------------------------------------------------------*/ + SHScriptEngine::FrameCleanUpRoutine::FrameCleanUpRoutine() + : SHSystemRoutine("Script Engine Frame Clean Up", false) + {} + void SHScriptEngine::FrameCleanUpRoutine::Execute(double) noexcept + { + reinterpret_cast(system)->csScriptsFrameCleanUp(); + } +}