diff --git a/SDK/include/NDK/Entity.hpp b/SDK/include/NDK/Entity.hpp index f2febee51..c7ab78bf5 100644 --- a/SDK/include/NDK/Entity.hpp +++ b/SDK/include/NDK/Entity.hpp @@ -34,6 +34,8 @@ namespace Ndk EntityHandle CreateHandle(); + inline void Enable(bool enable); + inline BaseComponent& GetComponent(ComponentIndex index); template 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; }; } diff --git a/SDK/include/NDK/Entity.inl b/SDK/include/NDK/Entity.inl index d30f58530..f185a4b0d 100644 --- a/SDK/include/NDK/Entity.inl +++ b/SDK/include/NDK/Entity.inl @@ -19,6 +19,15 @@ namespace Ndk return static_cast(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; diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index 42ecf36b1..4c0ebfb12 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -114,6 +114,7 @@ namespace Ndk void Entity::Create() { + m_enabled = true; m_valid = true; } diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index 7ee1fde49..8d318ace2 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -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)