Skip to content

IEntityWorld.ForEachWithComponent Method

Definition

Namespace: Brine2D.ECS

Overloads
ForEachWithComponent<T>\(Action<Entity,T>\) Invokes action for every active entity that has the specified component type, passing both the entity and the resolved component. Uses an System.Buffers.ArrayPool<> snapshot internally so structural changes made inside the callback are safe.
ForEachWithComponent<T>\(Action<Entity>\) Invokes action for every active entity that has the specified component type. Uses an System.Buffers.ArrayPool<> snapshot internally so structural changes made inside the callback are safe.

IEntityWorld.ForEachWithComponent\<T>\(Action\<Entity,T\>\) Method

Invokes action for every active entity that has the specified component type, passing both the entity and the resolved component. Uses an System.Buffers.ArrayPool<> snapshot internally so structural changes made inside the callback are safe.

C#
void ForEachWithComponent<T>(System.Action<Brine2D.ECS.Entity,T> action)
    where T : Brine2D.ECS.Component;

Type parameters

T

Parameters

action System.Action<Entity,T>

Remarks

Prefer this over GetEntitiesWithComponent<T>() in per-frame loops to avoid allocating a new list each call. For systems that query the same set every frame, CreateCachedQuery<T1>() is more efficient still.

IEntityWorld.ForEachWithComponent\<T>\(Action\<Entity\>\) Method

Invokes action for every active entity that has the specified component type. Uses an System.Buffers.ArrayPool<> snapshot internally so structural changes made inside the callback are safe.

C#
void ForEachWithComponent<T>(System.Action<Brine2D.ECS.Entity> action)
    where T : Brine2D.ECS.Component;

Type parameters

T

Parameters

action System.Action<Entity>

Remarks

Prefer this over GetEntitiesWithComponent<T>() in per-frame loops to avoid allocating a new list each call. For systems that query the same set every frame, CreateCachedQuery<T1>() is more efficient still.