(World) Inlined some methods
Former-commit-id: eab086bdde8b11cc261faf2cb5d161bbfcebdc73
This commit is contained in:
@@ -20,7 +20,7 @@ namespace Ndk
|
||||
using EntityList = std::vector<Entity>;
|
||||
|
||||
World();
|
||||
~World();
|
||||
~World() = default;
|
||||
|
||||
Entity CreateEntity();
|
||||
EntityList CreateEntities(unsigned int count);
|
||||
@@ -46,4 +46,6 @@ namespace Ndk
|
||||
};
|
||||
}
|
||||
|
||||
#include <NDK/World.inl>
|
||||
|
||||
#endif // NDK_WORLD_HPP
|
||||
|
||||
41
SDK/include/NDK/World.inl
Normal file
41
SDK/include/NDK/World.inl
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
inline World::World() :
|
||||
m_nextIndex(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline World::EntityList World::CreateEntities(unsigned int count)
|
||||
{
|
||||
EntityList list;
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
list.push_back(CreateEntity());
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
inline void World::KillEntities(EntityList& list)
|
||||
{
|
||||
m_killedEntities.reserve(m_killedEntities.size() + list.size());
|
||||
for (Entity& entity : list)
|
||||
KillEntity(entity);
|
||||
}
|
||||
|
||||
inline bool World::IsEntityValid(const Entity& entity) const
|
||||
{
|
||||
///DOC: Cette méthode vérifie également l'appartenance de l'entité au monde (et est donc plus sûre)
|
||||
return entity.GetWorld() == this && IsEntityIdValid(entity.GetId());
|
||||
}
|
||||
|
||||
inline bool World::IsEntityIdValid(Entity::Id id) const
|
||||
{
|
||||
///DOC: Il est possible que si l'identifiant vienne d'un autre monde, il soit considéré valide
|
||||
/// alors qu'aucune entité de ce monde-ci ne l'utilise (encore)
|
||||
|
||||
return m_entitiesCounter[id.part.index] == id.part.counter;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user