(World) Replaced pointers to Entity by EntityHandle
Former-commit-id: b29aaaa7362c0c816dc270e15ba5f8253717c457
This commit is contained in:
parent
924d10e61c
commit
6201183572
|
|
@ -30,12 +30,12 @@ namespace Ndk
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
void KillEntity(Entity* entity);
|
void KillEntity(EntityHandle entity);
|
||||||
void KillEntities(const EntityList& list);
|
void KillEntities(const EntityList& list);
|
||||||
|
|
||||||
Entity* GetEntity(Entity::Id id);
|
EntityHandle GetEntity(Entity::Id id);
|
||||||
|
|
||||||
bool IsEntityValid(Entity* entity) const;
|
bool IsEntityValid(EntityHandle entity) const;
|
||||||
bool IsEntityIdValid(Entity::Id id) const;
|
bool IsEntityIdValid(Entity::Id id) const;
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ namespace Ndk
|
||||||
KillEntity(entity);
|
KillEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool World::IsEntityValid(Entity* entity) const
|
inline bool World::IsEntityValid(EntityHandle entity) const
|
||||||
{
|
{
|
||||||
return entity != nullptr && entity->GetWorld() == this && IsEntityIdValid(entity->GetId());
|
return entity.IsValid() && entity->GetWorld() == this && IsEntityIdValid(entity->GetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool World::IsEntityIdValid(Entity::Id id) const
|
inline bool World::IsEntityIdValid(Entity::Id id) const
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ namespace Ndk
|
||||||
|
|
||||||
void Entity::Kill()
|
void Entity::Kill()
|
||||||
{
|
{
|
||||||
m_world->KillEntity(this);
|
m_world->KillEntity(CreateHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entity::IsValid() const
|
bool Entity::IsValid() const
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ namespace Ndk
|
||||||
m_killedEntities.clear();
|
m_killedEntities.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::KillEntity(Entity* entity)
|
void World::KillEntity(EntityHandle entity)
|
||||||
{
|
{
|
||||||
///DOC: Ignoré si l'entité est invalide
|
///DOC: Ignoré si l'entité est invalide
|
||||||
|
|
||||||
|
|
@ -58,14 +58,14 @@ namespace Ndk
|
||||||
m_killedEntities.emplace_back(entity);
|
m_killedEntities.emplace_back(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity* World::GetEntity(Entity::Id id)
|
EntityHandle World::GetEntity(Entity::Id id)
|
||||||
{
|
{
|
||||||
if (IsEntityIdValid(id))
|
if (IsEntityIdValid(id))
|
||||||
return &m_entities[id];
|
return m_entities[id].CreateHandle();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NazaraError("Invalid ID");
|
NazaraError("Invalid ID");
|
||||||
return nullptr;
|
return EntityHandle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue