System.register(["cc"], function (_export, _context) {
  "use strict";

  var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Component, RigidBody, Collider, v3, MeshRenderer, _dec, _class, _class2, _crd, ccclass, property, TileItem;

  return {
    setters: [function (_cc) {
      _cclegacy = _cc.cclegacy;
      __checkObsolete__ = _cc.__checkObsolete__;
      __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
      _decorator = _cc._decorator;
      Component = _cc.Component;
      RigidBody = _cc.RigidBody;
      Collider = _cc.Collider;
      v3 = _cc.v3;
      MeshRenderer = _cc.MeshRenderer;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "e57f3IhsV1IzqpUuNXaJW5e", "TileItem", undefined);

      __checkObsolete__(['_decorator', 'Component', 'RigidBody', 'Collider', 'v3', 'MeshRenderer', 'MeshCollider', 'CCObject', 'Vec2', 'Vec3']);

      ({
        ccclass,
        property
      } = _decorator);

      _export("TileItem", TileItem = (_dec = ccclass('TileItem'), _dec(_class = (_class2 = class TileItem extends Component {
        constructor(...args) {
          super(...args);
          this.auto_rotation = false;
          this.collider = [];
          this.rigid = null;
          this.removed = false;
          this.removedPos = void 0;
          this.playRmovedEff = false;
          this._enableCollider = false;
        }

        static getY() {
          let n = Date.now() - this.starttime;
          return n / 10;
        }

        start() {
          this.collider = this.node.children[0].getComponents(Collider);
        } //禁用碰撞


        set enableCollider(b) {
          let worldRotation = this.node.children[0].worldRotation.clone();
          this.node.worldPosition = this.node.children[0].worldPosition.clone();
          this.node.children[0].position = v3();
          this.node.children[0].worldRotation = worldRotation;
          this.rigid.useGravity = b; // this.collider.enabled = b;
          // this.rigid.enabled = b;
        }

        get enableCollider() {
          return this._enableCollider;
        }

        destoryCollider() {
          this.node.children[0].position = v3();
          this.node.children[0].eulerAngles = v3();
          this.collider.map(a => a.enabled = false);
          this.rigid.destroy();
        }

        addCollider() {
          let _render = this.node.children[0].getComponent(MeshRenderer);

          this.rigid = _render.node.addComponent(RigidBody);
          this.collider.map(a => a.enabled = true);
          return this.rigid;
        }

        update() {
          if (this.auto_rotation) {
            this.node.setRotationFromEuler(0, TileItem.getY(), 0);
          }

          if (this.rigid.isValid) {
            /*let plate = Main._instance._GameNode.plate;
            const gooseWorldPos = this.node.worldPosition;
            const plateWorldPos = plate.worldPosition;
            // 检测是否超出盘子范围（示例：XZ 平面限制）
            const maxX = 2, maxZ = 2; // 盘子半径
            if (Math.abs(gooseWorldPos.x - plateWorldPos.x) > maxX || 
                Math.abs(gooseWorldPos.z - plateWorldPos.z) > maxZ) {
                // 施加反向力（推回盘子中心）
                const forceDir = new Vec3(
                    plateWorldPos.x - gooseWorldPos.x,
                    0,
                    plateWorldPos.z - gooseWorldPos.z
                ).normalize().multiplyScalar(10); // 力的大小
                this.rigid.applyForce(forceDir);
            }*/
          }
        }

      }, _class2.TileItem = void 0, _class2.starttime = Date.now(), _class2)) || _class));

      _cclegacy._RF.pop();

      _crd = false;
    }
  };
});
//# sourceMappingURL=a6c58362140c7a340eedaa219d22614e4e8d249a.js.map