Sdk/World: Add const getters for systems
This commit is contained in:
parent
ae2fd0069a
commit
e99d34f195
|
|
@ -120,6 +120,7 @@ Nazara Development Kit:
|
|||
- CollisionComponent[2D|3D] and PhysicsComponent[2D|3D] now configures their internal RigidBody userdata to the entity ID they belong to (useful for callbacks).
|
||||
- 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
|
||||
|
||||
# 0.4:
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,9 @@ namespace Ndk
|
|||
inline const EntityList& GetEntities() const;
|
||||
inline const ProfilerData& GetProfilerData() const;
|
||||
inline BaseSystem& GetSystem(SystemIndex index);
|
||||
inline const BaseSystem& GetSystem(SystemIndex index) const;
|
||||
template<typename SystemType> SystemType& GetSystem();
|
||||
template<typename SystemType> const SystemType& GetSystem() const;
|
||||
|
||||
inline bool HasSystem(SystemIndex index) const;
|
||||
template<typename SystemType> bool HasSystem() const;
|
||||
|
|
|
|||
|
|
@ -177,9 +177,8 @@ namespace Ndk
|
|||
*
|
||||
* \param index Index of the system
|
||||
*
|
||||
* \remark Produces a NazaraAssert if system is not available in this world
|
||||
* \remark The world must have the system before calling this function
|
||||
*/
|
||||
|
||||
inline BaseSystem& World::GetSystem(SystemIndex index)
|
||||
{
|
||||
NazaraAssert(HasSystem(index), "This system is not part of the world");
|
||||
|
|
@ -190,13 +189,30 @@ namespace Ndk
|
|||
return *system;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets a system in the world by index
|
||||
* \return A const reference to the system
|
||||
*
|
||||
* \param index Index of the system
|
||||
*
|
||||
* \remark The world must have the system before calling this function
|
||||
*/
|
||||
inline const BaseSystem& World::GetSystem(SystemIndex index) const
|
||||
{
|
||||
NazaraAssert(HasSystem(index), "This system is not part of the world");
|
||||
|
||||
const BaseSystem* system = m_systems[index].get();
|
||||
NazaraAssert(system, "Invalid system pointer");
|
||||
|
||||
return *system;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets a system in the world by type
|
||||
* \return A reference to the system
|
||||
*
|
||||
* \remark Produces a NazaraAssert if system is not available in this world
|
||||
*/
|
||||
|
||||
template<typename SystemType>
|
||||
SystemType& World::GetSystem()
|
||||
{
|
||||
|
|
@ -206,6 +222,21 @@ namespace Ndk
|
|||
return static_cast<SystemType&>(GetSystem(index));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets a system in the world by type
|
||||
* \return A const reference to the system
|
||||
*
|
||||
* \remark Produces a NazaraAssert if system is not available in this world
|
||||
*/
|
||||
template<typename SystemType>
|
||||
const SystemType& World::GetSystem() const
|
||||
{
|
||||
static_assert(std::is_base_of<BaseSystem, SystemType>::value, "SystemType is not a system");
|
||||
|
||||
SystemIndex index = GetSystemIndex<SystemType>();
|
||||
return static_cast<const SystemType&>(GetSystem(index));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether or not a system is present in the world by index
|
||||
* \return true If it is the case
|
||||
|
|
|
|||
Loading…
Reference in New Issue