Type alias Entity

Entity: {
    addComponent: ((component) => void);
    deleteComponent: ((component) => void);
    getArchetype: (() => Archetype);
    getComponent: (<J, T>(type) => T | undefined);
    getId: (() => number);
    hasComponent: ((type) => boolean);
}

Represents an Entity in an ECS (Entity-Component-System) architecture.

Type declaration

  • addComponent: ((component) => void)
      • (component): void
      • Adds a new component to this entity.

        Parameters

        Returns void

  • deleteComponent: ((component) => void)
      • (component): void
      • Removes a component from this entity.

        Parameters

        • component: Component

          The component to remove.

        Returns void

  • getArchetype: (() => Archetype)
      • (): Archetype
      • Gets the archetype associated with this entity.

        Returns Archetype

        The archetype of this entity.

  • getComponent: (<J, T>(type) => T | undefined)
      • <J, T>(type): T | undefined
      • Gets a reference to the component by its type.

        Type Parameters

        • J

          The type of the component data.

        • T extends {
              data: J;
              type: symbol;
          }

          The type of the component object.

        Parameters

        • type: T

          The type of the component to retrieve.

        Returns T | undefined

        The component of the specified type or undefined if not found.

  • getId: (() => number)
      • (): number
      • Gets the unique identifier for this entity.

        Returns number

        The ID of this entity.

  • hasComponent: ((type) => boolean)
      • (type): boolean
      • Checks if the entity contains a component of the given type.

        Parameters

        • type: symbol

          The type of the component to check for.

        Returns boolean

        True if the entity has the component, otherwise false.