SDK/ParticleGroupComponent: Add [Add|Remove]Emitter methods taking an entity

The entity must have a ParticleEmitterComponent


Former-commit-id: da22fc8252c42be7661808ffab5f1d8ff6ccc4ae [formerly 5d0c352f695f14ddb069115e933322bf47c1fda2] [formerly f591cdff659b524ec7bcdb0bfd04392731e1e80b [formerly 354da841577784c89f4a72522c116d12ce0feb10]]
Former-commit-id: d588fc973d59ee90afc589b9d0cc3e80d308a074 [formerly 2732590a051ca851b9681e9c70e238aab3bba247]
Former-commit-id: 96537373e3d143e49dd83c7dc5d70cc3fd28a3fc
This commit is contained in:
Lynix 2016-08-10 22:52:29 +02:00
parent e0fa458f40
commit 279597b675
2 changed files with 28 additions and 1 deletions

View File

@ -25,6 +25,12 @@ namespace Ndk
ParticleGroupComponent(const ParticleGroupComponent&) = default; ParticleGroupComponent(const ParticleGroupComponent&) = default;
~ParticleGroupComponent() = default; ~ParticleGroupComponent() = default;
void AddEmitter(Entity* emitter);
using ParticleGroup::AddEmitter;
void RemoveEmitter(Entity* emitter);
using ParticleGroup::RemoveEmitter;
static ComponentIndex componentIndex; static ComponentIndex componentIndex;
}; };
} }

View File

@ -1,8 +1,11 @@
#include "ParticleGroupComponent.hpp"
// Copyright (C) 2015 Jérôme Leclercq // Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Development Kit" // This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp // For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <NDK/Components/ParticleGroupComponent.hpp>
#include <NDK/Components/ParticleEmitterComponent.hpp>
#include <Nazara/Core/Error.hpp>
namespace Ndk namespace Ndk
{ {
inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout) : inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout) :
@ -14,4 +17,22 @@ namespace Ndk
ParticleGroup(maxParticleCount, std::move(declaration)) ParticleGroup(maxParticleCount, std::move(declaration))
{ {
} }
inline void ParticleGroupComponent::AddEmitter(Entity* emitter)
{
NazaraAssert(emitter && emitter->IsValid(), "Invalid entity");
NazaraAssert(emitter->HasComponent<ParticleEmitterComponent>(), "Entity must have a NodeComponent");
auto& emitterComponent = emitter->GetComponent<ParticleEmitterComponent>();
ParticleGroup::AddEmitter(&emitterComponent);
}
inline void ParticleGroupComponent::RemoveEmitter(Entity* emitter)
{
NazaraAssert(emitter && emitter->IsValid(), "Invalid entity");
NazaraAssert(emitter->HasComponent<ParticleEmitterComponent>(), "Entity must have a NodeComponent");
auto& emitterComponent = emitter->GetComponent<ParticleEmitterComponent>();
ParticleGroup::RemoveEmitter(&emitterComponent);
}
} }