Skip to content

IEntityWorld.ForEachWithBehavior Method

Definition

Namespace: Brine2D.ECS

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

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

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

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

Type parameters

T

Parameters

action System.Action<Entity,T>

Remarks

Iterates the internal behavior list in O\(total behaviors\). For systems that query the same set every frame, consider a cached query with .WithBehavior<T>().

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

Invokes action for every active entity that has a behavior of type T. Uses an System.Buffers.ArrayPool<> snapshot so structural changes made inside the callback are safe.

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

Type parameters

T

Parameters

action System.Action<Entity>

Remarks

Iterates the internal behavior list in O\(total behaviors\). Prefer ForEachWithBehavior<T>\(Action<Entity,T>\) when you also need the behavior instance, to avoid a second lookup.