Viewport controls

This commit is contained in:
Dynamitos
2022-11-17 16:47:42 +01:00
parent f635ee2100
commit 4ba0bf3b45
73 changed files with 627 additions and 449 deletions
+47
View File
@@ -0,0 +1,47 @@
#pragma once
#include <entt/entt.hpp>
#include <thread_pool/thread_pool.h>
#include "Component/Component.h"
namespace Seele
{
namespace System
{
template<typename... Components>
class SystemBase
{
public:
SystemBase(entt::registry& registry) : registry(registry) {}
virtual ~SystemBase() {}
template<typename Comp>
auto getDependencies()
{
return Comp::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([&](){
int ret = (accessComponent(deps) + ...);
assert(ret == 0);
update((comp,...));
//});
});
}
void run(dp::thread_pool<>& pool)
{
setupView(mergeDependencies((getDependencies<Components>(),...)), pool);
}
virtual void update(Components&... components) = 0;
private:
entt::registry& registry;
};
} // namespace System
} // namespace Seele