#comment Completed System Routine Added Unit Test version 1
This commit is contained in:
parent
b7cd1bed48
commit
a90c137445
|
@ -1,5 +1,6 @@
|
||||||
#include "SBpch.h"
|
#include "SBpch.h"
|
||||||
#include "SBApplication.h"
|
#include "SBApplication.h"
|
||||||
|
#include "ECS_Base/UnitTesting/SHECSUnitTest.h"
|
||||||
|
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
#include "Editor/SHEditor.h"
|
#include "Editor/SHEditor.h"
|
||||||
|
@ -28,6 +29,8 @@ namespace Sandbox
|
||||||
#else
|
#else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SBApplication::Update(void)
|
void SBApplication::Update(void)
|
||||||
|
|
|
@ -118,6 +118,9 @@
|
||||||
<ClInclude Include="src\ECS_Base\System\SHRoutineStats.h" />
|
<ClInclude Include="src\ECS_Base\System\SHRoutineStats.h" />
|
||||||
<ClInclude Include="src\ECS_Base\System\SHSystem.h" />
|
<ClInclude Include="src\ECS_Base\System\SHSystem.h" />
|
||||||
<ClInclude Include="src\ECS_Base\System\SHSystemRoutine.h" />
|
<ClInclude Include="src\ECS_Base\System\SHSystemRoutine.h" />
|
||||||
|
<ClInclude Include="src\ECS_Base\UnitTesting\SHECSUnitTest.h" />
|
||||||
|
<ClInclude Include="src\ECS_Base\UnitTesting\SHTestComponents.h" />
|
||||||
|
<ClInclude Include="src\ECS_Base\UnitTesting\SHTestSystems.h" />
|
||||||
<ClInclude Include="src\Engine\SHEngine.h" />
|
<ClInclude Include="src\Engine\SHEngine.h" />
|
||||||
<ClInclude Include="src\Filesystem\SHFileSystem.h" />
|
<ClInclude Include="src\Filesystem\SHFileSystem.h" />
|
||||||
<ClInclude Include="src\Graphics\Buffers\SHVkBuffer.h" />
|
<ClInclude Include="src\Graphics\Buffers\SHVkBuffer.h" />
|
||||||
|
@ -204,6 +207,7 @@
|
||||||
<ClCompile Include="src\ECS_Base\Managers\SHSystemManager.cpp" />
|
<ClCompile Include="src\ECS_Base\Managers\SHSystemManager.cpp" />
|
||||||
<ClCompile Include="src\ECS_Base\System\SHFixedSystemRoutine.cpp" />
|
<ClCompile Include="src\ECS_Base\System\SHFixedSystemRoutine.cpp" />
|
||||||
<ClCompile Include="src\ECS_Base\System\SHSystemRoutine.cpp" />
|
<ClCompile Include="src\ECS_Base\System\SHSystemRoutine.cpp" />
|
||||||
|
<ClCompile Include="src\ECS_Base\UnitTesting\SHECSUnitTest.cpp" />
|
||||||
<ClCompile Include="src\Engine\SHEngine.cpp" />
|
<ClCompile Include="src\Engine\SHEngine.cpp" />
|
||||||
<ClCompile Include="src\Filesystem\SHFileSystem.cpp" />
|
<ClCompile Include="src\Filesystem\SHFileSystem.cpp" />
|
||||||
<ClCompile Include="src\Graphics\Buffers\SHVkBuffer.cpp" />
|
<ClCompile Include="src\Graphics\Buffers\SHVkBuffer.cpp" />
|
||||||
|
|
|
@ -388,6 +388,9 @@
|
||||||
<ClInclude Include="src\ECS_Base\System\SHSystemRoutine.h" />
|
<ClInclude Include="src\ECS_Base\System\SHSystemRoutine.h" />
|
||||||
<ClInclude Include="src\ECS_Base\System\SHFixedSystemRoutine.h" />
|
<ClInclude Include="src\ECS_Base\System\SHFixedSystemRoutine.h" />
|
||||||
<ClInclude Include="src\ECS_Base\System\SHRoutineStats.h" />
|
<ClInclude Include="src\ECS_Base\System\SHRoutineStats.h" />
|
||||||
|
<ClInclude Include="src\ECS_Base\UnitTesting\SHTestComponents.h" />
|
||||||
|
<ClInclude Include="src\ECS_Base\UnitTesting\SHTestSystems.h" />
|
||||||
|
<ClInclude Include="src\ECS_Base\UnitTesting\SHECSUnitTest.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\ECS_Base\Components\SHComponent.cpp">
|
<ClCompile Include="src\ECS_Base\Components\SHComponent.cpp">
|
||||||
|
@ -591,5 +594,6 @@
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\ECS_Base\System\SHSystemRoutine.cpp" />
|
<ClCompile Include="src\ECS_Base\System\SHSystemRoutine.cpp" />
|
||||||
<ClCompile Include="src\ECS_Base\System\SHFixedSystemRoutine.cpp" />
|
<ClCompile Include="src\ECS_Base\System\SHFixedSystemRoutine.cpp" />
|
||||||
|
<ClCompile Include="src\ECS_Base\UnitTesting\SHECSUnitTest.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -34,7 +34,7 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHSystemManager::RunRoutines(bool editorPause) noexcept
|
void SHSystemManager::RunRoutines(bool editorPause, double deltaTime) noexcept
|
||||||
{
|
{
|
||||||
for (auto& routine : systemRoutineContainer)
|
for (auto& routine : systemRoutineContainer)
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,7 @@ namespace SHADE
|
||||||
if (routine.get()->IsRunInEditorPause)
|
if (routine.get()->IsRunInEditorPause)
|
||||||
{
|
{
|
||||||
std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now();
|
std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now();
|
||||||
routine.get()->Execute(0.0);
|
routine.get()->Execute(deltaTime);
|
||||||
std::chrono::high_resolution_clock::time_point end = std::chrono::high_resolution_clock::now();
|
std::chrono::high_resolution_clock::time_point end = std::chrono::high_resolution_clock::now();
|
||||||
routine.get()->stats.executionTime = std::chrono::duration<double, std::milli>(end - start).count();
|
routine.get()->stats.executionTime = std::chrono::duration<double, std::milli>(end - start).count();
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ namespace SHADE
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now();
|
std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now();
|
||||||
routine.get()->Execute(0.0);
|
routine.get()->Execute(deltaTime);
|
||||||
std::chrono::high_resolution_clock::time_point end = std::chrono::high_resolution_clock::now();
|
std::chrono::high_resolution_clock::time_point end = std::chrono::high_resolution_clock::now();
|
||||||
routine.get()->stats.executionTime = std::chrono::duration<double, std::milli>(end - start).count();
|
routine.get()->stats.executionTime = std::chrono::duration<double, std::milli>(end - start).count();
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,8 @@ namespace SHADE
|
||||||
|
|
||||||
void SHSystemManager::Exit() noexcept
|
void SHSystemManager::Exit() noexcept
|
||||||
{
|
{
|
||||||
|
systemRoutineContainer.clear();
|
||||||
|
|
||||||
for (SystemContainer::reverse_iterator it = systemContainer.rbegin(); it != systemContainer.rend(); ++it)
|
for (SystemContainer::reverse_iterator it = systemContainer.rbegin(); it != systemContainer.rend(); ++it)
|
||||||
{
|
{
|
||||||
(*it).second->Exit();
|
(*it).second->Exit();
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace SHADE
|
||||||
* none
|
* none
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static std::enable_if_t<std::is_base_of_v<SHSystem, T>, void> CreateSystem()
|
static std::enable_if_t<std::is_base_of_v<SHSystem, T>, SystemID> CreateSystem()
|
||||||
{
|
{
|
||||||
SystemTypeID typeID = SystemFamily::GetID<T>();
|
SystemTypeID typeID = SystemFamily::GetID<T>();
|
||||||
|
|
||||||
|
@ -64,10 +64,12 @@ namespace SHADE
|
||||||
while (systemContainer.find(id) != systemContainer.end())
|
while (systemContainer.find(id) != systemContainer.end())
|
||||||
{
|
{
|
||||||
++version;
|
++version;
|
||||||
SystemID id = ((SystemID)version << sizeof(SystemVersionID) * CHAR_BIT) + typeID;
|
id = ((SystemID)version << sizeof(SystemVersionID) * CHAR_BIT) + typeID;
|
||||||
}
|
}
|
||||||
systemContainer.emplace(id, std::make_unique<T>());
|
systemContainer.emplace(id, std::make_unique<T>());
|
||||||
|
systemContainer[id].get()->systemID = id;
|
||||||
|
|
||||||
|
return id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +105,7 @@ namespace SHADE
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
static void Init() noexcept;
|
static void Init() noexcept;
|
||||||
|
|
||||||
static void RunRoutines(bool editorPause) noexcept;
|
static void RunRoutines(bool editorPause, double deltaTime) noexcept;
|
||||||
|
|
||||||
template<typename SystemType, typename RoutineType>
|
template<typename SystemType, typename RoutineType>
|
||||||
static void RegisterRoutine(SystemVersionID version = 0) noexcept
|
static void RegisterRoutine(SystemVersionID version = 0) noexcept
|
||||||
|
@ -112,6 +114,7 @@ namespace SHADE
|
||||||
if (system == nullptr)
|
if (system == nullptr)
|
||||||
return;
|
return;
|
||||||
systemRoutineContainer.emplace_back(std::make_unique<RoutineType>());
|
systemRoutineContainer.emplace_back(std::make_unique<RoutineType>());
|
||||||
|
systemRoutineContainer.back().get()->system = system;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
#include "SHpch.h"
|
||||||
#include "SHFixedSystemRoutine.h"
|
#include "SHFixedSystemRoutine.h"
|
||||||
#include "../SHECSMacros.h"
|
#include "../SHECSMacros.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
|
||||||
void SHFixedSystemRoutine::Execute(double dt)
|
void SHFixedSystemRoutine::Execute(double dt) noexcept
|
||||||
{
|
{
|
||||||
accumulatedTime += dt;
|
accumulatedTime += dt;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
|
|
@ -15,13 +15,14 @@ namespace SHADE
|
||||||
double executionTime;
|
double executionTime;
|
||||||
int numSteps{1};
|
int numSteps{1};
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& os, const SHRoutineStats& stats);
|
//friend std::ostream& operator<<(std::ostream& os, const SHRoutineStats& stats);
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& os, const SHRoutineStats& stats)
|
//std::ostream& operator<<(std::ostream& os, const SHRoutineStats& stats)
|
||||||
{
|
//{
|
||||||
os << stats.name << ": Execution Time: " << stats.executionTime << " Number of steps: " << stats.numSteps << std::endl;
|
// os << stats.name << ": Execution Time: " << stats.executionTime << " Number of steps: " << stats.numSteps << std::endl;
|
||||||
}
|
// return os;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "../SHECSMacros.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -17,6 +19,9 @@ namespace SHADE
|
||||||
|
|
||||||
class SHSystem
|
class SHSystem
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
SystemID systemID;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/*!*************************************************************************
|
/*!*************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -24,6 +29,9 @@ namespace SHADE
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
SHSystem()= default;
|
SHSystem()= default;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*!*************************************************************************
|
/*!*************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -51,37 +59,14 @@ namespace SHADE
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
virtual void Exit() = 0;
|
virtual void Exit() = 0;
|
||||||
|
|
||||||
|
friend class SHSystemManager;
|
||||||
|
|
||||||
protected:
|
inline SystemID GetSystemID(void) const noexcept { return systemID; }
|
||||||
|
inline SystemVersionID GetSystemVersion(void) const noexcept { return static_cast<SystemVersionID>(systemID >> sizeof(SystemVersionID) * CHAR_BIT); }
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SHTestSystem : public SHSystem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
SHTestSystem() = default;
|
|
||||||
~SHTestSystem() = default;
|
|
||||||
|
|
||||||
int value{5};
|
|
||||||
|
|
||||||
void Init()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Exit()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
|
#include "SHpch.h"
|
||||||
#include "SHSystemRoutine.h"
|
#include "SHSystemRoutine.h"
|
||||||
|
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,181 @@
|
||||||
|
#include "SHpch.h"
|
||||||
|
#include "SHECSUnitTest.h"
|
||||||
|
#include "../Managers/SHComponentManager.h"
|
||||||
|
#include "../Managers/SHEntityManager.h"
|
||||||
|
#include "../Managers/SHSystemManager.h"
|
||||||
|
#include "SHTestComponents.h"
|
||||||
|
#include "SHTestSystems.h"
|
||||||
|
#include "Tools/SHLogger.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
void SHECSUnitTest::TestAll(void) noexcept
|
||||||
|
{
|
||||||
|
TestBasicEntityCreate();
|
||||||
|
TestEntityCreateTemplate();
|
||||||
|
TestEntityDestroy();
|
||||||
|
TestSystemRoutine();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SHECSUnitTest::TestBasicEntityCreate(void) noexcept
|
||||||
|
{
|
||||||
|
|
||||||
|
SHComponentManager::CreateComponentSparseSet<SHComponent_A>();
|
||||||
|
SHComponentManager::CreateComponentSparseSet<SHComponent_B>();
|
||||||
|
SHComponentManager::CreateComponentSparseSet<SHComponent_C>();
|
||||||
|
|
||||||
|
SHLOG_INFO("Test for add and remove component")
|
||||||
|
|
||||||
|
EntityID id1 = SHEntityManager::CreateEntity();
|
||||||
|
EntityID id2 = SHEntityManager::CreateEntity();
|
||||||
|
EntityID id3 = SHEntityManager::CreateEntity();
|
||||||
|
|
||||||
|
|
||||||
|
SHComponentManager::AddComponent<SHComponent_A>(id1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SHECSUnitTest::TestEntityCreateTemplate(void) noexcept
|
||||||
|
{
|
||||||
|
std::cout << "\nTest2" << std::endl;
|
||||||
|
//Test entity Creation.
|
||||||
|
|
||||||
|
SHComponentManager::CreateComponentSparseSet<SHComponent_A>();
|
||||||
|
SHComponentManager::CreateComponentSparseSet<SHComponent_B>();
|
||||||
|
SHComponentManager::CreateComponentSparseSet<SHComponent_C>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (size_t i = 0; i < 10000; ++i)
|
||||||
|
{
|
||||||
|
switch (i % 3)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
SHEntityManager::CreateEntity<SHComponent_A, SHComponent_B>();
|
||||||
|
}break;
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
SHEntityManager::CreateEntity<SHComponent_A, SHComponent_C>();
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
SHEntityManager::CreateEntity<SHComponent_A>();
|
||||||
|
}break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
auto& denseA = SHComponentManager::GetDense<SHComponent_A>();
|
||||||
|
auto& denseB = SHComponentManager::GetDense<SHComponent_B>();
|
||||||
|
auto& denseC = SHComponentManager::GetDense<SHComponent_C>();
|
||||||
|
|
||||||
|
std::cout << "Test Entity Creation" << std::endl;
|
||||||
|
std::cout << "dense A size: " << denseA.size() << ((denseA.size() == 10000) ? " Success" : " Failure") << std::endl;
|
||||||
|
std::cout << "dense B size: " << denseB.size() << ((denseB.size() == 3334) ? " Success" : " Failure") << std::endl;
|
||||||
|
std::cout << "dense C size: " << denseC.size() << ((denseC.size() == 3333) ? " Success" : " Failure") << std::endl;
|
||||||
|
std::cout << "Number of entities: " << SHEntityManager::GetEntityCount() << (SHEntityManager::GetEntityCount() == 10000 ? " Success" : " Failure") << std::endl;
|
||||||
|
|
||||||
|
SHEntityManager::DestroyAllEntity();
|
||||||
|
std::cout << std::endl << "Test Destroy All Entity" << std::endl;
|
||||||
|
std::cout << "dense A size: " << denseA.size() << ((denseA.size() == 0) ? " Success" : " Failure") << std::endl;
|
||||||
|
std::cout << "dense B size: " << denseB.size() << ((denseB.size() == 0) ? " Success" : " Failure") << std::endl;
|
||||||
|
std::cout << "dense C size: " << denseC.size() << ((denseC.size() == 0) ? " Success" : " Failure") << std::endl;
|
||||||
|
std::cout << "Number of entities: " << SHEntityManager::GetEntityCount() << (SHEntityManager::GetEntityCount() == 0 ? " Success" : " Failure") << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SHECSUnitTest::TestEntityDestroy(void) noexcept
|
||||||
|
{
|
||||||
|
std::cout << "\nTest3" << std::endl;
|
||||||
|
SHComponentManager::CreateComponentSparseSet<SHComponent_A>();
|
||||||
|
SHComponentManager::CreateComponentSparseSet<SHComponent_B>();
|
||||||
|
SHComponentManager::CreateComponentSparseSet<SHComponent_C>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (size_t i = 0; i < 10000; ++i)
|
||||||
|
{
|
||||||
|
switch (i % 3)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
SHEntityManager::CreateEntity<SHComponent_A, SHComponent_B>();
|
||||||
|
}break;
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
SHEntityManager::CreateEntity<SHComponent_A, SHComponent_C>();
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
SHEntityManager::CreateEntity<SHComponent_A>();
|
||||||
|
}break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SHEntityManager::DestroyEntity(5000);
|
||||||
|
SHEntityManager::DestroyEntity(5001);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
auto& denseA = SHComponentManager::GetDense<SHComponent_A>();
|
||||||
|
auto& denseB = SHComponentManager::GetDense<SHComponent_B>();
|
||||||
|
auto& denseC = SHComponentManager::GetDense<SHComponent_C>();
|
||||||
|
|
||||||
|
|
||||||
|
std::cout << "Test Entity Deletion" << std::endl;
|
||||||
|
std::cout << "dense A size: " << denseA.size() << ((denseA.size() == 9998) ? " Success" : " Failure") << std::endl;
|
||||||
|
std::cout << "dense B size: " << denseB.size() << ((denseB.size() == 3333) ? " Success" : " Failure") << std::endl;
|
||||||
|
std::cout << "dense C size: " << denseC.size() << ((denseC.size() == 3333) ? " Success" : " Failure") << std::endl;
|
||||||
|
std::cout << "Number of entities: " << SHEntityManager::GetEntityCount() << (SHEntityManager::GetEntityCount() == 9998 ? " Success" : " Failure") << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
std::cout << std::endl << "Test Entity Recreation" << std::endl;
|
||||||
|
EntityID id = SHEntityManager::CreateEntity<SHComponent_C>();
|
||||||
|
std::cout << "dense A size: " << denseA.size() << ((denseA.size() == 9998) ? " Success" : " Failure") << std::endl;
|
||||||
|
std::cout << "dense B size: " << denseB.size() << ((denseB.size() == 3333) ? " Success" : " Failure") << std::endl;
|
||||||
|
std::cout << "dense C size: " << denseC.size() << ((denseC.size() == 3334) ? " Success" : " Failure") << std::endl;
|
||||||
|
std::cout << "Entity ID: " << id << " EntityIndex: " << EntityHandleGenerator::GetIndex(id) << (EntityHandleGenerator::GetIndex(id) == 5001 ? " Success" : " Failure") << std::endl;
|
||||||
|
std::cout << "Number of entities: " << SHEntityManager::GetEntityCount() << (SHEntityManager::GetEntityCount() == 9999 ? " Success" : " Failure") << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
SHEntityManager::DestroyAllEntity();
|
||||||
|
std::cout << std::endl << "Check Destroy All Entity" << std::endl;
|
||||||
|
std::cout << "dense A size: " << denseA.size() << ((denseA.size() == 0) ? " Success" : " Failure") << std::endl;
|
||||||
|
std::cout << "dense B size: " << denseB.size() << ((denseB.size() == 0) ? " Success" : " Failure") << std::endl;
|
||||||
|
std::cout << "dense C size: " << denseC.size() << ((denseC.size() == 0) ? " Success" : " Failure") << std::endl;
|
||||||
|
std::cout << "Number of entities: " << SHEntityManager::GetEntityCount() << (SHEntityManager::GetEntityCount() == 0 ? " Success" : " Failure") << std::endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHECSUnitTest::TestSystemRoutine(void) noexcept
|
||||||
|
{
|
||||||
|
SHSystemManager::CreateSystem<SHTestSystem>();
|
||||||
|
SHSystemManager::CreateSystem<SHTestSystem>();
|
||||||
|
|
||||||
|
|
||||||
|
SHSystemManager::RegisterRoutine<SHTestSystem, SHTestSystem::SHTestRoutine>(1);
|
||||||
|
|
||||||
|
SHSystemManager::RunRoutines(false, 1.0 / 120.0);
|
||||||
|
|
||||||
|
SHSystemManager::Exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
class SHECSUnitTest
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SHECSUnitTest() = delete;
|
||||||
|
~SHECSUnitTest() = delete;
|
||||||
|
|
||||||
|
static void TestBasicEntityCreate(void) noexcept;
|
||||||
|
static void TestEntityCreateTemplate(void) noexcept;
|
||||||
|
static void TestEntityDestroy(void) noexcept;
|
||||||
|
static void TestSystemRoutine(void) noexcept;
|
||||||
|
|
||||||
|
static void TestAll(void) noexcept;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../Components/SHComponent.h"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
|
||||||
|
class SHComponent_A :public SHComponent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int value{};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class SHComponent_B :public SHComponent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
float x{};
|
||||||
|
float y{};
|
||||||
|
float z{};
|
||||||
|
};
|
||||||
|
|
||||||
|
class SHComponent_C :public SHComponent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string value{};
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include "../System/SHSystem.h"
|
||||||
|
#include "../System/SHSystemRoutine.h"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
|
||||||
|
class SHTestSystem : public SHSystem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SHTestSystem() {};
|
||||||
|
~SHTestSystem() {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::string test{ "Test system" };
|
||||||
|
|
||||||
|
void Init() {};
|
||||||
|
void Exit() {};
|
||||||
|
|
||||||
|
class SHTestRoutine : public SHSystemRoutine
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SHTestRoutine()
|
||||||
|
:SHSystemRoutine("Test System Routine", false) {}
|
||||||
|
|
||||||
|
|
||||||
|
virtual void Execute(double dt) noexcept
|
||||||
|
{
|
||||||
|
|
||||||
|
std::cout << GetName() << " System Version: " << GetSystem()->GetSystemVersion() << std::endl;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue