Sdk/World: Add ForEachSystem method
This commit is contained in:
parent
e99d34f195
commit
e299e1f03e
|
|
@ -121,6 +121,7 @@ Nazara Development Kit:
|
|||
- Fixed EntityList copy/movement assignment operator which was not properly unregistering contained entities.
|
||||
- ListenerSystem now handles velocity in a generic way (no longer require a VelocityComponent and is compatible with physics)
|
||||
- World now has const getters for systems
|
||||
- Add World::ForEachSystem method, allowing iteration on every active system on a specific world
|
||||
|
||||
# 0.4:
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@ namespace Ndk
|
|||
inline void DisableProfiler();
|
||||
inline void EnableProfiler(bool enable = true);
|
||||
|
||||
template<typename F> void ForEachSystem(const F& iterationFunc);
|
||||
template<typename F> void ForEachSystem(const F& iterationFunc) const;
|
||||
|
||||
inline const EntityHandle& GetEntity(EntityId id);
|
||||
inline const EntityList& GetEntities() const;
|
||||
inline const ProfilerData& GetProfilerData() const;
|
||||
|
|
|
|||
|
|
@ -133,6 +133,40 @@ namespace Ndk
|
|||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Executes a function on every present system
|
||||
*
|
||||
* Calls iterationFunc on every previously added system, in the same order as their indexes
|
||||
*
|
||||
* \param iterationFunc Function to be called
|
||||
*/
|
||||
template<typename F>
|
||||
void World::ForEachSystem(const F& iterationFunc)
|
||||
{
|
||||
for (const auto& systemPtr : m_systems)
|
||||
{
|
||||
if (systemPtr)
|
||||
iterationFunc(*systemPtr);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Executes a function on every present system
|
||||
*
|
||||
* Calls iterationFunc on every previously added system, in the same order as their indexes
|
||||
*
|
||||
* \param iterationFunc Function to be called
|
||||
*/
|
||||
template<typename F>
|
||||
void World::ForEachSystem(const F& iterationFunc) const
|
||||
{
|
||||
for (const auto& systemPtr : m_systems)
|
||||
{
|
||||
if (systemPtr)
|
||||
iterationFunc(static_cast<const Ndk::BaseSystem&>(*systemPtr)); //< Force const reference
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets an entity
|
||||
* \return A constant reference to a handle of the entity
|
||||
|
|
@ -392,7 +426,7 @@ namespace Ndk
|
|||
m_orderedSystems = std::move(world.m_orderedSystems);
|
||||
m_orderedSystemsUpdated = world.m_orderedSystemsUpdated;
|
||||
m_profilerData = std::move(world.m_profilerData);
|
||||
m_isProfilerEnabled = world.m_isProfilerEnabled;
|
||||
m_isProfilerEnabled = m_isProfilerEnabled;
|
||||
|
||||
m_entities = std::move(world.m_entities);
|
||||
for (EntityBlock& block : m_entities)
|
||||
|
|
|
|||
Loading…
Reference in New Issue