sim-ecs - v0.6.5
    Preparing search index...

    Interface IEntity

    interface IEntity {
        id: string;
        addComponent(
            component: object | TObjectProto,
            ...args: readonly unknown[],
        ): IEntity;
        addEventListener<T extends keyof IEventMap>(
            event: T,
            handler: IEventMap[T],
        ): void;
        addTag(tag: TTag): IEntity;
        clone(serde: ISerDe, uuid?: string): IEntity;
        getComponent<T extends object>(component: TTypeProto<T>): undefined | T;
        getComponentCount(): number;
        getComponents(): IterableIterator<object>;
        getTagCount(): number;
        getTags(): IterableIterator<TTag>;
        hasComponent(component: ObjectConstructor | TObjectProto): boolean;
        hasEventListener<T extends keyof IEventMap>(
            event: T,
            handler: IEventMap[T],
        ): void;
        hasTag(tag: TTag): boolean;
        removeComponent(component: object | TObjectProto): IEntity;
        removeEventListener<T extends keyof IEventMap>(
            event: T,
            handler: IEventMap[T],
        ): void;
        removeTag(tag: TTag): IEntity;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    id: string

    UUID to identify the entity across instances The ID is generated and must be manually maintained when syncing with another instance

    Methods

    • Add a component to this entity

      Parameters

      • component: object | TObjectProto
      • ...args: readonly unknown[]

      Returns IEntity

    • Add a tag to this entity Tagging can be used to mark the entity instead of using an empty marker-component Tags cannot be queried for! They are only markers and should be implemented and used as lean and light-weight as possible.

      Parameters

      Returns IEntity

    • Get a component of a certain type which is associated with this entity

      Type Parameters

      • T extends object

      Parameters

      • component: TTypeProto<T>

      Returns undefined | T

    • Check if a certain component is associated with this entity

      Parameters

      • component: ObjectConstructor | TObjectProto

      Returns boolean