Sdk/Entity: Add DropComponent method
This commit is contained in:
@@ -43,6 +43,10 @@ namespace Ndk
|
||||
const EntityHandle& Clone() const;
|
||||
|
||||
inline void Disable();
|
||||
|
||||
std::unique_ptr<BaseComponent> DropComponent(ComponentIndex index);
|
||||
template<typename ComponentType> std::unique_ptr<BaseComponent> DropComponent();
|
||||
|
||||
void Enable(bool enable = true);
|
||||
|
||||
inline BaseComponent& GetComponent(ComponentIndex index);
|
||||
@@ -83,8 +87,6 @@ namespace Ndk
|
||||
void Create();
|
||||
void Destroy();
|
||||
|
||||
void DestroyComponent(ComponentIndex index);
|
||||
|
||||
inline Nz::Bitset<>& GetRemovedComponentBits();
|
||||
|
||||
inline void RegisterEntityList(EntityList* list);
|
||||
|
||||
@@ -64,6 +64,15 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if component is not available in this entity
|
||||
*/
|
||||
|
||||
template<typename ComponentType>
|
||||
std::unique_ptr<BaseComponent> Entity::DropComponent()
|
||||
{
|
||||
static_assert(std::is_base_of<BaseComponent, ComponentType>::value, "ComponentType is not a component");
|
||||
|
||||
ComponentIndex index = GetComponentIndex<ComponentType>();
|
||||
return DropComponent(index);
|
||||
}
|
||||
|
||||
template<typename ComponentType>
|
||||
ComponentType& Entity::GetComponent()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user