var t = require; var e = module; var i = exports; e = (this && this.__decorate) || function(t, e, i, s) { var o, a = arguments.length, n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s; if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s); else for (var r = t.length - 1; 0 <= r; r--) (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n); return 3 < a && n && Object.defineProperty(e, i, n), n; }; Object.defineProperty(i, "__esModule", { value: !0 }), (i.LineComponent = void 0); const s = t("SwitchFrame"), { ccclass: o, property: a, menu: n, executeInEditMode: r, playOnFocus: l } = cc._decorator; t = class extends cc.Component { constructor() { super(...arguments), (this.node1 = null), (this.node2 = null), (this.light = null), (this.switchFrame = null), (this.pos1 = null), (this.pos2 = null), (this._isDraw = !1); } set drawLine(t) { Log.trace("wtffffff", t), (this._isDraw = t) && this.setPos(this.node1.position, this.node2.position); } get drawLine() { return this._isDraw; } onLoad() { (this.node.anchorY = 0.5), (this.node.anchorX = 0); } getRadian2(t, e, i, s) { return Math.atan2(s - e, i - t); } setGray(t) { this.switchFrame.frameIndex = t ? 0 : 1; } setNode(t, e, i = -1) { (this.node1 = t || this.node1), (this.node2 = e || this.node2); (e = this.node1.parent.convertToWorldSpaceAR(this.node1.position)), (e = this.node.parent.convertToNodeSpaceAR(e)); this.pos2 = e; (e = this.node2.parent.convertToWorldSpaceAR(this.node2.position)), (e = this.node.parent.convertToNodeSpaceAR(e)); (this.pos1 = e), this.playAni(i); } setPos(t, e, i = -1) { (this.pos1 = t), (this.pos2 = e), this.playAni(i); } setCallback(t) { this.cb = t; } playAni(t = 0, e) { var i, s, o; this.pos1 && this.pos2 && ((i = this.pos2), (s = this.pos1), (this.node.width = 0), (o = this.getRadian2(i.x, i.y, s.x, s.y)), (o = this.node.angle = (180 * o) / Math.PI), Log.trace("角度:", o), (this.node.x = this.pos2.x), (this.node.y = this.pos2.y), (o = cc.Vec2.distance(i, s)), Log.trace("绘制:::", o), t <= 0 ? (this.node.width = o) : ((this.light.active = !0), cc .tween(this.node) .to(0.012 * o, { width: cc.Vec2.distance(i, s) }) .call(() => { this.light && (this.light.active = !1), e && e(); }) .start())); } getY() { if (this.pos1 && this.pos2) { var t = this.pos2, e = this.pos1, t = this.getRadian2(t.x, t.y, e.x, e.y), e = (Math.PI, this.node.width); return this.node.y + Math.sin(t) * e; } } stopAni() { this.node.stopAllActions(); } removeSelf() { (this.pos1 = null), (this.pos2 = null), this.stopAni(), (this.cb = null), this.light && (this.light.active = !1); } }; e([a(cc.Node)], t.prototype, "node1", void 0), e([a(cc.Node)], t.prototype, "node2", void 0), e([a(cc.Node)], t.prototype, "light", void 0), e([a(s.default)], t.prototype, "switchFrame", void 0), e([a({ type: cc.Boolean })], t.prototype, "drawLine", null), (t = e([o, r, l], t)), (i.LineComponent = t);