Add ecs::accessor::contains(uuid)
This commit is contained in:
parent
b73a37deea
commit
e55a98c2a0
1 changed files with 14 additions and 0 deletions
|
|
@ -61,6 +61,15 @@ namespace psemek::ecs
|
||||||
template <typename Component>
|
template <typename Component>
|
||||||
bool contains() const;
|
bool contains() const;
|
||||||
|
|
||||||
|
/** Check if the entity contains this component type by uuid.
|
||||||
|
*
|
||||||
|
* @param uuid The uuid of the component
|
||||||
|
* @return True if the entity contains a component with the specified
|
||||||
|
* uuid, false otherwise
|
||||||
|
* @pre The accessor is valid
|
||||||
|
*/
|
||||||
|
bool contains(util::uuid const & uuid) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
detail::table * table_ = nullptr;
|
detail::table * table_ = nullptr;
|
||||||
std::uint32_t row_ = 0;
|
std::uint32_t row_ = 0;
|
||||||
|
|
@ -120,6 +129,11 @@ namespace psemek::ecs
|
||||||
return get_if<Component const>() != nullptr;
|
return get_if<Component const>() != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool accessor::contains(util::uuid const & uuid) const
|
||||||
|
{
|
||||||
|
return table_->column_index(uuid) != std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
inline accessor::accessor(detail::table * table, std::uint32_t row)
|
inline accessor::accessor(detail::table * table, std::uint32_t row)
|
||||||
: table_(table)
|
: table_(table)
|
||||||
, row_(row)
|
, row_(row)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue