import { AppObjectController } from "@vived/core";
import { StylusEntity } from "../../../Stylus";
import { TryMoveTransformUC } from "../../UC";
export class MoveTransformSC extends AppObjectController {
    get stylus() {
        return this.getCachedSingleton(StylusEntity.type);
    }
    get tryMoveUC() {
        return this.getCachedLocalComponent(TryMoveTransformUC.type);
    }
    constructor(appObject) {
        super(appObject, MoveTransformSC.type);
        this.doUpdate = false;
        this.allow = (button) => {
            if (button === 0)
                return true;
            return false;
        };
        this.onButtonDown = (button) => {
            this.doUpdate = false;
            if (!this.stylus || !this.tryMoveUC)
                return;
            if (!this.allow(button))
                return;
            this.doUpdate = this.tryMoveUC.tryWithRay(this.stylus.pickRay);
        };
        this.onStylusMove = () => {
            if (!this.stylus || !this.tryMoveUC)
                return;
            if (!this.doUpdate)
                return;
            this.tryMoveUC.moveWithRay(this.stylus.pickRay);
        };
        this.onButtonUp = () => {
            if (!this.doUpdate)
                return;
            this.doUpdate = false;
            if (!this.tryMoveUC)
                return;
            this.tryMoveUC.stop();
        };
        this.stylus?.registerController(this);
    }
}
MoveTransformSC.type = "MoveTransformSC";
//# sourceMappingURL=MoveTransformSC.js.map