entity component API sorted
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <Aeon/Core/Events.hpp>
|
||||
#include <Aeon/Core/GameLayer.hpp>
|
||||
#include <Aeon/Input/Input.hpp>
|
||||
#include <Aeon/Entity/EntityController.hpp>
|
||||
|
||||
namespace Core
|
||||
{
|
||||
@@ -43,6 +44,7 @@ public:
|
||||
private:
|
||||
Display mDisplay;
|
||||
|
||||
EC::EntityController& mEntityController;
|
||||
Input::InputController& mInput;
|
||||
|
||||
// Game layers from z orderxko285132046
|
||||
|
||||
10
Aeon/Entity/CoreComponents/PositionComponent.hpp
Normal file
10
Aeon/Entity/CoreComponents/PositionComponent.hpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef AEON_ENTITY_CORECOMPONENTS_POSITIONCOMPONENT_H_
|
||||
#define AEON_ENTITY_CORECOMPONENTS_POSITIONCOMPONENT_H_
|
||||
|
||||
template <typename T, uint8_t D>
|
||||
struct Position
|
||||
{
|
||||
// Vector<D, T> data;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,12 +1,27 @@
|
||||
#ifndef AEON_ENTITY_ENTITY_H_
|
||||
#define AEON_ENTITY_ENTITY_H_
|
||||
|
||||
#include <Aeon/Includes.hpp>
|
||||
|
||||
namespace EC
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
struct Entity
|
||||
{
|
||||
uint32_t id;
|
||||
T id;
|
||||
|
||||
inline bool operator==( const Entity& rhs )
|
||||
{
|
||||
return rhs.id == id;
|
||||
}
|
||||
|
||||
inline bool operator!=( const Entity& rhs )
|
||||
{
|
||||
return rhs.id != id;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,57 @@
|
||||
#ifndef AEON_ENTITY_ENTITYCONTROLLER_H_
|
||||
#define AEON_ENTITY_ENTITYCONTROLLER_H_
|
||||
|
||||
#include <Aeon/Includes.hpp>
|
||||
|
||||
struct Entity;
|
||||
struct Component;
|
||||
|
||||
namespace EC
|
||||
{
|
||||
|
||||
// TODO: Entities space in memory should be pre-allocated
|
||||
// using the engine's lifecycle bump allocator
|
||||
class EntityRegistry
|
||||
{
|
||||
public:
|
||||
EntityRegistry();
|
||||
~EntityRegistry();
|
||||
|
||||
Entity& Create();
|
||||
Entity& Copy(const Entity& entity);
|
||||
Entity& Destroy(Entity& entity);
|
||||
bool Valid(const Entity& entity);
|
||||
|
||||
// add, replace components
|
||||
template <typename TComponent>
|
||||
TComponent& Add(const Entity& entity);
|
||||
|
||||
template <typename TComponent>
|
||||
TComponent& Replace(const Entity& entity);
|
||||
|
||||
// replace inplace
|
||||
template <typename TComponent>
|
||||
TComponent& Patch(const Entity& entity);
|
||||
|
||||
// Get component from entity based on T
|
||||
template <typename TComponent>
|
||||
TComponent& Get(const Entity& entity);
|
||||
|
||||
// Get std::optional from entity based on T
|
||||
template <typename TComponent>
|
||||
std::optional<TComponent&> Opt(const Entity& entity);
|
||||
|
||||
// TODO: Sort by component properties, for example list of
|
||||
// entities with the renderable components, sorted by Y pos
|
||||
// of position component
|
||||
// template <typename T>
|
||||
// std::vector<T&> Sort(std::function<;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,5 +19,7 @@ extern "C" {
|
||||
#include <iomanip>
|
||||
#include <tuple>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <functional>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,8 @@ file(GLOB EngineSource
|
||||
Aeon/*.cpp
|
||||
Aeon/Core/*.cpp
|
||||
Aeon/Debug/*.cpp
|
||||
Aeon/Entity/*.cpp
|
||||
Aeon/Entity/CoreComponents/*.cpp
|
||||
Aeon/Input/*.cpp
|
||||
Aeon/Maths/*.cpp
|
||||
Aeon/Rendering/*.cpp
|
||||
|
||||
Reference in New Issue
Block a user