CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::ComponentMaskSet Class Reference

A object that manages a set of components masks. More...

#include <CeresEngine/Entity/Component.hpp>

Public Member Functions

const ComponentMaskget (const EntityIndex index) const noexcept
 Gets the current component mask for the given index.
 
bool has (const EntityIndex index, const ComponentMask &mask) const noexcept
 Checks if the entity at the given index contains all components in the given mask.
 
const ComponentMaskset (const EntityIndex index, const ComponentMask &mask) noexcept
 Sets a mask for the given index.
 
const ComponentMaskreset (const EntityIndex index) noexcept
 Removes all bits in the component mask of the given index.
 
const ComponentMaskadd (const EntityIndex index, const ComponentMask &mask) noexcept
 Adds a new set of components in the given mask to the given index.
 
const ComponentMaskremove (const EntityIndex index, const ComponentMask &mask) noexcept
 Removes a new set of components in the given mask from the given index.
 
std::size_t getSize () const noexcept
 

Private Attributes

Vector< ComponentMaskmComponentMasks
 A vector that stores the component masks indexed by an integer index.
 

Static Private Attributes

static constexpr ComponentMask emptyComponentMask = 0
 A default empty component mask used when returning an empty mask by reference.
 

Detailed Description

A object that manages a set of components masks.

Member Function Documentation

◆ add()

const ComponentMask & CeresEngine::ComponentMaskSet::add ( const EntityIndex  index,
const ComponentMask mask 
)
inlinenoexcept

Adds a new set of components in the given mask to the given index.

Parameters
indexThe index whose component mask should be updated by adding all bits in mask.
maskThe mask whose bits should be enabled. For any bits that are already enabled before calling this method they remain enabled.
Returns
The new value of the component mask for the given index.

◆ get()

const ComponentMask & CeresEngine::ComponentMaskSet::get ( const EntityIndex  index) const
inlinenoexcept

Gets the current component mask for the given index.

If no such mask exists for the given index, an empty mask is returned.

Parameters
indexThe entity index to retrieve the component mask for.
Returns
The current component mask.

◆ getSize()

std::size_t CeresEngine::ComponentMaskSet::getSize ( ) const
inlinenoexcept
Returns
The internal size used by the component mask set.

◆ has()

bool CeresEngine::ComponentMaskSet::has ( const EntityIndex  index,
const ComponentMask mask 
) const
inlinenoexcept

Checks if the entity at the given index contains all components in the given mask.

If no such mask exists for the given index, false is returned.

Parameters
indexThe entity index whose component mask is to be checked against.
maskThe component mask to be checked. All components in the mask must be present for this function to return true.
Returns
True if the index mask has all components in mask.

◆ remove()

const ComponentMask & CeresEngine::ComponentMaskSet::remove ( const EntityIndex  index,
const ComponentMask mask 
)
inlinenoexcept

Removes a new set of components in the given mask from the given index.

Parameters
indexThe index whose component mask should be updated by removing all bits in mask.
maskThe mask whose bits should be disabled. For any bits that are not already enabled before calling this method they remain disabled.
Returns
The new value of the component mask for the given index.

◆ reset()

const ComponentMask & CeresEngine::ComponentMaskSet::reset ( const EntityIndex  index)
inlinenoexcept

Removes all bits in the component mask of the given index.

Parameters
indexThe index whose component mask should be reset to all bits being off.
Returns
The new value of the component mask for the given index.

◆ set()

const ComponentMask & CeresEngine::ComponentMaskSet::set ( const EntityIndex  index,
const ComponentMask mask 
)
inlinenoexcept

Sets a mask for the given index.

Parameters
indexThe index to set a mask for. The internal storage will be automatically resized to fit.
maskThe mask to be set.
Returns
The new value of the component mask for the given index.

Member Data Documentation

◆ emptyComponentMask

constexpr ComponentMask CeresEngine::ComponentMaskSet::emptyComponentMask = 0
inlinestaticconstexprprivate

A default empty component mask used when returning an empty mask by reference.

◆ mComponentMasks

Vector<ComponentMask> CeresEngine::ComponentMaskSet::mComponentMasks
private

A vector that stores the component masks indexed by an integer index.


The documentation for this class was generated from the following file: