SDK/Entity: Delay component removal until world update
Allows system to freely remove components while updating Former-commit-id: db5877bc20e6a0dfadd69f81a339f0a57d8404df [formerly 74327b8f1429855625613f258894b37d026041fe] [formerly 65b8f2ba78d2690b7a469d4b9818b189524633db [formerly 71be95adb46b7183261a8038352c4d8bd17cacc3]] Former-commit-id: ba91d5abad60792e648d47e646ae49d43a1c94b5 [formerly 8d0667574ff665e151e7fda5f854fc11a16c854d] Former-commit-id: eb7b06c2739ef698a153a6221870a8d0956dc875
This commit is contained in:
@@ -52,8 +52,8 @@ namespace Ndk
|
||||
inline bool IsEnabled() const;
|
||||
inline bool IsValid() const;
|
||||
|
||||
void RemoveAllComponents();
|
||||
void RemoveComponent(ComponentIndex index);
|
||||
inline void RemoveAllComponents();
|
||||
inline void RemoveComponent(ComponentIndex index);
|
||||
template<typename ComponentType> void RemoveComponent();
|
||||
|
||||
inline Nz::String ToString() const;
|
||||
@@ -67,6 +67,10 @@ namespace Ndk
|
||||
void Create();
|
||||
void Destroy();
|
||||
|
||||
void DestroyComponent(ComponentIndex index);
|
||||
|
||||
inline Nz::Bitset<>& GetRemovedComponentBits();
|
||||
|
||||
inline void RegisterSystem(SystemIndex index);
|
||||
|
||||
inline void SetWorld(World* world) noexcept;
|
||||
@@ -75,6 +79,7 @@ namespace Ndk
|
||||
|
||||
std::vector<std::unique_ptr<BaseComponent>> m_components;
|
||||
Nz::Bitset<> m_componentBits;
|
||||
Nz::Bitset<> m_removedComponentBits;
|
||||
Nz::Bitset<> m_systemBits;
|
||||
EntityId m_id;
|
||||
World* m_world;
|
||||
|
||||
@@ -103,12 +103,31 @@ namespace Ndk
|
||||
RemoveComponent(index);
|
||||
}
|
||||
|
||||
inline void Entity::RemoveAllComponents()
|
||||
{
|
||||
m_removedComponentBits = m_componentBits;
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
inline void Entity::RemoveComponent(ComponentIndex index)
|
||||
{
|
||||
m_removedComponentBits.UnboundedSet(index);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
inline Nz::String Entity::ToString() const
|
||||
{
|
||||
Nz::StringStream ss;
|
||||
return ss << "Entity(" << GetId() << ')';
|
||||
}
|
||||
|
||||
inline Nz::Bitset<>& Entity::GetRemovedComponentBits()
|
||||
{
|
||||
return m_removedComponentBits;
|
||||
}
|
||||
|
||||
inline void Entity::RegisterSystem(SystemIndex index)
|
||||
{
|
||||
m_systemBits.UnboundedSet(index);
|
||||
|
||||
Reference in New Issue
Block a user