import { AppObjectPM } from "@vived/core";
import { StickableEntity } from "../Entities/Stickable";
export class StickTargetPM extends AppObjectPM {
    static get(id, appObjects) {
        return appObjects.get(id)?.getComponent(StickTargetPM.type);
    }
}
StickTargetPM.type = "StickTargetPM";
export function makeStickTargetPM(appObject) {
    return new StickTargetPMImp(appObject);
}
class StickTargetPMImp extends StickTargetPM {
    get entity() {
        return this.getCachedLocalComponent(StickableEntity.type);
    }
    vmsAreEqual(a, b) {
        if (a.highlightTarget !== b.highlightTarget)
            return false;
        if (a.showStickTarget !== b.showStickTarget)
            return false;
        return true;
    }
    constructor(appObject) {
        super(appObject, StickTargetPM.type);
        this.onEntityChange = () => {
            if (!this.entity)
                return;
            const showStickTarget = this.entity.showStickTarget;
            const highlightTarget = this.entity.highlightTarget;
            const vm = {
                showStickTarget,
                highlightTarget,
            };
            this.doUpdateView(vm);
        };
        this.entity?.addChangeObserver(this.onEntityChange);
        this.onEntityChange();
    }
}
export const defaultStickTargetVM = {
    showStickTarget: false,
    highlightTarget: false,
};
//# sourceMappingURL=StickTargetPM.js.map