Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Component

class for all Components to inherit from. Component is a class with data.

export
class

Component

Hierarchy

  • Component

Index

Constructors

constructor

Properties

Protected m_admin

m_admin: EntityAdmin | undefined

Protected m_entity

m_entity: Entity = 0

Owner entity ID. Before the component instance be assigned to an entity, m_entity is 0. 0 is not a valid entity forever.

type

{Entity}

memberof

Component

Static id

id: number = 0

Don't modify or read this attribute! It's only used by EntityAdmin. If this component is being watched, EntityAdmin will apply an ID for the Component.id.

static
type

{number}

memberof

Component

Accessors

Protected admin

entity

  • Returns owner entity ID. Before the component instance be assigned to an entity, it returns 0 that is not a valid entity.

    readonly
    type

    {Entity}

    memberof

    Component

    Returns Entity

Methods

AddSibling

  • Add one or more sibing components. If the owner entity has owned the component type you give, the new component instance will replace the old.

    memberof

    Component

    Parameters

    • Rest ...cs: Component[]

      A list of component instances.

    Returns void

GetSibling

  • GetSibling<T>(cclass: CLASS<T>): T | undefined
  • Get Sibling component. Sibling components means they have the same entity owner. If the specified type component exist, returns it's instance. If not, returns undefined.

    template

    T

    memberof

    Component

    Type parameters

    Parameters

    • cclass: CLASS<T>

      The specified component type.

    Returns T | undefined

RemoveSibling

  • Remove one or more sibing components. Remove a component type that the owner entity doesn't own is allowed. So it's not necessary to determine whether the component type is owned before removing it.

    memberof

    Component

    Parameters

    Returns void

SureSibling

  • SureSibling<T>(cclass: CLASS<T>): T
  • Actually the same as GetSibling, but returns by a type assertion. If you are sure sibling component exist, call this method. The return type does not union undefined.

    template

    T

    memberof

    Component

    Type parameters

    Parameters

    • cclass: CLASS<T>

      Component type.

    Returns T