Rework ECS framework
- Add queue systems when adding/removing components and systems - Add GlobalData to ECSManager, used to store data that is not specific to entities - Add View class, used to for loop all entities that contains the given Components - Rework how signaling works
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <typeindex>
|
||||
#include <vector>
|
||||
|
||||
namespace Copium
|
||||
{
|
||||
@@ -8,27 +9,37 @@ namespace Copium
|
||||
|
||||
class SystemOrderer
|
||||
{
|
||||
private:
|
||||
std::type_index systemId;
|
||||
SystemPool* systemPool = nullptr;
|
||||
|
||||
public:
|
||||
SystemOrderer(std::type_index systemId, SystemPool* systemPool);
|
||||
|
||||
template <typename Other>
|
||||
template <typename System>
|
||||
void Before()
|
||||
{
|
||||
Before(typeid(Other));
|
||||
orderQueue.emplace_back(OrderOperation::Before, typeid(System));
|
||||
}
|
||||
|
||||
template <typename Other>
|
||||
template <typename System>
|
||||
void After()
|
||||
{
|
||||
After(typeid(Other));
|
||||
orderQueue.emplace_back(OrderOperation::After, typeid(System));
|
||||
}
|
||||
|
||||
private:
|
||||
void Before(const std::type_index& otherSystemId);
|
||||
void After(const std::type_index& otherSystemId);
|
||||
enum class OrderOperation
|
||||
{
|
||||
Before,
|
||||
After
|
||||
};
|
||||
|
||||
std::type_index systemId;
|
||||
SystemPool* systemPool = nullptr;
|
||||
std::vector<std::pair<OrderOperation, std::type_index>> orderQueue;
|
||||
|
||||
private:
|
||||
friend class SystemPool;
|
||||
|
||||
void CommitOrdering();
|
||||
void CommitBefore(const std::type_index& otherSystemId);
|
||||
void CommitAfter(const std::type_index& otherSystemId);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user