diff --git a/SDK/include/NDK/World.hpp b/SDK/include/NDK/World.hpp index d8bba2536..0759c12b0 100644 --- a/SDK/include/NDK/World.hpp +++ b/SDK/include/NDK/World.hpp @@ -20,7 +20,7 @@ namespace Ndk using EntityList = std::vector; World(); - ~World(); + ~World() = default; Entity CreateEntity(); EntityList CreateEntities(unsigned int count); @@ -46,4 +46,6 @@ namespace Ndk }; } +#include + #endif // NDK_WORLD_HPP diff --git a/SDK/include/NDK/World.inl b/SDK/include/NDK/World.inl new file mode 100644 index 000000000..75a8a14f3 --- /dev/null +++ b/SDK/include/NDK/World.inl @@ -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; + } +} diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index ae64967d3..936afb8e9 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -5,13 +5,6 @@ namespace Ndk { - World::World() : - m_nextIndex(0) - { - } - - World::~World() = default; - Entity World::CreateEntity() { Entity::Id id; @@ -41,15 +34,6 @@ namespace Ndk return entity; } - World::EntityList World::CreateEntities(unsigned int count) - { - EntityList list; - for (unsigned int i = 0; i < count; ++i) - list.push_back(CreateEntity()); - - return list; - } - void World::Clear() { ///DOC: Les handles existants avant Clear ne sont plus garantis de ne pas être réutilisés @@ -71,13 +55,6 @@ namespace Ndk m_killedEntities.push_back(entity); } - void World::KillEntities(EntityList& list) - { - m_killedEntities.reserve(m_killedEntities.size() + list.size()); - for (Entity& entity : list) - KillEntity(entity); - } - Entity World::GetEntity(Entity::Id id) { if (IsEntityIdValid(id)) @@ -89,20 +66,6 @@ namespace Ndk } } - 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()); - } - - 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; - } - void World::Update() { if (!m_killedEntities.empty())