Added const to some functions

This commit is contained in:
maverickdgg 2022-09-13 13:57:01 +08:00
parent 9c5a705bef
commit 8b8f0a076d
2 changed files with 23 additions and 11 deletions

View File

@ -28,7 +28,7 @@ namespace SHADE
//SHEntityManager::RemoveEntity(this->entityID);
}
EntityID SHEntity::GetEID() noexcept
EntityID SHEntity::GetEID()const noexcept
{
return this->entityID;
}
@ -39,6 +39,10 @@ namespace SHADE
SHComponentManager::SetActive(entityID, active);
}
bool SHEntity::GetActive(void) const noexcept
{
return isActive;
}
void SHEntity::SetParent(SHEntity* newParent) noexcept
@ -53,20 +57,20 @@ namespace SHADE
//TODO
}
SHEntity* SHEntity::GetParent() noexcept
SHEntity* SHEntity::GetParent()const noexcept
{
//TODO
return nullptr;
}
std::vector<SHEntity*>const& SHEntity::GetChildren() noexcept
std::vector<SHEntity*>const& SHEntity::GetChildren()const noexcept
{
//TODO
return std::vector<SHEntity*>{};
}
std::vector<EntityID>const& SHEntity::GetChildrenID() noexcept
std::vector<EntityID>const& SHEntity::GetChildrenID()const noexcept
{
return std::vector<EntityID>{};
}

View File

@ -63,7 +63,7 @@ namespace SHADE
* Returns nullptr if the entity does not have such Component.
***************************************************************************/
template<typename T>
std::enable_if_t<std::is_base_of_v<SHComponent, T>, T*> GetComponent() noexcept
std::enable_if_t<std::is_base_of_v<SHComponent, T>, T*> GetComponent()const noexcept
{
return SHComponentManager::GetComponent_s<T>(entityID);
@ -77,7 +77,7 @@ namespace SHADE
* \return uint32_t
* The entityID of this Entity object.
***************************************************************************/
EntityID GetEID() noexcept;
EntityID GetEID()const noexcept;
/*!*************************************************************************
* \brief Set the Active object
@ -91,6 +91,7 @@ namespace SHADE
***************************************************************************/
virtual void SetActive(bool active) noexcept;
bool GetActive(void)const noexcept;
/**************************************************************************
@ -124,7 +125,7 @@ namespace SHADE
* Returns a pointer to the parent entity.
* Returns a nullptr if the parent node is the root node.
***************************************************************************/
SHEntity* GetParent() noexcept;
SHEntity* GetParent()const noexcept;
/**************************************************************************
@ -133,7 +134,7 @@ namespace SHADE
* \return
* Return a vector of SHEntity pointers of the children belonging to this entity.
***************************************************************************/
std::vector<SHEntity*>const& GetChildren() noexcept;
std::vector<SHEntity*>const& GetChildren()const noexcept;
/**************************************************************************
* \brief
@ -141,11 +142,13 @@ namespace SHADE
* \return
* return a vector of EntityID of the children belonging to this entity.
***************************************************************************/
std::vector<EntityID>const& GetChildrenID() noexcept;
std::vector<EntityID>const& GetChildrenID()const noexcept;
//Name of the entity. This name is non-unique and only used for the editor.
std::string name;
bool isActive;
private:
@ -156,6 +159,11 @@ namespace SHADE
EntityID entityID;
//Entity active state. This should only be set using the SetActive function which will
//set the active state of all components of this entity.
bool isActive;
};
}