Remade Entities

Former-commit-id: 25f7bc84279fdf58b44cf78e2d94b4cbb78a8410
This commit is contained in:
Lynix
2015-02-19 22:06:57 +01:00
parent 1d79efeb7f
commit 3a18035989
8 changed files with 361 additions and 107 deletions

View File

@@ -8,57 +8,50 @@
#define NDK_ENTITY_HPP
#include <NDK/Prerequesites.hpp>
#include <set>
namespace Ndk
{
class EntityHandle;
class World;
class NDK_API Entity
{
friend EntityHandle;
friend World;
public:
class Id;
using Id = nzUInt32;
Entity();
Entity(const Entity&) = default;
~Entity() = default;
Entity(const Entity&) = delete;
Entity(Entity&& entity);
~Entity();
void Kill();
EntityHandle CreateHandle();
Id GetId() const;
World* GetWorld() const;
void Kill();
bool IsValid() const;
Entity& operator=(const Entity&) = default;
bool operator==(const Entity& other) const;
bool operator!=(const Entity& other) const;
// Identifiant
struct Id
{
struct Part
{
nzUInt32 counter, index;
};
union
{
Part part;
nzUInt64 value;
};
bool operator==(const Id& other) const;
bool operator!=(const Id& other) const;
};
Entity& operator=(const Entity&) = delete;
Entity& operator=(Entity&&) = delete;
private:
Entity(Id id, World* world);
Entity(World& world, Id id);
void Create();
void Destroy();
void RegisterHandle(EntityHandle* handle);
void UnregisterHandle(EntityHandle* handle);
std::set<EntityHandle*> m_handles;
Id m_id;
World* m_world;
bool m_valid;
};
}