import { AppObjectPM } from "@vived/core";
import { Vector3 } from "@vived/core";
import { Transform3D } from "../Entities/Transform3D";
export class CanBeStuckPM extends AppObjectPM {
    static getForID(appObjID, appObjects) {
        const appObj = appObjects.get(appObjID);
        if (appObj === undefined) {
            return undefined;
        }
        return appObj.getComponent(CanBeStuckPM.type);
    }
}
CanBeStuckPM.type = "CanBeStuckPM";
export function makeCanBeStuckPM(appObject) {
    return new CanBeStuckPMImp(appObject);
}
class CanBeStuckPMImp extends CanBeStuckPM {
    vmsAreEqual(a, b) {
        return a === b;
    }
    constructor(appObject) {
        super(appObject, CanBeStuckPM.type);
        this.onTransformChange = () => {
            if (!this.transform)
                return;
            const pos = this.transform.localPosition;
            const canBeStuck = !Vector3.Close(pos, Vector3.Zero());
            this.doUpdateView(canBeStuck);
        };
        this.dispose = () => {
            super.dispose();
            this.transform?.removeChangeObserver(this.onTransformChange);
            this.transform?.removeOnDisposeObserver(this.dispose);
        };
        this.transform = Transform3D.get(appObject);
        if (!this.transform) {
            this.warn("Unable to find Transform3D Entity");
            return;
        }
        else {
            this.transform.addChangeObserver(this.onTransformChange);
            this.transform.addOnDisposeObserver(this.dispose);
            this.onTransformChange();
        }
    }
}
//# sourceMappingURL=CanBeStuckPM.js.map