diff --git a/.gitignore b/.gitignore
index c7fefb6e..1110510c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@ x86/
bld/
[Bb]in/
[Bb]in-int/
+[Bb]in_int/
[Oo]bj/
[Ll]og/
[Ll]ogs/
@@ -359,3 +360,5 @@ MigrationBackup/
*.vcxproj.filters
*.sln
*.csproj
+
+*.filters
diff --git a/Dependencies.lua b/Dependencies.lua
index 9877a70e..824b512d 100644
--- a/Dependencies.lua
+++ b/Dependencies.lua
@@ -1,16 +1,16 @@
IncludeDir = {}
-IncludeDir["assimp"] = "%{wks.location}/Dependencies/assimp"
-IncludeDir["imgui"] = "%{wks.location}/Dependencies/imgui"
-IncludeDir["imguizmo"] = "%{wks.location}/Dependencies/imguizmo"
-IncludeDir["imnodes"] = "%{wks.location}/Dependencies/imnodes"
-IncludeDir["msdf_atlas_gen"] = "%{wks.location}/Dependencies/msdf"
-IncludeDir["msdfgen"] = "%{wks.location}/Dependencies/msdf/msdfgen"
-IncludeDir["spdlog"] = "%{wks.location}/Dependencies/spdlog"
-IncludeDir["tracy"] = "%{wks.location}/Dependencies/tracy"
-IncludeDir["VMA"] = "%{wks.location}/Dependencies/VMA"
-IncludeDir["yamlcpp"] = "%{wks.location}/Dependencies/yamlcpp/include"
-IncludeDir["RTTR"] = "%{wks.location}/Dependencies/RTTR"
-IncludeDir["reactphysics3d"] = "%{wks.location}/Dependencies/reactphysics3d"
-IncludeDir["SDL"] = "%{wks.location}/Dependencies/SDL"
+IncludeDir["assimp"] = "%{wks.location}\\Dependencies\\assimp"
+IncludeDir["imgui"] = "%{wks.location}\\Dependencies\\imgui"
+IncludeDir["imguizmo"] = "%{wks.location}\\Dependencies\\imguizmo"
+IncludeDir["imnodes"] = "%{wks.location}\\Dependencies\\imnodes"
+IncludeDir["msdf_atlas_gen"] = "%{wks.location}\\Dependencies\\msdf"
+IncludeDir["msdfgen"] = "%{wks.location}\\Dependencies\\msdf\\msdfgen"
+IncludeDir["spdlog"] = "%{wks.location}\\Dependencies\\spdlog"
+IncludeDir["tracy"] = "%{wks.location}\\Dependencies\\tracy"
+IncludeDir["VMA"] = "%{wks.location}\\Dependencies\\VMA"
+IncludeDir["yamlcpp"] = "%{wks.location}\\Dependencies\\yamlcpp\\include"
+IncludeDir["RTTR"] = "%{wks.location}\\Dependencies\\RTTR"
+IncludeDir["reactphysics3d"] = "%{wks.location}\\Dependencies\\reactphysics3d"
+IncludeDir["SDL"] = "%{wks.location}\\Dependencies\\SDL"
IncludeDir["VULKAN"] = "$(VULKAN_SDK)"
-IncludeDir["dotnet"] = "%{wks.location}/Dependencies/dotnet"
+IncludeDir["dotnet"] = "%{wks.location}\\Dependencies\\dotnet"
diff --git a/SHADE_Application/SHADE_Application.vcxproj b/SHADE_Application/SHADE_Application.vcxproj
deleted file mode 100644
index 0a7457a0..00000000
--- a/SHADE_Application/SHADE_Application.vcxproj
+++ /dev/null
@@ -1,132 +0,0 @@
-
-
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
- {BDC70008-29DE-FE9D-7255-8ABFDEAACF25}
- true
- Win32Proj
- SHADE_Application
- 10.0
-
-
-
- Application
- true
- Unicode
- v142
-
-
- Application
- false
- Unicode
- v142
-
-
-
-
-
-
-
-
-
-
-
-
- true
- ..\bin\Debug\
- ..\bin_int\Debug\SHADE_Application\
- SHADE_Application
- .exe
- ..\Dependencies\spdlog\include;$(VULKAN_SDK)\include;..\Dependencies\VMA\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;$(IncludePath)
-
-
- false
- ..\bin\Release\
- ..\bin_int\Release\SHADE_Application\
- SHADE_Application
- .exe
- ..\Dependencies\spdlog\include;$(VULKAN_SDK)\include;..\Dependencies\VMA\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;$(IncludePath)
-
-
-
- Use
- SBpch.h
- Level4
- 4251;%(DisableSpecificWarnings)
- NOMINMAX;_DEBUG;%(PreprocessorDefinitions)
- ..\SHADE_Engine\src;src;..\Dependencies\dotnet\include;..\Dependencies\SDL\include;%(AdditionalIncludeDirectories)
- EditAndContinue
- Disabled
- false
- MultiThreadedDebugDLL
- true
- stdcpp20
-
-
- Windows
- true
- SDL2.lib;SDL2main.lib;%(AdditionalDependencies)
- ..\Dependencies\spdlog\lib;..\Dependencies\SDL\lib;%(AdditionalLibraryDirectories)
- wWinMainCRTStartup
-
-
-
-
- Use
- SBpch.h
- Level4
- 4251;%(DisableSpecificWarnings)
- NOMINMAX;_RELEASE;%(PreprocessorDefinitions)
- ..\SHADE_Engine\src;src;..\Dependencies\dotnet\include;..\Dependencies\SDL\include;%(AdditionalIncludeDirectories)
- Full
- true
- true
- false
- true
- MultiThreadedDLL
- true
- stdcpp20
-
-
- Windows
- true
- true
- SDL2.lib;SDL2main.lib;%(AdditionalDependencies)
- ..\Dependencies\spdlog\lib;..\Dependencies\SDL\lib;%(AdditionalLibraryDirectories)
- wWinMainCRTStartup
-
-
-
-
-
-
-
-
-
-
- Create
-
-
-
-
-
-
- {3F92E998-2BF5-783D-D47A-B1F3C0BC44C0}
-
-
- {16DB1400-829B-9036-4BD6-D9B3B755D512}
-
-
-
-
-
-
\ No newline at end of file
diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp
index 847374d7..53cc1e40 100644
--- a/SHADE_Application/src/Application/SBApplication.cpp
+++ b/SHADE_Application/src/Application/SBApplication.cpp
@@ -43,28 +43,34 @@ namespace Sandbox
SDL_Init(SDL_INIT_EVERYTHING);
window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
+
+ // Create Systems
SHADE::SHSystemManager::CreateSystem();
+ SHADE::SHSystemManager::CreateSystem();
SHADE::SHGraphicsSystem* graphicsSystem = static_cast(SHADE::SHSystemManager::GetSystem());
+
+ // Create Routines
+ SHADE::SHSystemManager::RegisterRoutine();
+ SHADE::SHSystemManager::RegisterRoutine();
+ SHADE::SHSystemManager::RegisterRoutine();
+ SHADE::SHSystemManager::RegisterRoutine();
SHADE::SHSystemManager::RegisterRoutine();
SHADE::SHSystemManager::RegisterRoutine();
SHADE::SHSystemManager::RegisterRoutine();
SHADE::SHSystemManager::RegisterRoutine();
SHADE::SHComponentManager::CreateComponentSparseSet();
-
+ // Set up graphics system and windows
graphicsSystem->SetWindow(&window);
sdlWindow = SDL_CreateWindowFrom(window.GetHWND());
//auto [w, h] = window.GetWindowSize();
//SDL_SetWindowSize(sdlWindow, w, h);
SHADE::SHSystemManager::Init();
- #ifdef SHEDITOR
+ #ifdef SHEDITOR
SHADE::SHEditor::Initialise(sdlWindow);
- #else
- #endif
-
- // Set up scripting
- SHADE::SHScriptEngine::Init();
+ #else
+ #endif
SHSceneManager::InitSceneManager("TestScene");
}
@@ -99,11 +105,10 @@ namespace Sandbox
void SBApplication::Exit(void)
{
- #ifdef SHEDITOR
+ #ifdef SHEDITOR
SHADE::SHEditor::Exit();
#endif
SHSceneManager::Exit();
- SHADE::SHScriptEngine::Exit();
SHADE::SHSystemManager::Exit();
SDL_DestroyWindow(sdlWindow);
SDL_Quit();
diff --git a/SHADE_Application/src/Scenes/SBTestScene.cpp b/SHADE_Application/src/Scenes/SBTestScene.cpp
index aef39ddd..93d4e19b 100644
--- a/SHADE_Application/src/Scenes/SBTestScene.cpp
+++ b/SHADE_Application/src/Scenes/SBTestScene.cpp
@@ -7,6 +7,7 @@
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
#include "Scene/SHSceneManager.h"
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
+#include "Scripting/SHScriptEngine.h"
#include "Math/Transform/SHTransformComponent.h"
using namespace SHADE;
@@ -50,6 +51,10 @@ namespace Sandbox
renderable.TransformMatrix.Translate(0.0f, 0.0f, 2.0f);
transform.SetWorldPosition (SHVec3 (0.0f, 0.0f, 2.0f));
+
+ // Add script
+ SHADE::SHScriptEngine* scriptEngine = static_cast(SHADE::SHSystemManager::GetSystem());
+ scriptEngine->AddScript(*SHADE::SHEntityManager::GetEntityByID(testEntity), "TestScript");
}
void SBTestScene::Update(float dt)
{
@@ -59,6 +64,10 @@ namespace Sandbox
transform.SetWorldRotation (rotation, 0.0f, 0.0f);
rotation += dt * 10.0f;
+
+ // Destroy entity if space is pressed
+ if (GetKeyState(VK_SPACE) & 0x8000)
+ SHADE::SHEntityManager::DestroyEntity(testObj);
}
void SBTestScene::Render()
diff --git a/SHADE_Engine/SHADE_Engine.vcxproj b/SHADE_Engine/SHADE_Engine.vcxproj
deleted file mode 100644
index 2aa3b608..00000000
--- a/SHADE_Engine/SHADE_Engine.vcxproj
+++ /dev/null
@@ -1,383 +0,0 @@
-
-
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
- {3F92E998-2BF5-783D-D47A-B1F3C0BC44C0}
- true
- Win32Proj
- SHADE_Engine
- 10.0
-
-
-
- DynamicLibrary
- true
- Unicode
- v142
-
-
- DynamicLibrary
- false
- Unicode
- v142
-
-
-
-
-
-
-
-
-
-
-
-
- true
- ..\bin\Debug\
- ..\bin_int\Debug\SHADE_Engine\
- SHADE_Engine
- .dll
- ..\Dependencies\assimp\include;..\Dependencies\imgui;..\Dependencies\imguizmo;..\Dependencies\imnodes;..\Dependencies\msdf;..\Dependencies\msdf\msdfgen;..\Dependencies\spdlog\include;..\Dependencies\tracy;..\Dependencies\VMA\include;..\Dependencies\yamlcpp\include;..\Dependencies\SDL\include;..\Dependencies\RTTR\include;..\Dependencies\reactphysics3d\include;$(VULKAN_SDK)\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;..\Dependencies\dotnet\include;$(IncludePath)
-
-
- false
- ..\bin\Release\
- ..\bin_int\Release\SHADE_Engine\
- SHADE_Engine
- .dll
- ..\Dependencies\assimp\include;..\Dependencies\imgui;..\Dependencies\imguizmo;..\Dependencies\imnodes;..\Dependencies\msdf;..\Dependencies\msdf\msdfgen;..\Dependencies\spdlog\include;..\Dependencies\tracy;..\Dependencies\VMA\include;..\Dependencies\yamlcpp\include;..\Dependencies\SDL\include;..\Dependencies\RTTR\include;..\Dependencies\reactphysics3d\include;$(VULKAN_SDK)\include;$(VULKAN_SDK)\Source\SPIRV-Reflect;..\Dependencies\dotnet\include;$(IncludePath)
-
-
-
- Use
- SHpch.h
- Level4
- 4251;%(DisableSpecificWarnings)
- _LIB;_GLFW_INCLUDE_NONE;MSDFGEN_USE_CPP11;NOMINMAX;SH_API_EXPORT;_DEBUG;%(PreprocessorDefinitions)
- src;%(AdditionalIncludeDirectories)
- EditAndContinue
- Disabled
- false
- MultiThreadedDebugDLL
- true
- stdcpp20
-
-
- Windows
- true
- vulkan-1.lib;SDL2.lib;SDL2main.lib;shaderc_shared.lib;shlwapi.lib;assimp-vc142-mtd.lib;librttr_core_d.lib;spdlogd.lib;%(AdditionalDependencies)
- libs;$(VULKAN_SDK)\Lib;..\Dependencies\assimp\lib\Debug;..\Dependencies\assimp\lib\Release;..\Dependencies\RTTR\lib;..\Dependencies\SDL\lib;..\Dependencies\spdlog\lib;%(AdditionalLibraryDirectories)
- ..\bin\Debug\SHADE_Engine.lib
-
-
- xcopy /s /r /y /q "$(SolutionDir)/Dependencies/spdlog/bin" "$(OutDir)"
-xcopy /r /y /q "$(SolutionDir)/Dependencies/SDL/lib/SDL2.dll" "$(OutDir)"
-xcopy /s /r /y /q "$(SolutionDir)/Dependencies/dotnet/bin" "$(OutDir)"
-
-
-
-
- Use
- SHpch.h
- Level4
- 4251;%(DisableSpecificWarnings)
- _LIB;_GLFW_INCLUDE_NONE;MSDFGEN_USE_CPP11;NOMINMAX;SH_API_EXPORT;_RELEASE;%(PreprocessorDefinitions)
- src;%(AdditionalIncludeDirectories)
- Full
- true
- true
- false
- true
- MultiThreadedDLL
- true
- stdcpp20
-
-
- Windows
- true
- true
- vulkan-1.lib;SDL2.lib;SDL2main.lib;shaderc_shared.lib;shlwapi.lib;assimp-vc142-mt.lib;librttr_core.lib;spdlog.lib;%(AdditionalDependencies)
- libs;$(VULKAN_SDK)\Lib;..\Dependencies\assimp\lib\Debug;..\Dependencies\assimp\lib\Release;..\Dependencies\RTTR\lib;..\Dependencies\SDL\lib;..\Dependencies\spdlog\lib;%(AdditionalLibraryDirectories)
- ..\bin\Release\SHADE_Engine.lib
-
-
- xcopy /s /r /y /q "$(SolutionDir)/Dependencies/spdlog/bin" "$(OutDir)"
-xcopy /r /y /q "$(SolutionDir)/Dependencies/SDL/lib/SDL2.dll" "$(OutDir)"
-xcopy /s /r /y /q "$(SolutionDir)/Dependencies/dotnet/bin" "$(OutDir)"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Create
-
-
-
-
-
-
-
-
-
-
-
-
-
- {88F1A057-74BE-FB62-9DD7-E90A890331F1}
-
-
- {8900D8DD-F5DF-5679-FEF7-E14F6A56BDDA}
-
-
- {38BD587B-248B-4C81-0D1F-BDA7F98B28E6}
-
-
- {2ECAB41A-1A98-A820-032C-1947EF988485}
-
-
- {C0FF640D-2C14-8DBE-F595-301E616989EF}
-
-
-
-
-
-
\ No newline at end of file
diff --git a/SHADE_Engine/SHADE_Engine.vcxproj.filters b/SHADE_Engine/SHADE_Engine.vcxproj.filters
deleted file mode 100644
index 74be0df1..00000000
--- a/SHADE_Engine/SHADE_Engine.vcxproj.filters
+++ /dev/null
@@ -1,877 +0,0 @@
-
-
-
-
- {8EEA3EAC-7A8C-6982-6347-7DD64F88F0D2}
-
-
- {1AB26817-067F-C322-2F98-B1CA1BC4F8B0}
-
-
- {EFD23933-5B34-1741-E4A1-5DF350024E00}
-
-
- {261D0942-92A8-7606-9BB9-F9FA07C4D206}
-
-
- {BEBC9142-2A48-FF06-3359-82FB9F635B07}
-
-
- {07FEB307-F3F6-D259-1C29-B8DE0881B265}
-
-
- {37718753-A387-85E9-ECFE-100B58545671}
-
-
- {EE037863-5A8F-E527-63A0-681CCFAA4128}
-
-
- {078AA1A3-F318-2B6D-9C37-3F6888A53B13}
-
-
- {8C1A20B0-78BC-4A86-6177-5EDA4DB8D1D6}
-
-
- {DBC7D3B0-C769-FE86-B024-12DB9C6585D7}
-
-
- {3A8963B1-262B-8E87-0FE6-A1DBFB2615D8}
-
-
- {80E7870B-ECF0-877C-756C-9E7CE174937C}
-
-
- {8A8E2B37-7646-6D84-DF4D-46E0CB240875}
-
-
- {1653CE33-0220-293F-2B39-17E717655ECD}
-
-
- {92C817CE-7EC1-3620-A7F3-1BA5934B162C}
-
-
- {17C745C0-83DD-4356-CC54-CF7738AA14DE}
-
-
- {51443AC7-3D28-FB1C-A688-F56F928BE59E}
-
-
- {573A6CF2-43C9-F5BB-ECE7-09B7D8550662}
-
-
- {08DBDC43-F4D3-FB95-1D06-E11A095EDBA1}
-
-
- {4AD5CA42-3664-540C-DF82-6807CBF064B2}
-
-
- {FB5EE099-67EA-4D5E-70FB-D052DC05AA5E}
-
-
- {BA26540B-263D-52A1-6FB4-DDC2DB092329}
-
-
- {4B204703-3704-0859-A064-02AC8C67F2DA}
-
-
- {7A02D7B0-E60F-0597-6FF6-0082DB02D14D}
-
-
- {85EFB65D-F107-9E87-BAB4-2D21268C3221}
-
-
- {EBA1D3FF-D75C-C3AB-8014-3CF66CAE0D3C}
-
-
- {1F603FFC-8B22-7386-D4D2-011340D44B64}
-
-
- {8CDBA7C9-F8E8-D5AF-81CF-D19AEDDBA166}
-
-
- {D04C14FB-3C5A-42E1-C540-3ECC314D0E98}
-
-
- {2460C057-1070-6C28-7929-D14665585BC1}
-
-
- {7E76F08B-EA83-1E72-736A-1A5DDF76EA28}
-
-
- {FBD334F8-67EA-328E-B061-BEAF1CB70316}
-
-
- {1DD51CAD-8960-8A71-9271-0D66FE7BE671}
-
-
- {57DAB30C-4369-3DD6-EC87-51D1D8F54D7C}
-
-
- {9C0DAFD9-086F-8CE7-91DC-D299FD3CC3A6}
-
-
- {EF2D07CC-DB26-261E-0459-0BA3F0B0052A}
-
-
- {3AEF06DD-A6D2-151D-AFD5-43591B38DC6D}
-
-
- {245F5AB0-1085-2417-F9CA-A9E2E58F49E3}
-
-
- {03DB39DE-EFBE-FA33-581F-F5864422E5B5}
-
-
- {576DF841-4392-47C2-6CDD-2C52586146E0}
-
-
- {75F29FE5-6102-4CB6-CABB-B0D4B6EA3A4F}
-
-
- {5BAB2A92-478F-EBE7-B0EF-E53A9CF2D569}
-
-
- {B3B14D12-9FC1-F9E2-087B-5E01F4A9E87B}
-
-
- {AFF4887C-9B2B-8A0D-4418-7010302E060F}
-
-
- {EAD6C33D-5697-3F74-1FD2-88F18B518450}
-
-
- {3AB383AD-2681-77B3-0F15-E8D9FB815318}
-
-
- {F1B75745-5D6D-D03A-E661-CA115216C73E}
-
-
- {AC05897C-983C-8A0D-4129-70102D3F060F}
-
-
- {ED6CDF9B-D939-3AA7-0253-284FEE7E6F35}
-
-
- {B3F7140E-1F0C-3DBF-E88D-E01E546139F0}
-
-
- {985A7358-04C5-27CF-4D03-D974B9AC0524}
-
-
- {16CF2D0E-82E3-55BF-4B65-F91EB73852F0}
-
-
-
-
- Common
-
-
- ECS_Base\Components
-
-
- ECS_Base\Components
-
-
- ECS_Base\Entity
-
-
- ECS_Base\Events
-
-
- ECS_Base\Events
-
-
- ECS_Base\General
-
-
- ECS_Base\General
-
-
- ECS_Base\General
-
-
- ECS_Base\General
-
-
- ECS_Base\General
-
-
- ECS_Base\Managers
-
-
- ECS_Base\Managers
-
-
- ECS_Base\Managers
-
-
- ECS_Base
-
-
- ECS_Base\System
-
-
- ECS_Base\System
-
-
- ECS_Base\System
-
-
- ECS_Base\System
-
-
- ECS_Base\UnitTesting
-
-
- ECS_Base\UnitTesting
-
-
- ECS_Base\UnitTesting
-
-
- Editor
-
-
- Engine
-
-
- Events
-
-
- Events
-
-
- Events
-
-
- Events
-
-
- FRC
-
-
- Filesystem
-
-
- Graphics\Buffers
-
-
- Graphics\Commands
-
-
- Graphics\Commands
-
-
- Graphics\Commands
-
-
- Graphics\Debugging
-
-
- Graphics\Debugging
-
-
- Graphics\Debugging
-
-
- Graphics\Descriptors
-
-
- Graphics\Descriptors
-
-
- Graphics\Descriptors
-
-
- Graphics\Descriptors
-
-
- Graphics\Descriptors
-
-
- Graphics\Descriptors
-
-
- Graphics\Devices
-
-
- Graphics\Devices
-
-
- Graphics\Devices
-
-
- Graphics\Framebuffer
-
-
- Graphics\Images
-
-
- Graphics\Images
-
-
- Graphics\Images
-
-
- Graphics\Images
-
-
- Graphics\Instance
-
-
- Graphics\MiddleEnd\Batching
-
-
- Graphics\MiddleEnd\Batching
-
-
- Graphics\MiddleEnd\Batching
-
-
- Graphics\MiddleEnd\GlobalData
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Meshes
-
-
- Graphics\MiddleEnd\Meshes
-
-
- Graphics\MiddleEnd\PerFrame
-
-
- Graphics\MiddleEnd\PerFrame
-
-
- Graphics\MiddleEnd\Pipeline
-
-
- Graphics\MiddleEnd\Shaders
-
-
- Graphics\MiddleEnd\Shaders
-
-
- Graphics\MiddleEnd\Shaders
-
-
- Graphics\MiddleEnd\Textures
-
-
- Graphics\Pipeline
-
-
- Graphics\Pipeline
-
-
- Graphics\Pipeline
-
-
- Graphics\Pipeline
-
-
- Graphics\Pipeline
-
-
- Graphics\Pipeline
-
-
- Graphics\Queues
-
-
- Graphics\RenderGraph
-
-
- Graphics\Renderpass
-
-
- Graphics\Renderpass
-
-
- Graphics\Renderpass
-
-
- Graphics\Renderpass
-
-
- Graphics\Renderpass
-
-
- Graphics
-
-
- Graphics
-
-
- Graphics
-
-
- Graphics\Shaders\BlockInterface
-
-
- Graphics\Shaders
-
-
- Graphics\Shaders
-
-
- Graphics\Shaders\spirv-reflect
-
-
- Graphics\Swapchain
-
-
- Graphics\Swapchain
-
-
- Graphics\Synchronization
-
-
- Graphics\Synchronization
-
-
- Graphics\VertexDescriptors
-
-
- Graphics\Windowing
-
-
- Graphics\Windowing
-
-
- Graphics\Windowing\Surface
-
-
- Math\Geometry
-
-
- Math\Geometry
-
-
- Math
-
-
- Math
-
-
- Math
-
-
- Math
-
-
- Math
-
-
- Math\Transform
-
-
- Math\Transform
-
-
- Math\Transform
-
-
- Math\Vector
-
-
- Math\Vector
-
-
- Math\Vector
-
-
- Meta
-
-
- Resource
-
-
- Resource
-
-
- Resource
-
-
- Resource
-
-
- Resource
-
-
- Resource
-
-
-
-
-
- Scene
-
-
- Scene
-
-
- Scene
-
-
- Scripting
-
-
- Scripting
-
-
- Scripting
-
-
- Tools
-
-
- Tools
-
-
- Tools
-
-
- Tools
-
-
- Tools
-
-
- Tools
-
-
- Tools
-
-
- Tools
-
-
-
-
- ECS_Base\Components
-
-
- ECS_Base\Components
-
-
- ECS_Base\Entity
-
-
- ECS_Base\Managers
-
-
- ECS_Base\Managers
-
-
- ECS_Base\Managers
-
-
- ECS_Base\System
-
-
- ECS_Base\System
-
-
- ECS_Base\UnitTesting
-
-
- Editor
-
-
- Engine
-
-
- FRC
-
-
- Filesystem
-
-
- Graphics\Buffers
-
-
- Graphics\Commands
-
-
- Graphics\Commands
-
-
- Graphics\Debugging
-
-
- Graphics\Debugging
-
-
- Graphics\Debugging
-
-
- Graphics\Descriptors
-
-
- Graphics\Descriptors
-
-
- Graphics\Descriptors
-
-
- Graphics\Descriptors
-
-
- Graphics\Descriptors
-
-
- Graphics\Descriptors
-
-
- Graphics\Devices
-
-
- Graphics\Devices
-
-
- Graphics\Devices
-
-
- Graphics\Framebuffer
-
-
- Graphics\Images
-
-
- Graphics\Images
-
-
- Graphics\Images
-
-
- Graphics\Instance
-
-
- Graphics\MiddleEnd\Batching
-
-
- Graphics\MiddleEnd\Batching
-
-
- Graphics\MiddleEnd\Batching
-
-
- Graphics\MiddleEnd\GlobalData
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Interface
-
-
- Graphics\MiddleEnd\Meshes
-
-
- Graphics\MiddleEnd\PerFrame
-
-
- Graphics\MiddleEnd\PerFrame
-
-
- Graphics\MiddleEnd\Pipeline
-
-
- Graphics\MiddleEnd\Shaders
-
-
- Graphics\MiddleEnd\Shaders
-
-
- Graphics\MiddleEnd\Textures
-
-
- Graphics\Pipeline
-
-
- Graphics\Pipeline
-
-
- Graphics\Pipeline
-
-
- Graphics\Pipeline
-
-
- Graphics\Queues
-
-
- Graphics\RenderGraph
-
-
- Graphics\Renderpass
-
-
- Graphics\Renderpass
-
-
- Graphics\Renderpass
-
-
- Graphics
-
-
- Graphics
-
-
- Graphics\Shaders\BlockInterface
-
-
- Graphics\Shaders
-
-
- Graphics\Shaders
-
-
- Graphics\Shaders\spirv-reflect
-
-
- Graphics\Swapchain
-
-
- Graphics\Synchronization
-
-
- Graphics\Synchronization
-
-
- Graphics\VertexDescriptors
-
-
- Graphics\Windowing
-
-
- Graphics\Windowing
-
-
- Graphics\Windowing\Surface
-
-
- Math\Geometry
-
-
- Math\Geometry
-
-
- Math
-
-
- Math
-
-
- Math
-
-
- Math\Transform
-
-
- Math\Transform
-
-
- Math\Transform
-
-
- Math\Vector
-
-
- Math\Vector
-
-
- Math\Vector
-
-
- Resource
-
-
-
- Scene
-
-
- Scene
-
-
- Scripting
-
-
- Scripting
-
-
- Tools
-
-
- Tools
-
-
- Tools
-
-
- Tools
-
-
- Tools
-
-
-
\ No newline at end of file
diff --git a/SHADE_Engine/premake5.lua b/SHADE_Engine/premake5.lua
index 74f19f96..84acd8fa 100644
--- a/SHADE_Engine/premake5.lua
+++ b/SHADE_Engine/premake5.lua
@@ -25,22 +25,22 @@ project "SHADE_Engine"
externalincludedirs
{
- "%{IncludeDir.assimp}/include",
+ "%{IncludeDir.assimp}\\include",
"%{IncludeDir.imgui}",
"%{IncludeDir.imguizmo}",
"%{IncludeDir.imnodes}",
"%{IncludeDir.msdf_atlas_gen}",
"%{IncludeDir.msdfgen}",
- "%{IncludeDir.spdlog}/include",
+ "%{IncludeDir.spdlog}\\include",
"%{IncludeDir.tracy}",
- "%{IncludeDir.VMA}/include",
+ "%{IncludeDir.VMA}\\include",
"%{IncludeDir.yamlcpp}",
- "%{IncludeDir.SDL}/include",
- "%{IncludeDir.RTTR}/include",
- "%{IncludeDir.reactphysics3d}/include",
- "%{IncludeDir.VULKAN}/include",
- "%{IncludeDir.VULKAN}/Source/SPIRV-Reflect",
- "%{IncludeDir.dotnet}/include",
+ "%{IncludeDir.SDL}\\include",
+ "%{IncludeDir.RTTR}\\include",
+ "%{IncludeDir.reactphysics3d}\\include",
+ "%{IncludeDir.VULKAN}\\include",
+ "%{IncludeDir.VULKAN}\\Source\\SPIRV-Reflect",
+ "%{IncludeDir.dotnet}\\include",
}
externalwarnings "Off"
@@ -100,9 +100,9 @@ project "SHADE_Engine"
postbuildcommands
{
- "xcopy /s /r /y /q \"%{IncludeDir.spdlog}/bin\" \"$(OutDir)\"",
- "xcopy /r /y /q \"%{IncludeDir.SDL}/lib/SDL2.dll\" \"$(OutDir)\"",
- "xcopy /s /r /y /q \"%{IncludeDir.dotnet}/bin\" \"$(OutDir)\""
+ "xcopy /s /r /y /q \"%{IncludeDir.spdlog}\\bin\" \"$(OutDir)\"",
+ "xcopy /r /y /q \"%{IncludeDir.SDL}\\lib\\SDL2.dll\" \"$(OutDir)\"",
+ "xcopy /s /r /y /q \"%{IncludeDir.dotnet}\\bin\" \"$(OutDir)\""
}
warnings 'Extra'
diff --git a/SHADE_Engine/src/Events/SHEventReceiver.h b/SHADE_Engine/src/Events/SHEventReceiver.h
index e6e5e757..e2edd4dc 100644
--- a/SHADE_Engine/src/Events/SHEventReceiver.h
+++ b/SHADE_Engine/src/Events/SHEventReceiver.h
@@ -19,7 +19,7 @@ namespace SHADE
SHEventHandle(T::*callback)(SHEventPtr);
public:
- SHEventReceiverSpec(T* obj, void(T::* cb)(SHEventPtr))
+ SHEventReceiverSpec(T* obj, SHEventHandle(T::* cb)(SHEventPtr))
:SHEventReceiver(), object{ obj }, callback{ cb }
{
diff --git a/SHADE_Engine/src/Graphics/Devices/SHVkPhysicalDeviceLibrary.cpp b/SHADE_Engine/src/Graphics/Devices/SHVkPhysicalDeviceLibrary.cpp
index d815fb7e..3cf0a8e6 100644
--- a/SHADE_Engine/src/Graphics/Devices/SHVkPhysicalDeviceLibrary.cpp
+++ b/SHADE_Engine/src/Graphics/Devices/SHVkPhysicalDeviceLibrary.cpp
@@ -1,4 +1,4 @@
-#include "SHPch.h"
+#include "SHpch.h"
#include
#include
#include "SHVkPhysicalDeviceLibrary.h"
@@ -180,10 +180,13 @@ namespace SHADE
return;
}
+ #ifdef DEBUG
SHLOG_TRACE("Successfully queried Physical Devices:");
for (auto const& device : physicalDevices)
{
SHLOG_TRACE(std::string_view (std::string("\t-") + GetDeviceTypeName(device.getProperties().deviceType) + device.getProperties().deviceName.operator std::string()));
}
+ #endif
+
}
}
diff --git a/SHADE_Engine/src/Math/Transform/SHTransformSystem.cpp b/SHADE_Engine/src/Math/Transform/SHTransformSystem.cpp
index 879c2d34..adbdf746 100644
--- a/SHADE_Engine/src/Math/Transform/SHTransformSystem.cpp
+++ b/SHADE_Engine/src/Math/Transform/SHTransformSystem.cpp
@@ -21,12 +21,18 @@
namespace SHADE
{
+ /*-----------------------------------------------------------------------------------*/
+ /* Static Data Member Definitions */
+ /*-----------------------------------------------------------------------------------*/
+
+ //SHTransformSystem::TransformUpdateRoutine SHTransformSystem::UpdateRoutine;
+
/*-----------------------------------------------------------------------------------*/
/* Constructors & Destructor Definitions */
/*-----------------------------------------------------------------------------------*/
- SHTransformSystem::SHTransformSystem()
- : SHSystemRoutine { "Transform Routine", false }
+ SHTransformSystem::TransformUpdateRoutine::TransformUpdateRoutine()
+ : SHSystemRoutine { "Transform Update", false }
{}
@@ -34,7 +40,7 @@ namespace SHADE
/* Public Function Member Definitions */
/*-----------------------------------------------------------------------------------*/
- void SHTransformSystem::Execute(double dt) noexcept
+ void SHTransformSystem::TransformUpdateRoutine::Execute(double) noexcept
{
// Get the current scene graph to traverse and update
const auto& SCENE_GRAPH = SHSceneManager::GetCurrentSceneGraph();
@@ -53,7 +59,7 @@ namespace SHADE
for (const auto* child : node->GetChildren())
{
// Active states of entities should sync with scene nodes
- const bool IS_NODE_ACTIVE = child->isActive;
+ const bool IS_NODE_ACTIVE = child->IsActive();
#ifdef _DEBUG
const bool IS_ENTITY_ACTIVE = SHEntityManager::GetEntityByID(child->GetEntityID())->GetActive();
diff --git a/SHADE_Engine/src/Math/Transform/SHTransformSystem.h b/SHADE_Engine/src/Math/Transform/SHTransformSystem.h
index 5eebd292..c57cbdbd 100644
--- a/SHADE_Engine/src/Math/Transform/SHTransformSystem.h
+++ b/SHADE_Engine/src/Math/Transform/SHTransformSystem.h
@@ -21,19 +21,18 @@ namespace SHADE
/* Type Definitions */
/*-----------------------------------------------------------------------------------*/
- class SH_API SHTransformSystem : public SHSystemRoutine
+ class SH_API SHTransformSystem : public SHSystem
{
public:
-
/*---------------------------------------------------------------------------------*/
/* Constructors & Destructor */
/*---------------------------------------------------------------------------------*/
- SHTransformSystem ();
- ~SHTransformSystem () = default;
+ SHTransformSystem () = default;
+ ~SHTransformSystem () = default;
- SHTransformSystem (const SHTransformSystem&) = delete;
- SHTransformSystem (SHTransformSystem&&) = delete;
+ SHTransformSystem (const SHTransformSystem&) = delete;
+ SHTransformSystem (SHTransformSystem&&) = delete;
/*---------------------------------------------------------------------------------*/
/* Operator Overloads */
@@ -43,10 +42,37 @@ namespace SHADE
SHTransformSystem& operator= (SHTransformSystem&&) = delete;
/*---------------------------------------------------------------------------------*/
- /* Function Members */
+ /* System Routines */
/*---------------------------------------------------------------------------------*/
- void Execute(double dt) noexcept override;
+ class TransformUpdateRoutine : public SHSystemRoutine
+ {
+ public:
+ /*-------------------------------------------------------------------------------*/
+ /* Constructors & Destructor */
+ /*-------------------------------------------------------------------------------*/
+
+ TransformUpdateRoutine ();
+ ~TransformUpdateRoutine () = default;
+
+ TransformUpdateRoutine (const TransformUpdateRoutine&) = delete;
+ TransformUpdateRoutine (TransformUpdateRoutine&&) = delete;
+
+ /*-------------------------------------------------------------------------------*/
+ /* Operator Overloads */
+ /*-------------------------------------------------------------------------------*/
+
+ TransformUpdateRoutine& operator= (const TransformUpdateRoutine&) = delete;
+ TransformUpdateRoutine& operator= (TransformUpdateRoutine&&) = delete;
+
+ /*-------------------------------------------------------------------------------*/
+ /* Function Members */
+ /*-------------------------------------------------------------------------------*/
+
+ void Execute(double dt) noexcept override;
+ };
+
+ //static TransformUpdateRoutine UpdateRoutine;
private:
/*---------------------------------------------------------------------------------*/
diff --git a/SHADE_Engine/src/Scene/SHSceneGraph.cpp b/SHADE_Engine/src/Scene/SHSceneGraph.cpp
index 82e4fd7e..84c7f1c5 100644
--- a/SHADE_Engine/src/Scene/SHSceneGraph.cpp
+++ b/SHADE_Engine/src/Scene/SHSceneGraph.cpp
@@ -25,14 +25,14 @@ namespace SHADE
/*-----------------------------------------------------------------------------------*/
SHSceneNode::SHSceneNode(EntityID eid, SHSceneNode* parent) noexcept
- : isActive { true }
+ : active { true }
, entityID { eid }
, parent { parent }
{}
SHSceneNode::SHSceneNode(const SHSceneNode& rhs) noexcept
- : isActive { rhs.isActive }
+ : active { rhs.active }
, entityID { rhs.entityID }
, parent { rhs.parent }
{
@@ -40,7 +40,7 @@ namespace SHADE
}
SHSceneNode::SHSceneNode(SHSceneNode&& rhs) noexcept
- : isActive { rhs.isActive }
+ : active { rhs.active }
, entityID { rhs.entityID }
, parent { rhs.parent }
{
@@ -52,9 +52,9 @@ namespace SHADE
if (this == &rhs)
return *this;
- isActive = rhs.isActive;
- entityID = rhs.entityID;
- parent = rhs.parent;
+ active = rhs.active;
+ entityID = rhs.entityID;
+ parent = rhs.parent;
children.clear();
std::ranges::copy(rhs.children.begin(), rhs.children.end(), std::back_inserter(children));
@@ -64,9 +64,9 @@ namespace SHADE
SHSceneNode& SHSceneNode::operator=(SHSceneNode&& rhs) noexcept
{
- isActive = rhs.isActive;
- entityID = rhs.entityID;
- parent = rhs.parent;
+ active = rhs.active;
+ entityID = rhs.entityID;
+ parent = rhs.parent;
children.clear();
std::ranges::copy(rhs.children.begin(), rhs.children.end(), std::back_inserter(children));
@@ -104,6 +104,11 @@ namespace SHADE
/* Getter Function Definitions */
/*-----------------------------------------------------------------------------------*/
+ bool SHSceneNode::IsActive() const noexcept
+ {
+ return active;
+ }
+
EntityID SHSceneNode::GetEntityID() const noexcept
{
return entityID;
@@ -154,7 +159,7 @@ namespace SHADE
if (root != nullptr)
return root;
- SHLOG_WARNING("Scene has no root object!")
+ SHLOG_ERROR("Scene has no root object!")
return nullptr;
}
@@ -171,7 +176,7 @@ namespace SHADE
const auto NODE_ITER = entityNodeMap.find(entityID);
if (NODE_ITER == entityNodeMap.end())
{
- SHLOG_WARNING("Entity {} cannot be found in the scene! Unable to Get Scene node!", entityID)
+ SHLOG_ERROR("Entity {} cannot be found in the scene! Unable to Get Scene node!", entityID)
return nullptr;
}
////////////////////////////////////////
@@ -192,7 +197,7 @@ namespace SHADE
const auto NODE_ITER = entityNodeMap.find(entityID);
if (NODE_ITER == entityNodeMap.end())
{
- SHLOG_WARNING("Entity {} cannot be found in the scene! Unable to get Parent node!", entityID)
+ SHLOG_ERROR("Entity {} cannot be found in the scene! Unable to get Parent node!", entityID)
return nullptr;
}
////////////////////////////////////////
@@ -213,7 +218,7 @@ namespace SHADE
const auto NODE_ITER = entityNodeMap.find(entityID);
if (NODE_ITER == entityNodeMap.end())
{
- SHLOG_WARNING("Entity {} cannot be found in the scene!", entityID)
+ SHLOG_ERROR("Entity {} cannot be found in the scene!", entityID)
return nullptr;
}
@@ -248,7 +253,7 @@ namespace SHADE
const auto NODE_ITER = entityNodeMap.find(entityID);
if (NODE_ITER == entityNodeMap.end())
{
- SHLOG_WARNING("Entity {} cannot be found in the scene!", entityID)
+ SHLOG_ERROR("Entity {} cannot be found in the scene!", entityID)
return nullptr;
}
////////////////////////////////////////
@@ -269,7 +274,7 @@ namespace SHADE
const auto NODE_ITER = entityNodeMap.find(entityID);
if (NODE_ITER == entityNodeMap.end())
{
- SHLOG_WARNING("Entity {} cannot be found in the scene!", entityID)
+ SHLOG_ERROR("Entity {} cannot be found in the scene!", entityID)
return root->GetChildren();
}
////////////////////////////////////////
@@ -277,6 +282,27 @@ namespace SHADE
return NODE_ITER->second->GetChildren();
}
+ bool SHSceneGraph::IsActiveInHierarchy(EntityID entityID) const noexcept
+ {
+ ////////////////////////////////////////
+ // Error handling
+ if (!SHEntityManager::IsValidEID(entityID))
+ {
+ SHLOG_ERROR("Entity {} is invalid!", entityID)
+ return false;
+ }
+
+ const auto NODE_ITER = entityNodeMap.find(entityID);
+ if (NODE_ITER == entityNodeMap.end())
+ {
+ SHLOG_ERROR("Entity {} cannot be found in the scene!", entityID)
+ return false;
+ }
+ ////////////////////////////////////////
+
+ return NODE_ITER->second->IsActive();
+ }
+
/*-----------------------------------------------------------------------------------*/
/* Setter Function Definitions */
/*-----------------------------------------------------------------------------------*/
@@ -289,7 +315,7 @@ namespace SHADE
}
// Handle self assignment
- if (parentNode == parent)
+ if (parent && parentNode->entityID == parent->entityID)
return;
if (parent)
@@ -300,6 +326,16 @@ namespace SHADE
parent->AddChild(this);
}
+ void SHSceneNode::SetActive(bool newActiveState) noexcept
+ {
+ active = newActiveState;
+
+ for (auto* child : children)
+ {
+ SetActive(newActiveState);
+ }
+ }
+
void SHSceneGraph::SetParent(EntityID entityID, SHSceneNode* parent) const noexcept
{
////////////////////////////////////////
@@ -318,6 +354,9 @@ namespace SHADE
}
////////////////////////////////////////
+ if (parent == nullptr)
+ parent = root;
+
NODE_ITER->second->SetParent(parent);
}
@@ -340,14 +379,14 @@ namespace SHADE
auto NODE_ITER = entityNodeMap.find(entityID);
if (NODE_ITER == entityNodeMap.end())
{
- SHLOG_WARNING("Entity {} cannot be found in the scene! Unable to set parent!", entityID)
+ SHLOG_ERROR("Entity {} cannot be found in the scene! Unable to set parent!", entityID)
return;
}
auto PARENT_ITER = entityNodeMap.find(parent);
if (PARENT_ITER == entityNodeMap.end())
{
- SHLOG_WARNING("Entity {} cannot be found in the scene! Unable to parent to Entity {}", parent, entityID)
+ SHLOG_ERROR("Entity {} cannot be found in the scene! Unable to parent to Entity {}", parent, entityID)
return;
}
////////////////////////////////////////
@@ -476,7 +515,7 @@ namespace SHADE
auto NODE_ITER = entityNodeMap.find(entityID);
if (NODE_ITER == entityNodeMap.end())
{
- SHLOG_WARNING("Entity {} does not exist in the scene!", entityID)
+ SHLOG_ERROR("Entity {} does not exist in the scene!", entityID)
return false;
}
diff --git a/SHADE_Engine/src/Scene/SHSceneGraph.h b/SHADE_Engine/src/Scene/SHSceneGraph.h
index bdb8f52c..39afbb31 100644
--- a/SHADE_Engine/src/Scene/SHSceneGraph.h
+++ b/SHADE_Engine/src/Scene/SHSceneGraph.h
@@ -38,12 +38,6 @@ namespace SHADE
friend class SHSceneGraph;
public:
- /*---------------------------------------------------------------------------------*/
- /* Data Members */
- /*---------------------------------------------------------------------------------*/
-
- bool isActive;
-
/*---------------------------------------------------------------------------------*/
/* Constructors & Destructor */
/*---------------------------------------------------------------------------------*/
@@ -60,6 +54,7 @@ namespace SHADE
/* Getter Functions */
/*---------------------------------------------------------------------------------*/
+ [[nodiscard]] bool IsActive () const noexcept;
[[nodiscard]] EntityID GetEntityID () const noexcept;
[[nodiscard]] SHSceneNode* GetParent () const noexcept;
[[nodiscard]] const std::vector& GetChildren () const noexcept;
@@ -70,7 +65,8 @@ namespace SHADE
/* Setter Functions */
/*---------------------------------------------------------------------------------*/
- void SetParent (SHSceneNode* parentNode) noexcept;
+ void SetParent (SHSceneNode* parentNode) noexcept;
+ void SetActive (bool newActiveState) noexcept;
/*---------------------------------------------------------------------------------*/
/* Function Members */
@@ -88,6 +84,7 @@ namespace SHADE
/* Data Members */
/*---------------------------------------------------------------------------------*/
+ bool active;
EntityID entityID;
SHSceneNode* parent;
std::vector children;
@@ -121,12 +118,14 @@ namespace SHADE
/* Getter Functions */
/*---------------------------------------------------------------------------------*/
- [[nodiscard]] const SHSceneNode* GetRoot () const noexcept;
- [[nodiscard]] SHSceneNode* GetNode (EntityID entityID) const noexcept;
- [[nodiscard]] SHSceneNode* GetParent (EntityID entityID) const noexcept;
- [[nodiscard]] SHSceneNode* GetChild (EntityID entityID, SHSceneNode* childNode) const noexcept;
- [[nodiscard]] SHSceneNode* GetChild (EntityID entityID, EntityID childEntityID) const noexcept;
- [[nodiscard]] const std::vector& GetChildren (EntityID entityID) const noexcept;
+ [[nodiscard]] const SHSceneNode* GetRoot () const noexcept;
+ [[nodiscard]] SHSceneNode* GetNode (EntityID entityID) const noexcept;
+ [[nodiscard]] SHSceneNode* GetParent (EntityID entityID) const noexcept;
+ [[nodiscard]] SHSceneNode* GetChild (EntityID entityID, SHSceneNode* childNode) const noexcept;
+ [[nodiscard]] SHSceneNode* GetChild (EntityID entityID, EntityID childEntityID) const noexcept;
+ [[nodiscard]] const std::vector& GetChildren (EntityID entityID) const noexcept;
+
+ [[nodiscard]] bool IsActiveInHierarchy (EntityID entityID) const noexcept;
/*---------------------------------------------------------------------------------*/
/* Setter Functions */
diff --git a/SHADE_Engine/src/Scene/SHSceneManager.h b/SHADE_Engine/src/Scene/SHSceneManager.h
index 6ce90042..83ebab0f 100644
--- a/SHADE_Engine/src/Scene/SHSceneManager.h
+++ b/SHADE_Engine/src/Scene/SHSceneManager.h
@@ -16,7 +16,6 @@
#include "SHScene.h"
#include
-#include "SH_API.h"
//Project Headers
#include "SH_API.h"
diff --git a/SHADE_Engine/src/Scripting/SHScriptEngine.cpp b/SHADE_Engine/src/Scripting/SHScriptEngine.cpp
index 09f6ecec..fada5b70 100644
--- a/SHADE_Engine/src/Scripting/SHScriptEngine.cpp
+++ b/SHADE_Engine/src/Scripting/SHScriptEngine.cpp
@@ -16,39 +16,27 @@ of DigiPen Institute of Technology is prohibited.
// Standard Library
#include // std::fstream
#include // std::filesystem::canonical, std::filesystem::remove
+#include // std::shared_ptr
// Project Headers
#include "Tools/SHLogger.h"
#include "Tools/SHStringUtils.h"
+#include "ECS_Base/Events/SHEntityDestroyedEvent.h"
+#include "Events/SHEvent.h"
+#include "Events/SHEventReceiver.h"
+#include "Events/SHEventManager.hpp"
namespace SHADE
{
- /*--------------------------------------------------------------------------------*/
- /* Static Definitions */
- /*--------------------------------------------------------------------------------*/
+ /*-----------------------------------------------------------------------------------*/
+ /* Static Definitions */
+ /*----------------------------------------------------------------------------------*/
const std::string SHScriptEngine::DEFAULT_CSHARP_NAMESPACE = std::string("SHADE");
- SHDotNetRuntime SHScriptEngine::dotNet { false };
- SHScriptEngine::CsFuncPtr SHScriptEngine::csEngineInit = nullptr;
- SHScriptEngine::CsFuncPtr SHScriptEngine::csEngineLoadScripts = nullptr;
- SHScriptEngine::CsFuncPtr SHScriptEngine::csEngineUnloadScripts = nullptr;
- SHScriptEngine::CsFuncPtr SHScriptEngine::csEngineReloadScripts = nullptr;
- SHScriptEngine::CsFuncPtr SHScriptEngine::csEngineExit = nullptr;
- SHScriptEngine::CsFuncPtr SHScriptEngine::csScriptsFrameSetUp = nullptr;
- SHScriptEngine::CsFuncPtr SHScriptEngine::csScriptsExecuteFixedUpdate = nullptr;
- SHScriptEngine::CsFuncPtr SHScriptEngine::csScriptsExecuteUpdate = nullptr;
- SHScriptEngine::CsFuncPtr SHScriptEngine::csScriptsExecuteLateUpdate = nullptr;
- SHScriptEngine::CsFuncPtr SHScriptEngine::csScriptsFrameCleanUp = nullptr;
- SHScriptEngine::CsScriptManipFuncPtr SHScriptEngine::csScriptsAdd = nullptr;
- SHScriptEngine::CsScriptBasicFuncPtr SHScriptEngine::csScriptsRemoveAll = nullptr;
- SHScriptEngine::CsScriptOptionalFuncPtr SHScriptEngine::csScriptsRemoveAllImmediately = nullptr;
- SHScriptEngine::CsScriptSerialiseFuncPtr SHScriptEngine::csScriptsSerialise = nullptr;
- SHScriptEngine::CsScriptDeserialiseFuncPtr SHScriptEngine::csScriptDeserialise = nullptr;
- SHScriptEngine::CsScriptSerialiseYamlFuncPtr SHScriptEngine::csScriptsSerialiseYaml = nullptr;
- SHScriptEngine::CsScriptSerialiseYamlFuncPtr SHScriptEngine::csScriptDeserialiseYaml = nullptr;
- SHScriptEngine::CsScriptEditorFuncPtr SHScriptEngine::csEditorRenderScripts = nullptr;
+ const std::string SHScriptEngine::CSPROJ_DIR = "..\\..\\TempScriptsFolder";
+ const std::string SHScriptEngine::CSPROJ_PATH = std::string(CSPROJ_DIR) + "\\SHADE_Scripting.csproj";
- /*---------------------------------------------------------------------------------*/
- /* Lifecycle Functions */
- /*---------------------------------------------------------------------------------*/
+ /*-----------------------------------------------------------------------------------*/
+ /* Lifecycle Functions */
+ /*-----------------------------------------------------------------------------------*/
void SHScriptEngine::Init()
{
// Do not allow initialization if already initialised
@@ -71,15 +59,9 @@ namespace SHADE
// Initialise the CSharp Engine
csEngineInit();
-
- // Link events
- // - Entity Destruction
- /*onEntityDestroy = [this](const SHEntity& e)
- {
- csScriptsRemoveAll(e.GetEID());
- csGOLibNotifyDestroyEntity(e.GetEID());
- };
- ECS::OnEntityDestroy += onEntityDestroy;*/
+
+ // Register entity creation events
+ registerEvents();
}
void SHScriptEngine::UnloadScriptAssembly()
{
@@ -118,9 +100,9 @@ namespace SHADE
dotNet.Exit();
}
- /*---------------------------------------------------------------------------------*/
- /* Script Manipulation Functions */
- /*---------------------------------------------------------------------------------*/
+ /*-----------------------------------------------------------------------------------*/
+ /* Script Manipulation Functions */
+ /*-----------------------------------------------------------------------------------*/
bool SHScriptEngine::AddScript(const SHEntity& entity, const std::string_view& scriptName)
{
return csScriptsAdd(entity.GetEID(), scriptName.data());
@@ -137,7 +119,7 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
/* Script Serialisation Functions */
/*---------------------------------------------------------------------------------*/
- std::string SHScriptEngine::SerialiseScripts(const SHEntity& entity)
+ std::string SHScriptEngine::SerialiseScripts(const SHEntity& entity) const
{
// Create buffer needed to store serialised script data
constexpr int BUFFER_SIZE = 10240;
@@ -159,41 +141,40 @@ namespace SHADE
return result;
}
- /*---------------------------------------------------------------------------------*/
- /* Script Serialisation Functions */
- /*---------------------------------------------------------------------------------*/
- void SHScriptEngine::DeserialiseScript(const SHEntity& entity, const std::string& yaml)
+ /*-----------------------------------------------------------------------------------*/
+ /* Script Serialisation Functions */
+ /*-----------------------------------------------------------------------------------*/
+ void SHScriptEngine::DeserialiseScript(const SHEntity& entity, const std::string& yaml) const
{
csScriptDeserialise(entity.GetEID(), yaml.c_str());
}
- /*---------------------------------------------------------------------------------*/
- /* Script Editor Functions */
- /*---------------------------------------------------------------------------------*/
- void SHScriptEngine::RenderScriptsInInspector(const SHEntity& entity)
+ /*-----------------------------------------------------------------------------------*/
+ /* Script Editor Functions */
+ /*-----------------------------------------------------------------------------------*/
+ void SHScriptEngine::RenderScriptsInInspector(const SHEntity& entity) const
{
csEditorRenderScripts(entity.GetEID());
}
- /*---------------------------------------------------------------------------------*/
- /* Static Utility Functions */
- /*---------------------------------------------------------------------------------*/
- bool SHScriptEngine::BuildScriptAssembly(bool debug)
+ /*-----------------------------------------------------------------------------------*/
+ /* Static Utility Functions */
+ /*-----------------------------------------------------------------------------------*/
+ bool SHScriptEngine::BuildScriptAssembly(bool debug) const
{
- constexpr std::string_view BUILD_LOG_PATH = "../Build.log";
+ static const std::string BUILD_LOG_PATH = "../Build.log";
// Generate csproj file if it doesn't exist
- static const std::filesystem::path CSPROJ_PATH = "../SHADE_Scripting.csproj";
if (!std::filesystem::exists(CSPROJ_PATH))
{
GenerateScriptsCsProjFile(CSPROJ_PATH);
}
// Prepare directory (delete useless files)
- deleteFolder("net5.0");
- deleteFolder("ref");
- deleteFolder("../SHADE_Scripting");
- deleteFolder("../obj");
+ deleteFolder(CSPROJ_DIR + "\\net5.0");
+ deleteFolder(CSPROJ_DIR + "\\ref");
+ deleteFolder(CSPROJ_DIR + "\\obj");
+ deleteFolder(CSPROJ_DIR + "\\bin");
// Attempt to build the assembly
std::ostringstream oss;
@@ -203,7 +184,7 @@ namespace SHADE
const bool BUILD_SUCCESS = execProcess
(
L"C:\\Windows\\system32\\cmd.exe",
- L"/K \"dotnet build \"../SHADE_Scripting.csproj\" -c Debug -o \"./tmp/\" -fl -flp:LogFile=build.log;Verbosity=quiet & exit\""
+ L"/K \"" + generateBuildCommand(debug) + L" & exit\""
) == 0;
if (BUILD_SUCCESS)
{
@@ -221,6 +202,7 @@ namespace SHADE
// Clean up built files
deleteFolder("./tmp");
+ deleteFolder(CSPROJ_DIR + "\\obj");
// Read the build log and output to the console
dumpBuildLog(BUILD_LOG_PATH);
@@ -228,9 +210,9 @@ namespace SHADE
deleteFile(BUILD_LOG_PATH);
return BUILD_SUCCESS;
- }
+ }
- void SHScriptEngine::GenerateScriptsCsProjFile(const std::filesystem::path& path)
+ void SHScriptEngine::GenerateScriptsCsProjFile(const std::filesystem::path& path) const
{
// Sample
static std::string_view FILE_CONTENTS =
@@ -241,11 +223,11 @@ namespace SHADE
Release;Debug\n\
\n\
\n\
- .\\bin_Release-x64\n\
+ .\\bin\\Release\n\
x64\n\
\n\
\n\
- .\\bin_Debug-x64\n\
+ .\\bin\\Debug\n\
x64\n\
DEBUG;TRACE\n\
false\n\
@@ -264,7 +246,8 @@ namespace SHADE
\n\
\n\
\n\
- .\\bin\\SHADE_Managed.dll\n\
+ ..\\bin\\Debug\\SHADE_Managed.dll\
+ ..\\bin\\Release\\SHADE_Managed.dll\
\n\
\n\
";
@@ -273,17 +256,27 @@ namespace SHADE
std::ofstream file(path);
if (!file.is_open())
throw std::runtime_error("Unable to create CsProj file!");
-
+
// Fill the file
file << FILE_CONTENTS;
-
+
// Close
file.close();
- }
+ }
- /*---------------------------------------------------------------------------------*/
- /* Helper Functions */
- /*---------------------------------------------------------------------------------*/
+ /*-----------------------------------------------------------------------------------*/
+ /* Event Handler Functions */
+ /*-----------------------------------------------------------------------------------*/
+ SHEventHandle SHScriptEngine::onEntityDestroyed(SHEventPtr eventPtr)
+ {
+ auto eventData = reinterpret_cast*>(eventPtr.get());
+ csScriptsRemoveAll(eventData->data->eid);
+ return eventData->handle;
+ }
+
+ /*-----------------------------------------------------------------------------------*/
+ /* Helper Functions */
+ /*-----------------------------------------------------------------------------------*/
void SHScriptEngine::loadFunctions()
{
std::ostringstream oss;
@@ -401,6 +394,17 @@ namespace SHADE
);*/
}
+ void SHScriptEngine::registerEvents()
+ {
+ // Register for entity destroyed event
+ std::shared_ptr> destroyedEventReceiver
+ {
+ std::make_shared>(this, &SHScriptEngine::onEntityDestroyed)
+ };
+ ReceiverPtr receiver = std::dynamic_pointer_cast(destroyedEventReceiver);
+ SHEventManager::SubscribeTo(SH_ENTITY_DESTROYED_EVENT, receiver);
+ }
+
void SHScriptEngine::dumpBuildLog(const std::string_view& buildLogPath)
{
std::ifstream buildLog(buildLogPath);
@@ -423,25 +427,25 @@ namespace SHADE
}
}
}
- void SHScriptEngine::deleteFile(const std::string_view& filePath)
+ void SHScriptEngine::deleteFile(const std::string& filePath)
{
- try
- {
- std::filesystem::remove(std::filesystem::canonical(filePath));
- }
- catch (...) {} // Ignore deletion failures
- }
-
- void SHScriptEngine::deleteFolder(const std::string_view& filePath)
+ try
{
- try
- {
- std::filesystem::remove_all(std::filesystem::canonical(filePath));
- }
- catch (...) {} // Ignore deletion failures
+ std::filesystem::remove(std::filesystem::canonical(filePath));
}
+ catch (...) {} // Ignore deletion failures
+ }
+
+ void SHScriptEngine::deleteFolder(const std::string& filePath)
+ {
+ try
+ {
+ std::filesystem::remove_all(std::filesystem::canonical(filePath));
+ }
+ catch (...) {} // Ignore deletion failures
+ }
- bool SHScriptEngine::fileExists(const std::string_view& filePath)
+ bool SHScriptEngine::fileExists(const std::filesystem::path& filePath)
{
std::error_code error;
if (std::filesystem::exists(filePath, error))
@@ -483,8 +487,8 @@ namespace SHADE
DWORD status;
while (true)
{
- const auto SUCCESS = GetExitCodeProcess(procInfo.hProcess, &status);
- if (!SUCCESS)
+ const auto EXEC_SUCCESS = GetExitCodeProcess(procInfo.hProcess, &status);
+ if (!EXEC_SUCCESS)
{
auto err = GetLastError();
std::ostringstream oss;
@@ -503,4 +507,12 @@ namespace SHADE
}
}
+ std::wstring SHScriptEngine::generateBuildCommand(bool debug)
+ {
+ std::wostringstream oss;
+ oss << "dotnet build \"" << SHStringUtils::StrToWstr(CSPROJ_PATH) << "\" -c ";
+ oss << debug ? "Debug" : "Release";
+ oss << " -o \"./tmp/\" -fl -flp:LogFile=build.log;Verbosity=quiet";
+ return oss.str();
+ }
}
diff --git a/SHADE_Engine/src/Scripting/SHScriptEngine.h b/SHADE_Engine/src/Scripting/SHScriptEngine.h
index 442c0053..0994bb5d 100644
--- a/SHADE_Engine/src/Scripting/SHScriptEngine.h
+++ b/SHADE_Engine/src/Scripting/SHScriptEngine.h
@@ -15,10 +15,14 @@ of DigiPen Institute of Technology is prohibited.
#include
// Project Headers
+#include "SH_API.h"
#include "SHDotNetRuntime.h"
#include "ECS_Base/SHECSMacros.h"
#include "ECS_Base/Entity/SHEntity.h"
-#include "SH_API.h"
+#include "ECS_Base/System/SHSystem.h"
+#include "ECS_Base/System/SHSystemRoutine.h"
+#include "Events/SHEventDefines.h"
+#include "Events/SHEvent.h"
namespace SHADE
{
@@ -26,13 +30,41 @@ namespace SHADE
/// Manages initialisation of the DotNetRuntime and interfacing with CLR code written
/// and executed on .NET.
///
- class SH_API SHScriptEngine
+ 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 */
/*-----------------------------------------------------------------------------*/
- SHScriptEngine() = delete;
+ SHScriptEngine() = default;
/*-----------------------------------------------------------------------------*/
/* Lifecycle Functions */
@@ -41,33 +73,33 @@ namespace SHADE
/// Initialises the DotNetRuntime and retrieves function pointers to all
/// functions on the CLR used to interface with the engine.
///
- static void Init();
+ void Init() override;
///
/// Loads the managed script assembly. Ensure this is only called after
/// UnloadScriptAssembly() has been called.
///
- static void UnloadScriptAssembly();
+ void UnloadScriptAssembly();
///
/// Unloads the managed script assembly.
/// Take note that this will clear all existing scripts, ensure that the scene
/// is saved before doing so.
///
- static void LoadScriptAssembly();
+ void LoadScriptAssembly();
///
/// Reloads the managed script assembly.
/// Take note that this will clear all existing scripts, ensure that the scene
/// is saved before doing so.
///
- static void ReloadScriptAssembly();
+ void ReloadScriptAssembly();
///
/// Executes the FixedUpdate()s of the Scripts that are attached to
/// Entities.
///
- static void ExecuteFixedUpdates();
+ void ExecuteFixedUpdates();
///
/// Shuts down the DotNetRuntime.
///
- static void Exit();
+ void Exit() override;
/*-----------------------------------------------------------------------------*/
/* Script Manipulation Functions */
@@ -84,14 +116,14 @@ namespace SHADE
/// True if successfully added. False otherwise with the error logged to the
/// console.
///
- static bool AddScript(const SHEntity& entity, const std::string_view& scriptName);
+ bool AddScript(const SHEntity& entity, const std::string_view& scriptName);
///
/// Removes all Scripts attached to the specified Entity. Does not do anything
/// if the specified Entity is invalid or does not have any Scripts
/// attached.
///
/// The entity to remove the scripts from.
- static void RemoveAllScripts(const SHEntity& entity);
+ void RemoveAllScripts(const SHEntity& entity);
///
/// Removes all Scripts attached to the specified Entity. Unlike
/// RemoveAllScripts(), this removes all the scripts immediately.
@@ -103,7 +135,7 @@ namespace SHADE
/// Whether or not to call OnDestroy on the scripts. This is ignored if not in
/// play mode.
///
- static void RemoveAllScriptsImmediately(const SHEntity& entity, bool callOnDestroy);
+ void RemoveAllScriptsImmediately(const SHEntity& entity, bool callOnDestroy);
/*-----------------------------------------------------------------------------*/
/* Script Serialisation Functions */
@@ -116,7 +148,7 @@ namespace SHADE
///
/// String that represents the set of scripts attached to the specified Entity.
///
- static std::string SerialiseScripts(const SHEntity& entity);
+ std::string SerialiseScripts(const SHEntity& entity) const;
///
/// Loads the specified JSON string and creates a Script for the specified Entity
/// based on the specified JSON string.
@@ -125,7 +157,7 @@ namespace SHADE
///
/// The YAML string that represents the Script to load into the Entity.
///
- static void DeserialiseScript(const SHEntity& entity, const std::string& yaml);
+ void DeserialiseScript(const SHEntity& entity, const std::string& yaml) const;
/*-----------------------------------------------------------------------------*/
/* Script Editor Functions */
@@ -138,7 +170,7 @@ namespace SHADE
/// rendering code.
///
/// The Entity to render the Scripts of.
- static void RenderScriptsInInspector(const SHEntity& entity);
+ void RenderScriptsInInspector(const SHEntity& entity) const;
/*-----------------------------------------------------------------------------*/
/* Static Utility Functions */
@@ -153,12 +185,12 @@ namespace SHADE
/// can be debugged.
///
/// Whether or not the build succeeded.
- static bool BuildScriptAssembly(bool debug = false);
+ bool BuildScriptAssembly(bool debug = false) const;
///
/// Generates a .csproj file for editing and compiling the C# scripts.
///
/// File path to the generated file.
- static void GenerateScriptsCsProjFile(const std::filesystem::path& path);
+ void GenerateScriptsCsProjFile(const std::filesystem::path& path) const;
private:
/*-----------------------------------------------------------------------------*/
@@ -178,45 +210,56 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/
static constexpr std::string_view DEFAULT_CSHARP_LIB_NAME = "SHADE_Managed";
static constexpr std::string_view MANAGED_SCRIPT_LIB_NAME = "SHADE_Scripting";
+ static const std::string CSPROJ_DIR;
+ static const std::string CSPROJ_PATH;
static const std::string DEFAULT_CSHARP_NAMESPACE;
/*-----------------------------------------------------------------------------*/
/* Data Members */
/*-----------------------------------------------------------------------------*/
- static SHDotNetRuntime dotNet;
+ SHDotNetRuntime dotNet { false };
// Function Pointers to CLR Code
// - Engine Lifecycle
- static CsFuncPtr csEngineInit;
- static CsFuncPtr csEngineLoadScripts;
- static CsFuncPtr csEngineUnloadScripts;
- static CsFuncPtr csEngineReloadScripts;
- static CsFuncPtr csEngineExit;
+ CsFuncPtr csEngineInit = nullptr;
+ CsFuncPtr csEngineLoadScripts = nullptr;
+ CsFuncPtr csEngineUnloadScripts = nullptr;
+ CsFuncPtr csEngineReloadScripts = nullptr;
+ CsFuncPtr csEngineExit = nullptr;
// - Scripts Store
- static CsFuncPtr csScriptsFrameSetUp;
- static CsFuncPtr csScriptsExecuteFixedUpdate;
- static CsFuncPtr csScriptsExecuteUpdate;
- static CsFuncPtr csScriptsExecuteLateUpdate;
- static CsFuncPtr csScriptsFrameCleanUp;
- static CsScriptManipFuncPtr csScriptsAdd;
- static CsScriptBasicFuncPtr csScriptsRemoveAll;
- static CsScriptOptionalFuncPtr csScriptsRemoveAllImmediately;
- static CsScriptSerialiseFuncPtr csScriptsSerialise;
- static CsScriptDeserialiseFuncPtr csScriptDeserialise;
- static CsScriptSerialiseYamlFuncPtr csScriptsSerialiseYaml;
- static CsScriptSerialiseYamlFuncPtr csScriptDeserialiseYaml;
+ CsFuncPtr csScriptsFrameSetUp = nullptr;
+ CsFuncPtr csScriptsExecuteFixedUpdate = nullptr;
+ CsFuncPtr csScriptsExecuteUpdate = nullptr;
+ CsFuncPtr csScriptsExecuteLateUpdate = nullptr;
+ CsFuncPtr csScriptsFrameCleanUp = nullptr;
+ CsScriptManipFuncPtr csScriptsAdd = nullptr;
+ CsScriptBasicFuncPtr csScriptsRemoveAll = nullptr;
+ CsScriptOptionalFuncPtr csScriptsRemoveAllImmediately = nullptr;
+ CsScriptSerialiseFuncPtr csScriptsSerialise = nullptr;
+ CsScriptDeserialiseFuncPtr csScriptDeserialise = nullptr;
+ CsScriptSerialiseYamlFuncPtr csScriptsSerialiseYaml = nullptr;
+ CsScriptSerialiseYamlFuncPtr csScriptDeserialiseYaml = nullptr;
// - Editor
- static CsScriptEditorFuncPtr csEditorRenderScripts;
+ CsScriptEditorFuncPtr csEditorRenderScripts = nullptr;
// Delegates
/*ECS::EntityEvent::Delegate onEntityCreate;
ECS::EntityEvent::Delegate onEntityDestroy;*/
+ /*-----------------------------------------------------------------------------*/
+ /* Event Handler Functions */
+ /*-----------------------------------------------------------------------------*/
+ SHEventHandle onEntityDestroyed(SHEventPtr eventPtr);
+
/*-----------------------------------------------------------------------------*/
/* Helper Functions */
/*-----------------------------------------------------------------------------*/
///
/// Loads all the function pointers to CLR code that we need to execute.
///
- static void loadFunctions();
+ void loadFunctions();
+ ///
+ /// Registers events for the scripting system
+ ///
+ void registerEvents();
///
/// Reads the file via the specified path that represents a build log of error
/// and warning messages.
@@ -230,18 +273,19 @@ namespace SHADE
/// Deletes the file as specified by the file path.
///
/// File path to the file to delete.
- static void deleteFile(const std::string_view& filePath);
+ static void deleteFile(const std::string& filePath);
///
/// Deletes the folder and all files in it as specified by the file path.
///
/// File path to the file to delete.
- static void deleteFolder(const std::string_view& filePath);
+ static void deleteFolder(const std::string& filePath);
///
/// Checks if a specified file exists.
///
/// File path to the file to check.
/// True if the file exists
- static bool fileExists(const std::string_view& filePath);
+ static bool fileExists(const std::filesystem::path& filePath);
static DWORD execProcess(const std::wstring& path, const std::wstring& args);
+ static std::wstring generateBuildCommand(bool debug);
};
}
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();
+ }
+}
diff --git a/SHADE_Engine/src/Tools/SHLog.cpp b/SHADE_Engine/src/Tools/SHLog.cpp
new file mode 100644
index 00000000..2d0b7b58
--- /dev/null
+++ b/SHADE_Engine/src/Tools/SHLog.cpp
@@ -0,0 +1,54 @@
+/************************************************************************************//*!
+\file SHLog.cpp
+\author Tng Kah Wei, kahwei.tng, 390009620
+\par email: kahwei.tng\@digipen.edu
+\date Sep 17, 2022
+\brief Contains the definition of functions of the SHLog 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.
+*//*************************************************************************************/
+// Precompiled Header
+#include "SHpch.h"
+// Primary Header
+#include "SHLog.h"
+// Project Includes
+#include "SHLogger.h"
+
+namespace SHADE
+{
+ void SHLog::Info(const std::string& msg) noexcept
+ {
+ SHLOG_INFO(msg)
+ }
+
+ void SHLog::Warning(const std::string& msg) noexcept
+ {
+ SHLOG_WARNING(msg)
+ }
+
+
+ void SHLog::Error(const std::string& msg) noexcept
+ {
+ SHLOG_ERROR(msg)
+ }
+
+ void SHLog::Critical(const std::string& msg) noexcept
+ {
+ SHLOG_CRITICAL(msg)
+ }
+
+ void SHLog::Floor() noexcept
+ {
+ SHLOG_FLOOR()
+ }
+
+#ifdef _DEBUG
+ void SHLog::Trace(const std::string& msg) noexcept
+ {
+ SHLOG_TRACE(msg)
+ }
+#endif
+
+}
diff --git a/SHADE_Engine/src/Tools/SHLog.h b/SHADE_Engine/src/Tools/SHLog.h
new file mode 100644
index 00000000..b77042db
--- /dev/null
+++ b/SHADE_Engine/src/Tools/SHLog.h
@@ -0,0 +1,48 @@
+/************************************************************************************//*!
+\file SHLog.h
+\author Tng Kah Wei, kahwei.tng, 390009620
+\par email: kahwei.tng\@digipen.edu
+\date Sep 17, 2022
+\brief Contains the SHLog 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.
+*//*************************************************************************************/
+
+// Standard Library
+#include
+// Project Headers
+#include "SH_API.h"
+
+namespace SHADE
+{
+ /*!************************************************************************************
+
+ \class SHLog
+
+ \brief
+ Static class that contains wrapper functions for SHLogger's macros.
+
+ **************************************************************************************/
+ class SH_API SHLog
+ {
+ public:
+ /*---------------------------------------------------------------------------------*/
+ /* Constructor */
+ /*---------------------------------------------------------------------------------*/
+ SHLog() = delete;
+
+ /*---------------------------------------------------------------------------------*/
+ /* Logging Functions */
+ /*---------------------------------------------------------------------------------*/
+ static void Info(const std::string& msg) noexcept;
+ static void Warning(const std::string& msg) noexcept;
+ static void Error(const std::string& msg) noexcept;
+ static void Critical(const std::string& msg) noexcept;
+ static void Floor() noexcept;
+#ifdef _DEBUG
+ static void Trace(const std::string& msg) noexcept;
+#endif
+ };
+}
diff --git a/SHADE_Managed/src/Engine/ECS.cxx b/SHADE_Managed/src/Engine/ECS.cxx
index e4405006..36bef851 100644
--- a/SHADE_Managed/src/Engine/ECS.cxx
+++ b/SHADE_Managed/src/Engine/ECS.cxx
@@ -21,6 +21,9 @@ of DigiPen Institute of Technology is prohibited.
#include
// External Dependencies
#include "ECS_Base/Managers/SHEntityManager.h"
+#include "Scene/SHSceneManager.h"
+#include "Scene/SHSceneGraph.h"
+#include "Tools/SHLog.h"
// Project Headers
#include "Utility/Convert.hxx"
#include "Utility/Debug.hxx"
@@ -124,27 +127,31 @@ namespace SHADE
return T();
}
- // Get Transform component and get the children list
- throw gcnew System::NotImplementedException;
- //Pls::Transform* tf = Pls::ECS::GetComponent(entity);
- //if (tf == nullptr)
- // return T();
+ // Get Entity's SceneGraphNode
+ SHSceneNode* sceneGraphNode = SHSceneManager::GetCurrentSceneGraph().GetNode(entity);
+ if (sceneGraphNode == nullptr)
+ {
+ std::ostringstream oss;
+ oss << "[ECS_CLI] Failed to retrieve SceneGraphNode of entity #" << entity << ". This should not happen!";
+ SHLog::Warning(oss.str());
+ return T();
+ }
- //// Search direct children first
- //for (const auto& child : tf->GetChildren())
- //{
- // T component = GetComponent(child);
- // if (component != nullptr)
- // return component;
- //}
+ // Search direct children first
+ for (const auto& child : sceneGraphNode->GetChildren())
+ {
+ T component = GetComponent(child->GetEntityID());
+ if (component != nullptr)
+ return component;
+ }
- //// Search their children
- //for (const auto& child : tf->GetChildren())
- //{
- // T script = GetComponentInChildren(child);
- // if (script != nullptr)
- // return script;
- //}
+ // Search their children
+ for (const auto& child : sceneGraphNode->GetChildren())
+ {
+ T component = GetComponentInChildren(child->GetEntityID());
+ if (component != nullptr)
+ return component;
+ }
// None here
return T();
diff --git a/SHADE_Managed/src/Engine/GameObject.cxx b/SHADE_Managed/src/Engine/GameObject.cxx
index 1fbc3b4a..8c78e399 100644
--- a/SHADE_Managed/src/Engine/GameObject.cxx
+++ b/SHADE_Managed/src/Engine/GameObject.cxx
@@ -56,7 +56,7 @@ namespace SHADE
}
bool GameObject::IsActiveInHierarchy::get()
{
- throw gcnew System::NotImplementedException();
+ return true; // TODO: Update once we have an equivalent on the Entity object
}
/*---------------------------------------------------------------------------------*/
diff --git a/SHADE_Managed/src/Math/Vector2.hxx b/SHADE_Managed/src/Math/Vector2.hxx
index 69a6110f..9253a703 100644
--- a/SHADE_Managed/src/Math/Vector2.hxx
+++ b/SHADE_Managed/src/Math/Vector2.hxx
@@ -19,7 +19,7 @@ of DigiPen Institute of Technology is prohibited.
namespace SHADE
{
///
- /// CLR version of the the PlushieEngine's Vector2 class that represents a
+ /// CLR version of the the SHADE Engine's Vector2 class that represents a
/// 2-Dimensional Vector. Designed to closely match Unity's Vector2 struct.
///
[System::Runtime::InteropServices::StructLayout(System::Runtime::InteropServices::LayoutKind::Sequential)]
diff --git a/SHADE_Managed/src/Scripts/ScriptStore.cxx b/SHADE_Managed/src/Scripts/ScriptStore.cxx
index d30cad6b..252ab071 100644
--- a/SHADE_Managed/src/Scripts/ScriptStore.cxx
+++ b/SHADE_Managed/src/Scripts/ScriptStore.cxx
@@ -20,6 +20,7 @@ of DigiPen Institute of Technology is prohibited.
#include
// External Dependencies
#include "ECS_Base/Managers/SHEntityManager.h"
+#include "Tools/SHLog.h"
// Project Headers
#include "Utility/Debug.hxx"
#include "Utility/Convert.hxx"
@@ -147,7 +148,6 @@ namespace SHADE
// Check if entity exists and is a valid GameObject
if (!EntityUtils::IsValid(entity))
throw gcnew System::ArgumentException("Invalid Entity provided to get a Script from.");
-
// Check if entity exists in the script storage
if (!scripts.ContainsKey(entity))
@@ -155,27 +155,31 @@ namespace SHADE
return T();
}
- // Get Transform component and get the children list
- throw gcnew System::NotImplementedException;
- //Pls::Transform* tf = Pls::ECS::GetComponent(Convert::ToNative(entity));
- //if (tf == nullptr)
- // return T();
+ // Get Entity's SceneGraphNode
+ SHSceneNode* sceneGraphNode = SHSceneManager::GetCurrentSceneGraph().GetNode(entity);
+ if (sceneGraphNode == nullptr)
+ {
+ std::ostringstream oss;
+ oss << "[ECS_CLI] Failed to retrieve SceneGraphNode of entity #" << entity << ". This should not happen!";
+ SHLog::Warning(oss.str());
+ return T();
+ }
- //// Search direct children first
- //for (const auto& child : tf->GetChildren())
- //{
- // T script = GetScript(Convert::ToCLI(child));
- // if (script != nullptr)
- // return script;
- //}
+ // Search direct children first
+ for (const auto& child : sceneGraphNode->GetChildren())
+ {
+ T script = GetScript(child->GetEntityID());
+ if (script != nullptr)
+ return script;
+ }
- //// Search their children
- //for (const auto& child : tf->GetChildren())
- //{
- // T script = GetScriptInChildren(Convert::ToCLI(child));
- // if (script != nullptr)
- // return script;
- //}
+ // Search their children
+ for (const auto& child : sceneGraphNode->GetChildren())
+ {
+ T script = GetScript(child->GetEntityID());
+ if (script != nullptr)
+ return script;
+ }
// None here
return T();
@@ -232,7 +236,6 @@ namespace SHADE
// Check if entity exists
if (!EntityUtils::IsValid(entity))
throw gcnew System::ArgumentException("Invalid Entity provided to remove a Script from.");
-
// Check if entity exists in the script storage
if (!scripts.ContainsKey(entity))
@@ -263,8 +266,7 @@ namespace SHADE
Debug::LogError("[ScriptStore] Attempted to remove a Script from an invalid Entity!");
return false;
}
-
-
+
// Check if entity exists in the script storage
if (!scripts.ContainsKey(entity))
{
@@ -285,14 +287,7 @@ namespace SHADE
}
void ScriptStore::RemoveAllScripts(Entity entity)
{
- SAFE_NATIVE_CALL_BEGIN
- // Check if entity exists
- if (!EntityUtils::IsValid(entity))
- {
- Debug::LogError("[ScriptStore] Attempted to remove Scripts from an invalid Entity!");
- return;
- }
-
+ SAFE_NATIVE_CALL_BEGIN
// Check if entity exists in the script storage
if (!scripts.ContainsKey(entity))
return;
@@ -309,13 +304,6 @@ namespace SHADE
void ScriptStore::RemoveAllScriptsImmediately(Entity entity, bool callOnDestroy)
{
SAFE_NATIVE_CALL_BEGIN
- // Check if entity exists
- if (!EntityUtils::IsValid(entity))
- {
- Debug::LogError("[ScriptStore] Attempted to remove Scripts from an invalid Entity!");
- return;
- }
-
// Check if entity exists in the script storage
if (!scripts.ContainsKey(entity))
return;
@@ -384,10 +372,7 @@ namespace SHADE
while (disposalQueue.Count > 0)
{
Script^ script = disposalQueue.Dequeue();
- /*if (Application::IsPlaying)
- {
- script->OnDestroy();
- }*/
+ script->OnDestroy();
auto entity = script->Owner.GetEntity();
auto scriptList = scripts[script->Owner.GetEntity()];
scriptList->Remove(script);
@@ -494,7 +479,6 @@ namespace SHADE
// Check if entity exists, otherwise nothing
if (!EntityUtils::IsValid(entity))
return true;
-
// Check if entity exists in the script storage
if (!scripts.ContainsKey(entity))
@@ -665,7 +649,7 @@ namespace SHADE
// Entity Validity Check
if (nativeEntity == nullptr)
- throw gcnew System::InvalidOperationException("Attempted to get native Component to an invalid Entity.");
+ return false;
// Check active state
return nativeEntity->GetActive();
diff --git a/SHADE_Managed/src/Serialisation/ReflectionUtilities.cxx b/SHADE_Managed/src/Serialisation/ReflectionUtilities.cxx
new file mode 100644
index 00000000..2a9cc57c
--- /dev/null
+++ b/SHADE_Managed/src/Serialisation/ReflectionUtilities.cxx
@@ -0,0 +1,242 @@
+/************************************************************************************//*!
+\file ReflectionUtilities.cxx
+\author Tng Kah Wei, kahwei.tng, 390009620
+\par email: kahwei.tng\@digipen.edu
+\date Nov 6, 2021
+\brief Contains the definition of the functions for the ReflectionUtilities
+ managed static class.
+
+ 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.
+*//*************************************************************************************/
+// Precompiled Headers
+#include "SHpch.h"
+// Primary Header
+#include "Serialisation/ReflectionUtilities.hxx"
+// Project Includes
+#include "SerializeFieldAttribute.hxx"
+#include "Utility/Convert.hxx"
+#include "Math/Vector2.hxx"
+#include "Math/Vector3.hxx"
+#include "Utility/Debug.hxx"
+
+/*-------------------------------------------------------------------------------------*/
+/* Macro Functions */
+/*-------------------------------------------------------------------------------------*/
+///
+/// Macro expansion that is used in RapidJsonValueToField() to retrieve the specified
+/// member of a Vector type that is stored into a Vector named "vec".
+///
+/// The name of the member to retrieve.
+#define PRIMITIVE_VECTOR_FIELD_ASSIGN(MEMBER) \
+iter = jsonValue.FindMember(#MEMBER); \
+if (iter != jsonValue.MemberEnd()) \
+{ \
+ vec.MEMBER = iter->value.GetDouble(); \
+} \
+
+/*-------------------------------------------------------------------------------------*/
+/* Function Definitions */
+/*-------------------------------------------------------------------------------------*/
+namespace SHADE
+{
+ System::Collections::Generic::IEnumerable^ ReflectionUtilities::GetInstanceFields(System::Object^ object)
+ {
+ using namespace System::Reflection;
+
+ return object->GetType()->GetFields
+ (
+ BindingFlags::Public | BindingFlags::NonPublic | BindingFlags::Instance
+ );
+ }
+
+ bool ReflectionUtilities::FieldIsSerialisable(System::Reflection::FieldInfo^ fieldInfo)
+ {
+ return fieldInfo->IsPublic || fieldInfo->GetCustomAttributes(SerializeField::typeid, true)->Length > 0;
+ }
+
+ /*---------------------------------------------------------------------------------*/
+ /* Serialisation Functions */
+ /*---------------------------------------------------------------------------------*/
+ void ReflectionUtilities::Serialise(System::Object^ object, YAML::Emitter& yaml)
+ {
+ using namespace System::Reflection;
+
+ // Create YAML object
+ yaml << YAML::Key << Convert::ToNative(object->GetType()->FullName);
+ yaml << YAML::BeginMap;
+
+ // Get all fields
+ System::Collections::Generic::IEnumerable^ fields = GetInstanceFields(object);
+ for each (FieldInfo^ field in fields)
+ {
+ // Ignore private and non-SerialiseField
+ if (!FieldIsSerialisable(field))
+ continue;
+
+ // Serialise
+ writeFieldIntoYaml(field, object, yaml);
+ }
+
+ yaml << YAML::EndMap;
+ }
+ void ReflectionUtilities::Deserialise(YAML::Node& yamlNode, Object^ object)
+ {
+ using namespace System::Reflection;
+
+ // Load the YAML
+ if (!yamlNode.IsMap())
+ {
+ // Invalid
+ Debug::LogError
+ (
+ System::String::Format("[ReflectionUtilities] Invalid YAML Node provided for deserialization of \"{0}\" script.",
+ object->GetType()->FullName)
+ );
+ return;
+ }
+ // Get all fields
+ System::Collections::Generic::IEnumerable^ fields = GetInstanceFields(object);
+ for each (FieldInfo^ field in fields)
+ {
+ // Ignore private and non-SerialiseField
+ if (!FieldIsSerialisable(field))
+ continue;
+
+ // Deserialise
+ const std::string FIELD_NAME = Convert::ToNative(field->Name);
+ if (yamlNode[FIELD_NAME])
+ {
+ writeYamlIntoField(field, object, yamlNode[FIELD_NAME]);
+ }
+ }
+ }
+ /*---------------------------------------------------------------------------------*/
+ /* Serialization Helper Functions */
+ /*---------------------------------------------------------------------------------*/
+ void ReflectionUtilities::writeFieldIntoYaml(System::Reflection::FieldInfo^ fieldInfo, Object^ object, YAML::Emitter& yaml)
+ {
+ // Field Name
+ yaml << YAML::Key << Convert::ToNative(fieldInfo->Name);
+
+ // Field Value
+ yaml << YAML::Value;
+ if (fieldInsertYaml (fieldInfo, object, yaml) ||
+ fieldInsertYaml (fieldInfo, object, yaml) ||
+ fieldInsertYaml (fieldInfo, object, yaml) ||
+ fieldInsertYaml(fieldInfo, object, yaml) ||
+ fieldInsertYaml(fieldInfo, object, yaml) ||
+ fieldInsertYaml(fieldInfo, object, yaml) ||
+ fieldInsertYaml (fieldInfo, object, yaml) ||
+ fieldInsertYaml (fieldInfo, object, yaml) ||
+ fieldInsertYaml (fieldInfo, object, yaml) ||
+ fieldInsertYaml (fieldInfo, object, yaml))
+ {
+ return;
+ }
+ else if (fieldInfo->FieldType->IsSubclassOf(System::Enum::typeid))
+ {
+ yaml << safe_cast(fieldInfo->GetValue(object));
+ }
+ else if (fieldInfo->FieldType == System::String::typeid)
+ {
+ System::String^ str = safe_cast(fieldInfo->GetValue(object));
+ yaml << Convert::ToNative(str);
+ }
+ else if (fieldInfo->FieldType == Vector2::typeid)
+ {
+ Vector2 vec = safe_cast(fieldInfo->GetValue(object));
+ yaml << YAML::BeginSeq << YAML::Flow << vec.x << vec.y << YAML::EndSeq;
+ }
+ else if (fieldInfo->FieldType == Vector3::typeid)
+ {
+ Vector3 vec = safe_cast(fieldInfo->GetValue(object));
+ yaml << YAML::BeginSeq << YAML::Flow << vec.x << vec.y << vec.z << YAML::EndSeq;
+ }
+ else // Not any of the supported types
+ {
+ Debug::LogWarning(Convert::ToNative(System::String::Format
+ (
+ "[ReflectionUtilities] Failed to parse \"{0}\" of \"{1}\" type for serialization.",
+ fieldInfo->Name, fieldInfo->FieldType)
+ ));
+ }
+ }
+
+ void ReflectionUtilities::writeYamlIntoField(System::Reflection::FieldInfo^ fieldInfo, Object^ object, YAML::Node& node)
+ {
+ if (fieldInfo->FieldType == System::Int16::typeid)
+ {
+ fieldInfo->SetValue(object, node.as());
+ }
+ if (fieldAssignYaml (fieldInfo, object, node) ||
+ fieldAssignYaml (fieldInfo, object, node) ||
+ fieldAssignYaml (fieldInfo, object, node) ||
+ fieldAssignYaml(fieldInfo, object, node) ||
+ fieldAssignYaml(fieldInfo, object, node) ||
+ fieldAssignYaml(fieldInfo, object, node) ||
+ fieldAssignYaml (fieldInfo, object, node) ||
+ fieldAssignYaml (fieldInfo, object, node) ||
+ fieldAssignYaml (fieldInfo, object, node) ||
+ fieldAssignYaml (fieldInfo, object, node))
+ {
+ return;
+ }
+ else if (fieldInfo->FieldType->IsSubclassOf(System::Enum::typeid))
+ {
+ fieldInfo->SetValue(object, node.as());
+ }
+ else if (fieldInfo->FieldType == System::String::typeid)
+ {
+ fieldInfo->SetValue(object, Convert::ToCLI(node.as()));
+ }
+ else if (fieldInfo->FieldType == Vector2::typeid)
+ {
+ if (node.IsSequence() && node.size() == 2)
+ {
+ Vector2 vec;
+ vec.x = node[0].as();
+ vec.y = node[1].as();
+ fieldInfo->SetValue(object, vec);
+ }
+ else
+ {
+ Debug::LogWarning
+ (
+ System::String::Format("[ReflectionUtilities] Invalid YAML Node provided for deserialization of a Vector2 \"{0}\" field in \"{1}\" script.",
+ fieldInfo->Name, object->GetType()->FullName)
+ );
+ }
+ }
+ else if (fieldInfo->FieldType == Vector3::typeid)
+ {
+ if (node.IsSequence() && node.size() == 3)
+ {
+ Vector3 vec;
+ vec.x = node[0].as();
+ vec.y = node[1].as();
+ vec.z = node[2].as();
+ fieldInfo->SetValue(object, vec);
+ }
+ else
+ {
+ Debug::LogWarning
+ (
+ System::String::Format("[ReflectionUtilities] Invalid YAML Node provided for deserialization of a Vector3 \"{0}\" field in \"{1}\" script.",
+ fieldInfo->Name, object->GetType()->FullName)
+ );
+ }
+ }
+ else // Not any of the supported types
+ {
+ Debug::LogWarning(Convert::ToNative(System::String::Format
+ (
+ "[ReflectionUtilities] Failed to parse \"{0}\" of \"{1}\" type for deserialisation.",
+ fieldInfo->Name, fieldInfo->FieldType)
+ ));
+ }
+ }
+}
diff --git a/SHADE_Managed/src/Serialisation/ReflectionUtilities.h++ b/SHADE_Managed/src/Serialisation/ReflectionUtilities.h++
new file mode 100644
index 00000000..88469b34
--- /dev/null
+++ b/SHADE_Managed/src/Serialisation/ReflectionUtilities.h++
@@ -0,0 +1,54 @@
+/************************************************************************************//*!
+\file ReflectionUtilities.h++
+\author Tng Kah Wei, kahwei.tng, 390009620
+\par email: kahwei.tng\@digipen.edu
+\date Sep 16, 2022
+\brief Contains the definition of the template functions of the managed
+ ReflectionUtilities static 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
+
+// Primary Header
+#include "ReflectionUtilities.hxx"
+
+namespace SHADE
+{
+ /*---------------------------------------------------------------------------------*/
+ /* Serialization Helper Functions */
+ /*---------------------------------------------------------------------------------*/
+ template
+ bool ReflectionUtilities::fieldInsertYaml(System::Reflection::FieldInfo^ fieldInfo, System::Object^ object, YAML::Emitter& emitter)
+ {
+ if (fieldInfo->FieldType == FieldType::typeid)
+ {
+ emitter << safe_cast(fieldInfo->GetValue(object));
+ return true;
+ }
+
+ return false;
+ }
+
+ template
+ bool ReflectionUtilities::fieldAssignYaml(System::Reflection::FieldInfo^ fieldInfo, Object^ object, YAML::Node& node)
+ {
+ return fieldAssignYaml(fieldInfo, object, node);
+ }
+
+ template
+ bool ReflectionUtilities::fieldAssignYaml(System::Reflection::FieldInfo^ fieldInfo, Object^ object, YAML::Node& node)
+ {
+ if (fieldInfo->FieldType == FieldType::typeid)
+ {
+ fieldInfo->SetValue(object, node.as());
+ return true;
+ }
+
+ return false;
+ }
+}
diff --git a/SHADE_Managed/src/Serialisation/ReflectionUtilities.hxx b/SHADE_Managed/src/Serialisation/ReflectionUtilities.hxx
new file mode 100644
index 00000000..53f8fa1d
--- /dev/null
+++ b/SHADE_Managed/src/Serialisation/ReflectionUtilities.hxx
@@ -0,0 +1,81 @@
+/************************************************************************************//*!
+\file ReflectionUtilities.hxx
+\author Tng Kah Wei, kahwei.tng, 390009620
+\par email: kahwei.tng\@digipen.edu
+\date Nov 6, 2021
+\brief Contains the definition of the managed ReflectionUtilities static class.
+
+ 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
+
+// External Dependencies
+#include
+
+namespace SHADE
+{
+ ///
+ /// Contains useful static functions for working with Reflection.
+ ///
+ private ref class ReflectionUtilities abstract sealed
+ {
+ public:
+ /*-----------------------------------------------------------------------------*/
+ /* Utility Functions */
+ /*-----------------------------------------------------------------------------*/
+ ///
+ /// Retrieves a set of all non-static (instance) fields from a specified object.
+ ///
+ /// The object to get non-static fields from.
+ /// Immutable list of non-static fields.
+ static System::Collections::Generic::IEnumerable^ GetInstanceFields(System::Object^ object);
+ ///
+ /// Checks if a specified field is a candidate for serialisation. This means that
+ /// the field is public or private with the [SerialiseField] attribute.
+ ///
+ /// The field to check.
+ ///
+ /// True if the specified field is a candidate for serialisation.
+ ///
+ static bool FieldIsSerialisable(System::Reflection::FieldInfo^ fieldInfo);
+
+ /*-----------------------------------------------------------------------------*/
+ /* Serialisation Functions */
+ /*-----------------------------------------------------------------------------*/
+ ///
+ /// Creates a JSON node that represents the specified object and its associated
+ /// serialisable fields. Public fields and fields marked with the SerialiseField
+ /// attribute will be serialised.
+ ///
+ /// The object to serialise.
+ static void Serialise(System::Object^ object, YAML::Emitter& yaml);
+ ///
+ /// Deserialises a YAML node that contains a map of Scripts and copies the
+ /// deserialised data into the specified object if there are matching fields.
+ ///
+ ///
+ /// The JSON string that contains the data to copy into this PlushieScript
+ /// object.
+ ///
+ /// The object to copy deserialised data into.
+ static void Deserialise(YAML::Node& yamlNode, Object^ object);
+
+ /*-----------------------------------------------------------------------------*/
+ /* Serialization Helper Functions */
+ /*-----------------------------------------------------------------------------*/
+ static void writeFieldIntoYaml(System::Reflection::FieldInfo^ fieldInfo, Object^ object, YAML::Emitter& yaml);
+ template
+ static bool fieldInsertYaml(System::Reflection::FieldInfo^ fieldInfo, System::Object^ object, YAML::Emitter& emitter);
+ static void writeYamlIntoField(System::Reflection::FieldInfo^ fieldInfo, Object^ object, YAML::Node& node);
+ template
+ static bool fieldAssignYaml(System::Reflection::FieldInfo^ fieldInfo, Object^ object, YAML::Node& node);
+ template
+ static bool fieldAssignYaml(System::Reflection::FieldInfo^ fieldInfo, Object^ object, YAML::Node& node);
+ };
+}
+
+#include "ReflectionUtilities.h++"
\ No newline at end of file
diff --git a/SHADE_Managed/src/Serialisation/SerialiseFieldAttribute.cxx b/SHADE_Managed/src/Serialisation/SerialiseFieldAttribute.cxx
new file mode 100644
index 00000000..c371d200
--- /dev/null
+++ b/SHADE_Managed/src/Serialisation/SerialiseFieldAttribute.cxx
@@ -0,0 +1,27 @@
+/************************************************************************************//*!
+\file SerializeFieldAttribute.cxx
+\author Tng Kah Wei, kahwei.tng, 390009620
+\par email: kahwei.tng\@digipen.edu
+\date Nov 5, 2021
+\brief Contains the definition of the functions of the managed SerializeField
+ Attribute class.
+
+ 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.
+*//*************************************************************************************/
+// Precompiled Headers
+#include "SHpch.h"
+// Primary Header
+#include "SerializeFieldAttribute.hxx"
+
+namespace SHADE
+{
+ /*---------------------------------------------------------------------------------*/
+ /* Constructors */
+ /*---------------------------------------------------------------------------------*/
+ SerializeField::SerializeField()
+ {}
+}
diff --git a/SHADE_Managed/src/Serialisation/SerializeFieldAttribute.hxx b/SHADE_Managed/src/Serialisation/SerializeFieldAttribute.hxx
new file mode 100644
index 00000000..533ded2a
--- /dev/null
+++ b/SHADE_Managed/src/Serialisation/SerializeFieldAttribute.hxx
@@ -0,0 +1,35 @@
+/************************************************************************************//*!
+\file SerializeFieldAttribute.hxx
+\author Tng Kah Wei, kahwei.tng, 390009620
+\par email: kahwei.tng\@digipen.edu
+\date Nov 5, 2021
+\brief Contains the definition of the managed SerializeField Attribute class with
+ the declaration of functions for working with it.
+
+ 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
+
+namespace SHADE
+{
+ ///
+ /// Simple attribute to mark that a field in a Script should be serialised.
+ ///
+ [System::AttributeUsage(System::AttributeTargets::Field)]
+ public ref class SerializeField : public System::Attribute
+ {
+ public:
+ /*-----------------------------------------------------------------------------*/
+ /* Constructors */
+ /*-----------------------------------------------------------------------------*/
+ ///
+ /// Default Constructor
+ ///
+ SerializeField();
+ };
+}
+
diff --git a/SHADE_Managed/src/Utility/Debug.cxx b/SHADE_Managed/src/Utility/Debug.cxx
index 330375b0..8a107ab3 100644
--- a/SHADE_Managed/src/Utility/Debug.cxx
+++ b/SHADE_Managed/src/Utility/Debug.cxx
@@ -18,6 +18,8 @@ of DigiPen Institute of Technology is prohibited.
#include "Debug.hxx"
// Standard Libraries
#include
+// External Libraries
+#include "Tools/SHLog.h"
// Project Headers
#include "Convert.hxx"
@@ -28,11 +30,11 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
void Debug::Log(const std::string& str)
{
- std::cout << str << std::endl;
+ SHLog::Info(str);
}
void Debug::Log(System::String^ str)
- {
- System::Console::WriteLine(str);
+ {
+ SHLog::Info(Convert::ToNative(str));
}
void Debug::Log(System::String^ str, Object^ owner)
@@ -47,15 +49,15 @@ namespace SHADE
{
std::ostringstream oss;
oss << "[" << throwerName << "] " << Convert::ToNative(str);
- std::cout << oss.str() << std::endl;
+ Log(oss.str());
}
void Debug::LogWarning(const std::string& str)
{
- std::cout << str << std::endl;
+ SHLog::Warning(str);
}
void Debug::LogWarning(System::String^ str)
- {
- System::Console::WriteLine(str);
+ {
+ SHLog::Warning(Convert::ToNative(str));
}
void Debug::LogWarning(System::String^ str, Object^ thrower)
{
@@ -69,16 +71,16 @@ namespace SHADE
void Debug::LogWarning(System::String^ str, const std::string& throwerName)
{
std::ostringstream oss;
- oss << "[" << throwerName << "] " << Convert::ToNative(str);
- std::cout << oss.str() << std::endl;
+ oss << "[" << throwerName << "] " << Convert::ToNative(str);
+ LogWarning(oss.str());
}
void Debug::LogError(const std::string& str)
{
- std::cout << str << std::endl;
+ SHLog::Error(str);
}
void Debug::LogError(System::String^ str)
{
- System::Console::WriteLine(str);
+ SHLog::Error(Convert::ToNative(str));
}
void Debug::LogError(System::String^ str, Object^ thrower)
{
@@ -88,7 +90,7 @@ namespace SHADE
{
std::ostringstream oss;
oss << "[" << throwerName << "] -> " << Convert::ToNative(str);
- std::cout << oss.str() << std::endl;
+ LogError(oss.str());
}
void Debug::LogError(System::String^ str, System::String^ throwerName)
{
@@ -111,12 +113,12 @@ namespace SHADE
{
std::ostringstream oss;
oss << "[" << throwerName << "] Unhandled exception: " << Convert::ToNative(exception->ToString());
- std::cout << oss.str() << std::endl;
+ LogError(oss.str());
}
void Debug::LogExceptionNative(const std::exception& exception, const std::string& throwerName)
{
std::ostringstream oss;
oss << "[" << throwerName << "] Unhandled exception: " << exception.what();
- std::cout << oss.str() << std::endl;
+ LogError(oss.str());
}
}
diff --git a/TempScriptsFolder/TestScript.cs b/TempScriptsFolder/TestScript.cs
new file mode 100644
index 00000000..c1ed5bd5
--- /dev/null
+++ b/TempScriptsFolder/TestScript.cs
@@ -0,0 +1,23 @@
+using SHADE;
+
+public class TestScript : Script
+{
+ public TestScript(GameObject gameObj) : base(gameObj) {}
+
+ protected override void awake()
+ {
+ Debug.Log("TestScript.Awake()");
+ }
+ protected override void start()
+ {
+ Debug.Log("TestScript.Start()");
+ }
+ protected override void update()
+ {
+ Debug.Log("TestScript.Update()");
+ }
+ protected override void onDestroy()
+ {
+ Debug.Log("TestScript.OnDestroy()");
+ }
+}
\ No newline at end of file
diff --git a/premake5.lua b/premake5.lua
index 450be7d7..8b6c5a29 100644
--- a/premake5.lua
+++ b/premake5.lua
@@ -7,12 +7,12 @@ workspace "SHADE"
configurations
{
"Debug",
- "Release",
+ "Release"
}
flags
{
- "MultiProcessorCompile"
+ "MultiProcessorCompile"
}
outputdir = "%{wks.location}/bin/%{cfg.buildcfg}"