"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StylusSelectAppObjectSC = void 0;
const core_1 = require("@vived/core");
const Stylus_1 = require("../../Stylus");
const UC_1 = require("../UC");
class StylusSelectAppObjectSC extends core_1.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 = Stylus_1.StylusEntity.get(this.appObjects);
        if (!this.stylus) {
            this.error("Unable to find StylusEntity");
            return;
        }
        this.selectUC = appObject.getComponent(UC_1.SelectAppObjectUC.type);
        if (!this.selectUC) {
            this.error("Added to an App Object that does not have SelectAppObjectUC");
            return;
        }
        this.stylus.registerController(this);
    }
}
exports.StylusSelectAppObjectSC = StylusSelectAppObjectSC;
StylusSelectAppObjectSC.type = "StylusSelectAppObjectSC";
//# sourceMappingURL=StylusSelectAppObjectSC.js.map