Table of Contents

Class EntityManagerExtensions

Namespace
RisingV.Shared.Extensions
Assembly
RisingV.Shared.dll

Provides extension methods for the Unity.Entities.EntityManager class.

public static class EntityManagerExtensions
Inheritance
EntityManagerExtensions
Inherited Members

Methods

GetBufferInternal<T>(EntityManager, Entity)

Gets the component data of type T from the specified entity.

public static List<T>? GetBufferInternal<T>(this EntityManager entityManager, Entity entity) where T : struct

Parameters

entityManager EntityManager

The Unity.Entities.EntityManager instance.

entity Entity

The entity to check.

Returns

List<T>

Type Parameters

T

The type of the component to check for.

GetComponentDataAOT<T>(EntityManager, Entity)

Get ComponentData AOT of type T from the specified entity.

public static T GetComponentDataAOT<T>(this EntityManager em, Entity entity) where T : unmanaged

Parameters

em EntityManager

The Unity.Entities.EntityManager instance.

entity Entity

The entity to check.

Returns

T

The component data of type T if it exists, otherwise default value.

Type Parameters

T

The type of the component to check for, must be unmanaged.

GetComponentDataOrDefault<T>(EntityManager, Entity, out T?)

Gets the component data of type T from the specified entity.

public static bool GetComponentDataOrDefault<T>(this EntityManager entityManager, Entity entity, out T? value) where T : new()

Parameters

entityManager EntityManager

The Unity.Entities.EntityManager instance.

entity Entity

The entity to check.

value T

The output parameter to hold the component data if it exists.

Returns

bool

Type Parameters

T

The type of the component to check for.

GetEntitiesByComponentType<T1>(EntityManager, EntityQueryOptions, bool)

Gets all entities that have a component of type T1.

public static NativeArray<Entity> GetEntitiesByComponentType<T1>(this EntityManager em, EntityQueryOptions queryOption = EntityQueryOptions.Default, bool includeAll = false)

Parameters

em EntityManager

The Unity.Entities.EntityManager instance.

queryOption EntityQueryOptions

The options for the entity query.

includeAll bool

Whether to include all entities or only those that match the specified component type.

Returns

NativeArray<Entity>

A Unity.Collections.NativeArray<T> containing all entities that have the specified component type.

Type Parameters

T1

The type of the component to query for.

GetEntitiesByComponentTypes<T1, T2>(EntityManager, EntityQueryOptions, bool)

Gets all entities that have components of type T1 and T2.

public static NativeArray<Entity> GetEntitiesByComponentTypes<T1, T2>(this EntityManager em, EntityQueryOptions queryOption = EntityQueryOptions.Default, bool includeAll = false)

Parameters

em EntityManager

The Unity.Entities.EntityManager instance.

queryOption EntityQueryOptions

The options for the entity query.

includeAll bool

Whether to include all entities or only those that match the specified component types.

Returns

NativeArray<Entity>

A Unity.Collections.NativeArray<T> containing all entities that have the specified component types.

Type Parameters

T1

The type of the first component to query for.

T2

The type of the second component to query for.

GetEntitiesByComponentTypes<T1, T2, T3>(EntityManager, EntityQueryOptions, bool)

Gets all entities that have components of type T1, T2, and T3.

public static NativeArray<Entity> GetEntitiesByComponentTypes<T1, T2, T3>(this EntityManager em, EntityQueryOptions queryOption = EntityQueryOptions.Default, bool includeAll = false)

Parameters

em EntityManager

The Unity.Entities.EntityManager instance.

queryOption EntityQueryOptions

The options for the entity query.

includeAll bool

Whether to include all entities or only those that match the specified component types.

Returns

NativeArray<Entity>

A Unity.Collections.NativeArray<T> containing all entities that have the specified component types.

Type Parameters

T1

The type of the first component to query for.

T2

The type of the second component to query for.

T3

The type of the third component to query for.

GetEntityByNetworkId(EntityManager, NetworkId)

Gets all entities that have a component network ID.

public static Entity GetEntityByNetworkId(this EntityManager em, NetworkId networkId)

Parameters

em EntityManager

The Unity.Entities.EntityManager instance.

networkId NetworkId

The network ID to search for.

Returns

Entity

GetEntityByNetworkId(EntityManager, ulong)

Gets the entity associated with the specified unpacked network ID.

public static Entity GetEntityByNetworkId(this EntityManager em, ulong unpackedNetworkId)

Parameters

em EntityManager

The Unity.Entities.EntityManager instance.

unpackedNetworkId ulong

The unpacked network ID to search for.

Returns

Entity

HasComponent<T>(EntityManager, Entity)

Checks if the specified entity has a component of type T.

public static bool HasComponent<T>(this EntityManager entityManager, Entity entity)

Parameters

entityManager EntityManager

The Unity.Entities.EntityManager instance.

entity Entity

The entity to check.

Returns

bool

True if the entity has the component, otherwise false.

Type Parameters

T

The type of the component to check for.