struct ecs::TGroupCommon

template<u32 OwnedTypeCount, u32 IncludedTypeCount, u32 ExcludedTypeCount>
Inherits: GroupCommon

Provides helper functionality for owning groups.

Template parameters

OwnedTypeCount

Number of types owned by the group. All owned types will be sorted and tightly packed in their respective storage so they may be quickly iterated over.

IncludedTypeCount

Number of types in the included type filter.

ExcludedTypeCount

Number of types in the excluded type filter.

Public

Methods

~TGroupCommon<OwnedTypeCount, IncludedTypeCount, ExcludedTypeCount>

~TGroupCommon<OwnedTypeCount, IncludedTypeCount, ExcludedTypeCount>()

Size

u64 Size() const

Returns the number of entities in the group.

OwnsType

bool OwnsType(TypeHash elementTypeHash) const override

Checks if the provided type hash is an element type of one of the owned storage types.

~TGroupCommon<0, IncludedTypeCount, ExcludedTypeCount>

~TGroupCommon<0, IncludedTypeCount, ExcludedTypeCount>()

GetGroupStorage

Returns a set of entities that match the group filters.

GetGroupStorage

const TSparseSet<SparseSetDeletePolicy::SwapAndErase> &GetGroupStorage() const

~GroupCommon

virtual ~GroupCommon() = default

Private

Methods

SwapEntry

void SwapEntry(u64 packedIndex, Entity entity)

Swaps locations of two entities and their associated components in all owned storages.

packedIndex
Packed index of the entity to swap from.
entity
Entity to swap to.

TryAddEntryToGroupAfterAdd

void TryAddEntryToGroupAfterAdd(Entity entity)

Checks if the entity passes the group filter, and if so adds the entity to the packed entity list.

This should be called whenever an entity is added to any referenced storage types, so we can check if the entity was added to the included type storage.

TryAddEntryToGroupBeforeRemove

void TryAddEntryToGroupBeforeRemove(Entity entity)

Checks if the entity passes the group filter, and if so adds the entity to the packed entity list.

This should be called whenever an entity is removed from any referenced storage types, so we can check if the entity has been removed from the last excluded storage.

TryRemoveFromGroup

void TryRemoveFromGroup(Entity entity)

Removes an entity from the list of packed group entities.

TryAddEntryToGroupAfterAdd

void TryAddEntryToGroupAfterAdd(Entity entity)

Checks if the entity passes the group filter, and if so adds the entity to the packed entity list.

This should be called whenever an entity is added to any referenced storage types, so we can check if the entity was added to the included type storage.

TryAddEntryToGroupBeforeRemove

void TryAddEntryToGroupBeforeRemove(Entity entity)

Checks if the entity passes the group filter, and if so adds the entity to the packed entity list.

This should be called whenever an entity is removed from any referenced storage types, so we can check if the entity has been removed from the last excluded storage.

TryRemoveFromGroup

void TryRemoveFromGroup(Entity entity)

Removes an entity from the list of packed group entities.

Fields

mIncludedTypeStorage

std::array<SparseSet *, OwnedTypeCount + IncludedTypeCount> mIncludedTypeStorage

mExcludedTypeStorage

std::array<SparseSet *, ExcludedTypeCount> mExcludedTypeStorage

mEventHandles

std::array<THEvent<ThreadUnsafe>, (OwnedTypeCount + IncludedTypeCount + ExcludedTypeCount) * 2> mEventHandles

mNextIndex

u64 mNextIndex

mIncludedTypeStorage

std::array<SparseSet *, IncludedTypeCount> mIncludedTypeStorage

mExcludedTypeStorage

std::array<SparseSet *, ExcludedTypeCount> mExcludedTypeStorage

mEventHandles

std::array<THEvent<ThreadUnsafe>, (IncludedTypeCount + ExcludedTypeCount) * 2> mEventHandles

mGroupEntities