@kognifai/cogsengine
    Preparing search index...

    Class ComponentCollection

    class ComponentCollection stores added Dynamic components in an Entity.

    Index

    Accessors

    Methods

    Accessors

    • get length(): number

      Gets number of dynamic components.

      Returns number

    Methods

    • Add extra component to Entity.component collection. Component must be a subclass of Component. Can only be added to one entity. Max one Components of same type in an Entity.

      Create built-in component using: component = runtime.'ComponentTypeName'.create(); Create custom

      Type Parameters

      • T extends Component

        Component type - inferred from component added.

      Parameters

      • component: T

        component to add.

      Returns T

      Component Added. null if error.

      DynamicComponent component using component = new MyDynamicComponent();

    • Gets the item at the given index, allowing for positive and negative integers.

      Parameters

      • index: number

        The index (position) of the array element to be returned. Supports relative indexing from the end of the array when passed a negative index; i.e. if a negative number is used, the element returned will be found by counting back from the end of the array.

      Returns Component

      The element in the array matching the given index. Undefined if outside.

    • Called when collection being destroyed to release resources on Cogs.js release().

      Returns void

    • Remove dynamic component from Entity.components

      Parameters

      • component: Component

        Component to remove. May be predefined in entity or added by user.

      Returns void