Sdk/Entity: Add enable/disable mechanism
Former-commit-id: 09884bdacf2b573bef516936d2580942cc5d4f66
This commit is contained in:
parent
4a71fb2922
commit
8adc0097df
|
|
@ -34,6 +34,8 @@ namespace Ndk
|
|||
|
||||
EntityHandle CreateHandle();
|
||||
|
||||
inline void Enable(bool enable);
|
||||
|
||||
inline BaseComponent& GetComponent(ComponentIndex index);
|
||||
template<typename ComponentType> ComponentType& GetComponent();
|
||||
inline const Nz::Bitset<>& GetComponentBits() const;
|
||||
|
|
@ -47,6 +49,7 @@ namespace Ndk
|
|||
void Kill();
|
||||
|
||||
void Invalidate();
|
||||
inline bool IsEnabled() const;
|
||||
inline bool IsValid() const;
|
||||
|
||||
void RemoveAllComponents();
|
||||
|
|
@ -73,6 +76,7 @@ namespace Ndk
|
|||
Nz::Bitset<> m_systemBits;
|
||||
EntityId m_id;
|
||||
World* m_world;
|
||||
bool m_enabled;
|
||||
bool m_valid;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,15 @@ namespace Ndk
|
|||
return static_cast<ComponentType&>(AddComponent(std::move(ptr)));
|
||||
}
|
||||
|
||||
inline void Entity::Enable(bool enable)
|
||||
{
|
||||
if (m_enabled != enable)
|
||||
{
|
||||
m_enabled = enable;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
inline BaseComponent& Entity::GetComponent(ComponentIndex index)
|
||||
{
|
||||
///DOC: Le component doit être présent
|
||||
|
|
@ -74,6 +83,11 @@ namespace Ndk
|
|||
return HasComponent(index);
|
||||
}
|
||||
|
||||
inline bool Entity::IsEnabled() const
|
||||
{
|
||||
return m_enabled;
|
||||
}
|
||||
|
||||
inline bool Entity::IsValid() const
|
||||
{
|
||||
return m_valid;
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ namespace Ndk
|
|||
|
||||
void Entity::Create()
|
||||
{
|
||||
m_enabled = true;
|
||||
m_valid = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ namespace Ndk
|
|||
|
||||
// Doit-elle en faire partie ?
|
||||
if (system->Filters(entity))
|
||||
if (entity->IsEnabled() && system->Filters(entity))
|
||||
{
|
||||
// L'entité doit faire partie du système, revalidons-là (événement système) ou ajoutons-la au système
|
||||
if (!partOfSystem)
|
||||
|
|
|
|||
Loading…
Reference in New Issue