Documentation for module 'NDK'

Former-commit-id: 63e1cac538c577a1f1aafa71fa7eef69a6d4daab [formerly b2d8769fd02a0e7d9c476d4ad7be1988a1fd6789] [formerly 636b5cb79bcb8da44d9aa45ba1023565bcf29f0d [formerly a2361ec2b8679d4d4ba096e543b5d4b91825dd62]]
Former-commit-id: d402d35477f9db0135c553d55c401939426bf62d [formerly 607336ea0f42731e4604f3a8c2df06f3aecfc401]
Former-commit-id: 69e23cd6c06723486de5e4641ce810012dac66da
This commit is contained in:
Gawaboumga
2016-08-21 13:48:52 +02:00
parent 42abd200be
commit 9eba331f34
75 changed files with 3374 additions and 112 deletions

View File

@@ -8,6 +8,18 @@
namespace Ndk
{
/*!
* \ingroup NDK
* \class Ndk::Entity
* \brief NDK class that represents an entity in a world
*/
/*!
* \brief Constructs a Entity object by move semantic
*
* \param entity Entity to move into this
*/
Entity::Entity(Entity&& entity) :
HandledObject(std::move(entity)),
m_components(std::move(entity.m_components)),
@@ -20,35 +32,57 @@ namespace Ndk
{
}
/*!
* \brief Constructs a Entity object linked to a world and with an id
*
* \param world World in which the entity interact
* \param id Identifier of the entity
*/
Entity::Entity(World* world, EntityId id) :
m_id(id),
m_world(world)
{
}
/*!
* \brief Destructs the object and calls Destroy
*
* \see Destroy
*/
Entity::~Entity()
{
Destroy();
}
/*!
* \brief Adds a component to the entity
* \return A reference to the newly added component
*
* \param componentPtr Component to add to the entity
*
* \remark Produces a NazaraAssert if component is nullptr
*/
BaseComponent& Entity::AddComponent(std::unique_ptr<BaseComponent>&& componentPtr)
{
NazaraAssert(componentPtr, "Component must be valid");
ComponentIndex index = componentPtr->GetIndex();
// Nous nous assurons que le vecteur de component est suffisamment grand pour contenir le nouveau component
// We ensure that the vector has enough space
if (index >= m_components.size())
m_components.resize(index + 1);
// Affectation et retour du component
// Affectation and return of the component
m_components[index] = std::move(componentPtr);
m_componentBits.UnboundedSet(index);
m_removedComponentBits.UnboundedReset(index);
Invalidate();
// On récupère le component et on informe les composants existants du nouvel arrivant
// We get the new component and we alert other existing components of the new one
BaseComponent& component = *m_components[index].get();
component.SetEntity(this);
@@ -61,34 +95,57 @@ namespace Ndk
return component;
}
/*!
* \brief Clones the entity
* \return The clone newly created
*
* \remark The close is enable by default, even if the original is disabled
* \remark Produces a NazaraAssert if the entity is not valid
*/
const EntityHandle& Entity::Clone() const
{
///DOC: The clone is enabled by default, even if the original entity is disabled
NazaraAssert(IsValid(), "Invalid entity");
return m_world->CloneEntity(m_id);
}
/*!
* \brief Kills the entity
*/
void Entity::Kill()
{
m_world->KillEntity(this);
}
/*!
* \brief Invalidates the entity
*/
void Entity::Invalidate()
{
// On informe le monde que nous avons besoin d'une mise à jour
// We alert everyone that we have been updated
m_world->Invalidate(m_id);
}
/*!
* \brief Creates the entity
*/
void Entity::Create()
{
m_enabled = true;
m_valid = true;
}
/*!
* \brief Destroys the entity
*/
void Entity::Destroy()
{
// On informe chaque système
// We alert each system
for (std::size_t index = m_systemBits.FindFirst(); index != m_systemBits.npos; index = m_systemBits.FindNext(index))
{
if (m_world->HasSystem(index))
@@ -104,12 +161,19 @@ namespace Ndk
m_valid = false;
}
/*!
* \brief Destroys a component by index
*
* \param index Index of the component
*
* \remark If component is not available, no action is performed
*/
void Entity::DestroyComponent(ComponentIndex index)
{
///DOC: N'a aucun effet si le component n'est pas présent
if (HasComponent(index))
{
// On récupère le component et on informe les composants du détachement
// We get the component and we alert existing components of the deleted one
BaseComponent& component = *m_components[index].get();
for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i))
{