Add generic handlers

Former-commit-id: 8fc343d3a056de8031cf453748b8801d50d3710e
This commit is contained in:
Lynix
2016-03-31 21:14:22 +02:00
parent a2f6e54104
commit a77ad42fcb
16 changed files with 542 additions and 423 deletions

View File

@@ -8,6 +8,7 @@
#define NDK_ENTITY_HPP
#include <Nazara/Core/Bitset.hpp>
#include <Nazara/Core/HandledObject.hpp>
#include <NDK/Algorithm.hpp>
#include <memory>
#include <vector>
@@ -15,13 +16,14 @@
namespace Ndk
{
class BaseComponent;
class EntityHandle;
class Entity;
class World;
class NDK_API Entity
using EntityHandle = Nz::ObjectHandle<Entity>;
class NDK_API Entity : public Nz::HandledObject<Entity>
{
friend class BaseSystem;
friend EntityHandle;
friend World;
public:
@@ -32,8 +34,6 @@ namespace Ndk
BaseComponent& AddComponent(std::unique_ptr<BaseComponent>&& component);
template<typename ComponentType, typename... Args> ComponentType& AddComponent(Args&&... args);
EntityHandle CreateHandle();
inline void Enable(bool enable);
inline BaseComponent& GetComponent(ComponentIndex index);
@@ -56,6 +56,8 @@ namespace Ndk
void RemoveComponent(ComponentIndex index);
template<typename ComponentType> void RemoveComponent();
inline Nz::String ToString() const;
Entity& operator=(const Entity&) = delete;
Entity& operator=(Entity&&) = delete;
@@ -65,16 +67,13 @@ namespace Ndk
void Create();
void Destroy();
inline void RegisterHandle(EntityHandle* handle);
inline void RegisterSystem(SystemIndex index);
inline void SetWorld(World* world) noexcept;
inline void UnregisterHandle(EntityHandle* handle);
inline void UnregisterSystem(SystemIndex index);
std::vector<std::unique_ptr<BaseComponent>> m_components;
std::vector<EntityHandle*> m_handles;
Nz::Bitset<> m_componentBits;
Nz::Bitset<> m_systemBits;
EntityId m_id;