Skip to content

Behavior.OnComponentAdded(Component) Method

Definition

Namespace: Brine2D.ECS

Called when a component is added to the same entity as this behavior. Fires after the component's own OnAdded() has run.

C#
protected internal virtual void OnComponentAdded(Brine2D.ECS.Component component);

Parameters

component Component

The component that was added.

Example

C#
protected internal override void OnComponentAdded(Component component)
{
    if (component is WeaponComponent weapon)
        _currentWeapon = weapon;
}

Remarks

Use this to react to dynamic component changes — for example, caching a newly-added weapon component or enabling a visual effect when a status effect is applied. Entity is guaranteed to be non-null inside this callback.