Skip to content

EntityPrefab.AddBehavior(Action) Method

Definition

Namespace: Brine2D.ECS

Adds a behavior of the specified type. The behavior is created with dependency injection when the prefab is instantiated.

C#
public Brine2D.ECS.EntityPrefab AddBehavior<T>(System.Action<T>? configure=null)
    where T : Brine2D.ECS.Behavior;

Type parameters

T

Parameters

configure System.Action<T>

Optional action invoked after the behavior is constructed but before OnAdded() is called, so configured values are available during attachment. Pass null to skip configuration.

Returns

EntityPrefab

Example

C#
prefab.AddBehavior<EnemyAIBehavior>(ai => ai.PatrolRadius = 200f);