Implemented basic game dll interaction

This commit is contained in:
Dynamitos
2023-01-29 18:58:59 +01:00
parent 2208ab438a
commit 0dce84459e
72 changed files with 1297 additions and 350 deletions
+7 -2
View File
@@ -1,11 +1,16 @@
target_sources(Engine
PRIVATE
ComponentSystem.h
Executor.h
Executor.cpp
SystemBase.h)
SystemBase.h
SystemGraph.h
SystemGraph.cpp)
target_sources(Engine
PUBLIC FILE_SET HEADERS
FILES
ComponentSystem.h
Executor.h
SystemBase.h)
SystemBase.h
SystemGraph.h)
+57
View File
@@ -0,0 +1,57 @@
#pragma once
#include "SystemBase.h"
#include "Component/Component.h"
namespace Seele
{
namespace System
{
template<typename... Components>
class ComponentSystem : public SystemBase
{
public:
ComponentSystem(PScene scene) : SystemBase(scene) {}
virtual ~ComponentSystem() {}
template<is_component Comp>
auto getDependencies()
{
return Comp::dependencies;
}
template<typename Comp>
Dependencies<> getDependencies()
{
return Dependencies<>();
}
template<typename... Dep>
auto mergeDependencies(Dep... deps)
{
return (deps | ...);
}
template<typename... Deps>
void setupView(Dependencies<Deps...>, dp::thread_pool<>&)
{
registry.view<Components..., Deps...>().each([&](Components&... comp, Deps&... deps){
//pool.enqueue_detach([&](){
(accessComponent(deps) + ...);
update((comp,...));
//});
});
}
template<>
void setupView(Dependencies<>, dp::thread_pool<>&)
{
registry.view<Components...>().each([&](Components&... comp){
//pool.enqueue_detach([&](){
update(comp...);
//});
});
}
virtual void run(dp::thread_pool<>& pool, double delta) override
{
SystemBase::run(pool, delta);
setupView(mergeDependencies((getDependencies<Components>(),...)), pool);
}
virtual void update(Components&... components) = 0;
};
} // namespace System
} // namespace Seele
+10 -45
View File
@@ -1,63 +1,28 @@
#pragma once
#include <entt/entt.hpp>
#include <thread_pool/thread_pool.h>
#include "Component/Component.h"
#include <entt/entt.hpp>
#include "Scene/Scene.h"
namespace Seele
{
namespace System
{
template<typename... Components>
class SystemBase
class SystemBase
{
public:
SystemBase(entt::registry& registry) : registry(registry) {}
SystemBase(PScene scene) : registry(scene->registry), scene(scene) {}
virtual ~SystemBase() {}
template<is_component Comp>
auto getDependencies()
{
return Comp::dependencies;
}
template<typename Comp>
Dependencies<> getDependencies()
{
return Dependencies<>();
}
template<typename... Dep>
auto mergeDependencies(Dep... deps)
{
return (deps | ...);
}
template<typename... Deps>
void setupView(Dependencies<Deps...>, dp::thread_pool<>&)
{
registry.view<Components..., Deps...>().each([&](Components&... comp, Deps&... deps){
//pool.enqueue_detach([&](){
(accessComponent(deps) + ...);
update((comp,...));
//});
});
}
template<>
void setupView(Dependencies<>, dp::thread_pool<>&)
{
registry.view<Components...>().each([&](Components&... comp){
//pool.enqueue_detach([&](){
update(comp...);
//});
});
}
void run(dp::thread_pool<>& pool, double delta)
virtual void run(dp::thread_pool<>& pool, double delta)
{
deltaTime = delta;
setupView(mergeDependencies((getDependencies<Components>(),...)), pool);
update();
}
virtual void update(Components&... components) = 0;
virtual void update() {}
protected:
double deltaTime;
private:
entt::registry& registry;
PScene scene;
};
DEFINE_REF(SystemBase)
} // namespace System
} // namespace Seele
} // namespace Seele
+15
View File
@@ -0,0 +1,15 @@
#include "SystemGraph.h"
using namespace Seele;
void SystemGraph::addSystem(System::UPSystemBase system)
{
systems.add(std::move(system));
}
void SystemGraph::run(dp::thread_pool<>& threadPool, float deltaTime)
{
for(auto& system : systems) {
system->run(threadPool, deltaTime);
}
}
+16
View File
@@ -0,0 +1,16 @@
#pragma once
#include "Containers/Array.h"
#include "SystemBase.h"
namespace Seele
{
class SystemGraph
{
public:
void addSystem(System::UPSystemBase system);
void run(dp::thread_pool<>& threadPool, float deltaTime);
private:
Array<System::UPSystemBase> systems;
};
DEFINE_REF(SystemGraph)
} // namespace Seele;