import { AppObjectController } from "@vived/core";
import { StylusEntity } from "../../Stylus";
import { SelectAppObjectUC } from "../UC";
export class StylusSelectAppObjectSC extends AppObjectController {
    constructor(appObject) {
        super(appObject, StylusSelectAppObjectSC.type);
        this.allow = () => {
            return true;
        };
        this.onButtonClick = (button) => {
            if (button !== 0)
                return;
            if (!this.stylus)
                return;
            if (!this.selectUC)
                return;
            if (!this.allow())
                return;
            const pointerRay = this.stylus.pickRay;
            this.selectUC.trySelectAppObject(pointerRay);
        };
        this.stylus = StylusEntity.get(this.appObjects);
        if (!this.stylus) {
            this.error("Unable to find StylusEntity");
            return;
        }
        this.selectUC = appObject.getComponent(SelectAppObjectUC.type);
        if (!this.selectUC) {
            this.error("Added to an App Object that does not have SelectAppObjectUC");
            return;
        }
        this.stylus.registerController(this);
    }
}
StylusSelectAppObjectSC.type = "StylusSelectAppObjectSC";
//# sourceMappingURL=StylusSelectAppObjectSC.js.map