@game-vir/entity - v15.1.1
    Preparing search index...

    Class BaseEntity<Context, Params, Events>Abstract

    Base entity class, types, and functionality.

    Type Parameters

    • Context = any
    • Params extends Record<string, any> | undefined = any
    • Events extends Readonly<Event> = never

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    context: Context
    entityStore: EntityStore<Context>

    The entity store to add all entities to.

    hitbox: undefined | Body<BaseEntity<Context, Params, Events>>
    hitboxSystem: System

    Collision detection system.

    isDestroyed: boolean = false

    If true, this entity should no longer be used or operated upon.

    params: Params

    Writable entity params. These should be serializable.

    pixi: Application

    Original pixi app.

    entityKey: string = 'BaseEntity'

    This key is used for deserialization of entities to track which class needs to be constructed. You cannot have duplicate keys loaded at the same time.

    paramsMap:
        | undefined
        | PartialWithUndefined<
            {
                hitbox: Partial<
                    {
                        angle: true
                        | PropertyKey;
                        bbox: true | PropertyKey;
                        calcPoints: true | PropertyKey;
                        center: true | PropertyKey;
                        convexPolygons: true | PropertyKey;
                        dirty: true | PropertyKey;
                        draw: true | PropertyKey;
                        drawBVH: true | PropertyKey;
                        edges: true | PropertyKey;
                        end: true | PropertyKey;
                        getAABB: true | PropertyKey;
                        getAABBAsBBox: true | PropertyKey;
                        getCentroid: true | PropertyKey;
                        getEdge: true | PropertyKey;
                        group: true | PropertyKey;
                        height: true | PropertyKey;
                        isCentered: true | PropertyKey;
                        isConvex: true | PropertyKey;
                        isSimple: true | PropertyKey;
                        isStatic: true | PropertyKey;
                        isTrigger: true | PropertyKey;
                        maxX: true | PropertyKey;
                        maxY: true | PropertyKey;
                        minX: true | PropertyKey;
                        minY: true | PropertyKey;
                        move: true | PropertyKey;
                        normals: true | PropertyKey;
                        offset: true | PropertyKey;
                        offsetCopy: true | PropertyKey;
                        padding: true | PropertyKey;
                        points: true | PropertyKey;
                        pos: true | PropertyKey;
                        r: true | PropertyKey;
                        radiusX: true | PropertyKey;
                        radiusY: true | PropertyKey;
                        rotate: true | PropertyKey;
                        scale: true | PropertyKey;
                        setAngle: true | PropertyKey;
                        setOffset: true | PropertyKey;
                        setPoints: true | PropertyKey;
                        setPosition: true | PropertyKey;
                        setScale: true | PropertyKey;
                        start: true | PropertyKey;
                        step: true | PropertyKey;
                        system: true | PropertyKey;
                        translate: true | PropertyKey;
                        updateBody: true | PropertyKey;
                        userData: true | PropertyKey;
                        width: true | PropertyKey;
                        x: true | PropertyKey;
                        y: true | PropertyKey;
                    },
                >;
                view: Partial<
                    {
                        _accessibleActive: true
                        | PropertyKey;
                        _accessibleDiv: true | PropertyKey;
                        _cx: true | PropertyKey;
                        _cy: true | PropertyKey;
                        _didChangeId: true | PropertyKey;
                        _didContainerChangeTick: true | PropertyKey;
                        _didViewChangeTick: true | PropertyKey;
                        _filterEffect: true | PropertyKey;
                        _getGlobalBoundsRecursive: true | PropertyKey;
                        _internalEventMode: true | PropertyKey;
                        _lastUsed: true | PropertyKey;
                        _localBoundsCacheData: true | PropertyKey;
                        _localBoundsCacheId: true | PropertyKey;
                        _markStructureAsChanged: true | PropertyKey;
                        _maskEffect: true | PropertyKey;
                        _maskOptions: true | PropertyKey;
                        _onRender: true | PropertyKey;
                        _onUpdate: true | PropertyKey;
                        _pivot: true | PropertyKey;
                        _position: true | PropertyKey;
                        _renderId: true | PropertyKey;
                        _roundPixels: true | PropertyKey;
                        _scale: true | PropertyKey;
                        _setHeight: true | PropertyKey;
                        _setWidth: true | PropertyKey;
                        _skew: true | PropertyKey;
                        _sx: true | PropertyKey;
                        _sy: true | PropertyKey;
                        _updateFlags: true | PropertyKey;
                        _updateIsSimple: true | PropertyKey;
                        _zIndex: true | PropertyKey;
                        accessible: true | PropertyKey;
                        accessibleChildren: true | PropertyKey;
                        accessibleHint: true | PropertyKey;
                        accessiblePointerEvents: true | PropertyKey;
                        accessibleText: true | PropertyKey;
                        accessibleTitle: true | PropertyKey;
                        accessibleType: true | PropertyKey;
                        addChild: true | PropertyKey;
                        addChildAt: true | PropertyKey;
                        addEffect: true | PropertyKey;
                        addEventListener: true | PropertyKey;
                        addListener: true | PropertyKey;
                        allowChildren: true | PropertyKey;
                        alpha: true | PropertyKey;
                        angle: true | PropertyKey;
                        batched: true | PropertyKey;
                        blendMode: true | PropertyKey;
                        boundsArea: true | PropertyKey;
                        cacheAsBitmap: true | PropertyKey;
                        cacheAsTexture: true | PropertyKey;
                        children: true | PropertyKey;
                        collectRenderables: true | PropertyKey;
                        collectRenderablesSimple: true | PropertyKey;
                        collectRenderablesWithEffects: true | PropertyKey;
                        containsPoint: true | PropertyKey;
                        cullable: true | PropertyKey;
                        cullableChildren: true | PropertyKey;
                        cullArea: true | PropertyKey;
                        culled: true | PropertyKey;
                        cursor: true | PropertyKey;
                        depthOfChildModified: true | PropertyKey;
                        destroy: true | PropertyKey;
                        destroyed: true | PropertyKey;
                        didChange: true | PropertyKey;
                        didViewUpdate: true | PropertyKey;
                        disableRenderGroup: true | PropertyKey;
                        dispatchEvent: true | PropertyKey;
                        effects: true | PropertyKey;
                        emit: true | PropertyKey;
                        enableRenderGroup: true | PropertyKey;
                        eventMode: true | PropertyKey;
                        eventNames: true | PropertyKey;
                        filterArea: true | PropertyKey;
                        filters: true | PropertyKey;
                        getBounds: true | PropertyKey;
                        getChildAt: true | PropertyKey;
                        getChildByLabel: true | PropertyKey;
                        getChildByName: true | PropertyKey;
                        getChildIndex: true | PropertyKey;
                        getChildrenByLabel: true | PropertyKey;
                        getFastGlobalBounds: true | PropertyKey;
                        getGlobalAlpha: true | PropertyKey;
                        getGlobalPosition: true | PropertyKey;
                        getGlobalTint: true | PropertyKey;
                        getGlobalTransform: true | PropertyKey;
                        getLocalBounds: true | PropertyKey;
                        getSize: true | PropertyKey;
                        globalDisplayStatus: true | PropertyKey;
                        groupAlpha: true | PropertyKey;
                        groupBlendMode: true | PropertyKey;
                        groupColor: true | PropertyKey;
                        groupColorAlpha: true | PropertyKey;
                        groupTransform: true | PropertyKey;
                        height: true | PropertyKey;
                        hitArea: true | PropertyKey;
                        includeInBuild: true | PropertyKey;
                        interactive: true | PropertyKey;
                        interactiveChildren: true | PropertyKey;
                        isInteractive: true | PropertyKey;
                        isRenderGroup: true | PropertyKey;
                        isSimple: true | PropertyKey;
                        label: true | PropertyKey;
                        layerParentId: true | PropertyKey;
                        listenerCount: true | PropertyKey;
                        listeners: true | PropertyKey;
                        localAlpha: true | PropertyKey;
                        localBlendMode: true | PropertyKey;
                        localColor: true | PropertyKey;
                        localDisplayStatus: true | PropertyKey;
                        localTransform: true | PropertyKey;
                        mask: true | PropertyKey;
                        measurable: true | PropertyKey;
                        name: true | PropertyKey;
                        off: true | PropertyKey;
                        on: true | PropertyKey;
                        once: true | PropertyKey;
                        onclick: true | PropertyKey;
                        onglobalmousemove: true | PropertyKey;
                        onglobalpointermove: true | PropertyKey;
                        onglobaltouchmove: true | PropertyKey;
                        onmousedown: true | PropertyKey;
                        onmouseenter: true | PropertyKey;
                        onmouseleave: true | PropertyKey;
                        onmousemove: true | PropertyKey;
                        onmouseout: true | PropertyKey;
                        onmouseover: true | PropertyKey;
                        onmouseup: true | PropertyKey;
                        onmouseupoutside: true | PropertyKey;
                        onpointercancel: true | PropertyKey;
                        onpointerdown: true | PropertyKey;
                        onpointerenter: true | PropertyKey;
                        onpointerleave: true | PropertyKey;
                        onpointermove: true | PropertyKey;
                        onpointerout: true | PropertyKey;
                        onpointerover: true | PropertyKey;
                        onpointertap: true | PropertyKey;
                        onpointerup: true | PropertyKey;
                        onpointerupoutside: true | PropertyKey;
                        onRender: true | PropertyKey;
                        onrightclick: true | PropertyKey;
                        onrightdown: true | PropertyKey;
                        onrightup: true | PropertyKey;
                        onrightupoutside: true | PropertyKey;
                        ontap: true | PropertyKey;
                        ontouchcancel: true | PropertyKey;
                        ontouchend: true | PropertyKey;
                        ontouchendoutside: true | PropertyKey;
                        ontouchmove: true | PropertyKey;
                        ontouchstart: true | PropertyKey;
                        onwheel: true | PropertyKey;
                        parent: true | PropertyKey;
                        parentRenderGroup: true | PropertyKey;
                        parentRenderGroupIndex: true | PropertyKey;
                        parentRenderLayer: true | PropertyKey;
                        pivot: true | PropertyKey;
                        position: true | PropertyKey;
                        relativeGroupTransform: true | PropertyKey;
                        relativeRenderGroupDepth: true | PropertyKey;
                        removeAllListeners: true | PropertyKey;
                        removeChild: true | PropertyKey;
                        removeChildAt: true | PropertyKey;
                        removeChildren: true | PropertyKey;
                        removeEffect: true | PropertyKey;
                        removeEventListener: true | PropertyKey;
                        removeFromParent: true | PropertyKey;
                        removeListener: true | PropertyKey;
                        renderable: true | PropertyKey;
                        renderGroup: true | PropertyKey;
                        reparentChild: true | PropertyKey;
                        reparentChildAt: true | PropertyKey;
                        rotation: true | PropertyKey;
                        roundPixels: true | PropertyKey;
                        scale: true | PropertyKey;
                        setChildIndex: true | PropertyKey;
                        setFromMatrix: true | PropertyKey;
                        setMask: true | PropertyKey;
                        setSize: true | PropertyKey;
                        skew: true | PropertyKey;
                        sortableChildren: true | PropertyKey;
                        sortChildren: true | PropertyKey;
                        sortDirty: true | PropertyKey;
                        swapChildren: true | PropertyKey;
                        tabIndex: true | PropertyKey;
                        tint: true | PropertyKey;
                        toGlobal: true | PropertyKey;
                        toLocal: true | PropertyKey;
                        updateCacheTexture: true | PropertyKey;
                        updateLocalTransform: true | PropertyKey;
                        updateTick: true | PropertyKey;
                        updateTransform: true | PropertyKey;
                        visible: true | PropertyKey;
                        width: true | PropertyKey;
                        x: true | PropertyKey;
                        y: true | PropertyKey;
                        zIndex: true | PropertyKey;
                    },
                >;
            },
        >

    Defines which properties from BaseEntity.params will be mapped to hitbox and/or view properties.

    paramsShape: undefined | ShapeDefinition<AnyObject, any>

    Shape definition of this entity's parameters.

    reverseParamsMap: undefined | ReverseParamsMap

    A mapping from params properties to hitbox or view properties, making it easy to map params values.

    Methods

    • This method is call whenever this entity's hitbox (if it has one) collides with another hitbox. It will be called for each individual collision. Override this to do something about it.

      Parameters

      • otherEntity: BaseEntity
      • collision: Readonly<Response>

      Returns void

    • Serialize the entity params for sharing across the network (for multiplayer play). By default this simply calls JSON.stringify on this.params. This method must be overridden if your entity has params that are not JSON compatible.

      Returns undefined | string