Skip to content

Entity.CollectDescendants(List) Method

Definition

Namespace: Brine2D.ECS

Appends all descendant entities into results via iterative depth-first traversal. Avoids allocating the result collection; use a pre-allocated or reused System.Collections.Generic.List<> to reduce per-call heap pressure.

C#
public void CollectDescendants(System.Collections.Generic.List<Brine2D.ECS.Entity> results);

Parameters

results System.Collections.Generic.List<Entity>

The list to append descendants into. Not cleared by this method.

Remarks

Prefer this over GetDescendants() in hot paths \(e\.g\., per\-frame scene\-graph walks\) to avoid allocating a new list each call. Clear and reuse results across calls. Note that traversal still allocates a System.Collections.Generic.Stack<> internally for non-trivial hierarchies, so this method is not fully allocation-free.