System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3", "__unresolved_4", "__unresolved_5", "__unresolved_6"], function (_export, _context) {
  "use strict";

  var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, director, Layers, Node, Prefab, sp, Sprite, SpriteFrame, tween, Logger, GameConst, bundleMgr, Utils, uiMgr, PoolManager, _dec, _class, _crd, ccclass, property, ResUtil;

  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

  function _reportPossibleCrUseOfLogger(extras) {
    _reporterNs.report("Logger", "../extend/Logger", _context.meta, extras);
  }

  function _reportPossibleCrUseOfGameConst(extras) {
    _reporterNs.report("GameConst", "../common/GameConst", _context.meta, extras);
  }

  function _reportPossibleCrUseOfbundleMgr(extras) {
    _reporterNs.report("bundleMgr", "../manager/BundleManager", _context.meta, extras);
  }

  function _reportPossibleCrUseOfUtils(extras) {
    _reporterNs.report("Utils", "./Utils", _context.meta, extras);
  }

  function _reportPossibleCrUseOfuiMgr(extras) {
    _reporterNs.report("uiMgr", "../manager/UIManager", _context.meta, extras);
  }

  function _reportPossibleCrUseOfPoolManager(extras) {
    _reporterNs.report("PoolManager", "../manager/PoolManager", _context.meta, extras);
  }

  return {
    setters: [function (_unresolved_) {
      _reporterNs = _unresolved_;
    }, function (_cc) {
      _cclegacy = _cc.cclegacy;
      __checkObsolete__ = _cc.__checkObsolete__;
      __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
      _decorator = _cc._decorator;
      director = _cc.director;
      Layers = _cc.Layers;
      Node = _cc.Node;
      Prefab = _cc.Prefab;
      sp = _cc.sp;
      Sprite = _cc.Sprite;
      SpriteFrame = _cc.SpriteFrame;
      tween = _cc.tween;
    }, function (_unresolved_2) {
      Logger = _unresolved_2.Logger;
    }, function (_unresolved_3) {
      GameConst = _unresolved_3.GameConst;
    }, function (_unresolved_4) {
      bundleMgr = _unresolved_4.bundleMgr;
    }, function (_unresolved_5) {
      Utils = _unresolved_5.default;
    }, function (_unresolved_6) {
      uiMgr = _unresolved_6.uiMgr;
    }, function (_unresolved_7) {
      PoolManager = _unresolved_7.PoolManager;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "3015eqw5adC8ZqXLnnEky33", "ResUtil", undefined);

      __checkObsolete__(['_decorator', 'Asset', 'Component', 'Constructor', 'director', 'Layers', 'Node', 'Prefab', 'SceneAsset', 'sp', 'Sprite', 'SpriteFrame', 'tween', 'utils', 'Vec3']);

      ({
        ccclass,
        property
      } = _decorator);

      _export("ResUtil", ResUtil = (_dec = ccclass('ResUtil'), _dec(_class = class ResUtil {
        /**
         * 根据名字加载一个新的模型与预制体或者缓存中的预制体
         * @param path 模型名字
         * @param cb 返回回调
         * @returns 返回参数
         */
        static loadModelPrefabName(path, cb) {
          if ((_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
            error: Error()
          }), Utils) : Utils).isNull(path)) return;
          return new Promise((resolve, reject) => {
            (_crd && bundleMgr === void 0 ? (_reportPossibleCrUseOfbundleMgr({
              error: Error()
            }), bundleMgr) : bundleMgr).loadAsset((_crd && GameConst === void 0 ? (_reportPossibleCrUseOfGameConst({
              error: Error()
            }), GameConst) : GameConst).bundleName.models, path, Prefab, (err, res) => {
              if (err) {
                console.warn("加载错误：", path, err);
                cb == null || cb(err, null);
                reject(null);
              } else {
                cb == null || cb(null, res);
                resolve(res);
              }
            });
          });
        }
        /**
         * 设置精灵贴图 只能prefabs包 texture目录下
         * @param path 资源路径
         * 只能是在prefabs这个bundle目录下、然后如果使用
         * @param target 精灵或者节点
         * @param cb 回调函数
         */


        static setSpriteFrame(name, target) {
          if ((_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
            error: Error()
          }), Utils) : Utils).isNull(name)) return;
          var path = "texture/" + name + "/spriteFrame";
          (_crd && bundleMgr === void 0 ? (_reportPossibleCrUseOfbundleMgr({
            error: Error()
          }), bundleMgr) : bundleMgr).loadAsset((_crd && GameConst === void 0 ? (_reportPossibleCrUseOfGameConst({
            error: Error()
          }), GameConst) : GameConst).bundleName.resources, path, SpriteFrame, (err, clip) => {
            if (!err) {
              var sprite = target instanceof Node ? target.getComponent(Sprite) : target;

              if (!sprite) {
                console.error('Target node does not have a Sprite component!');
              } else {
                sprite.spriteFrame = clip;
              }
            }
          });
        }
        /**
         * 设置精灵贴图 指定自定义的包
         * @param bundle 包名如果传空 默认prefabs包名
         * @param path 路径 如果在prefabs包下，就可以直接传递传图片名称或者path路径(hit_m or texture/hit_m/spriteFrame)
         * 如果不在prefabs包下就只能传递完成的路径(texture/hit_m/spriteFrame)
         * @param type 类型
         * @param target 图片或者节点
         * @param onComplete 设置完成的回调
         */


        static setSpriteFrameAsset(bundle, path, type, target, onComplete) {
          if ((_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
            error: Error()
          }), Utils) : Utils).isNull(bundle)) {
            bundle = (_crd && GameConst === void 0 ? (_reportPossibleCrUseOfGameConst({
              error: Error()
            }), GameConst) : GameConst).bundleName.resources;

            if (!path.startsWith("texture/")) {
              path = "texture/" + path + "/spriteFrame";
            }
          }

          if ((_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
            error: Error()
          }), Utils) : Utils).isNull(path)) return;
          (_crd && bundleMgr === void 0 ? (_reportPossibleCrUseOfbundleMgr({
            error: Error()
          }), bundleMgr) : bundleMgr).loadAsset(bundle, path, type, (err, clip) => {
            if (!err) {
              var sprite = target instanceof Node ? target.getComponent(Sprite) : target;

              if (!sprite) {
                console.error('Target node does not have a Sprite component!');
              } else {
                sprite.spriteFrame = clip;
              }
            }

            onComplete == null || onComplete(err, clip);
          });
        }
        /**
         * 预加载场景资源（支持进度回调）
         * @param {string} sceneName - 场景名称（如 "main" 或者"level1"）
         * @param {Function} [onComplete] - 完成回调
         * @param {Function} [onProgress] - 加载进度回调
         * @param {Error | null} onProgress.err - 错误信息（成功时为 null）
         * @param {number} onProgress.progress - 加载进度（0~1）
         */


        static preloadScene(sceneName, onComplete, onProgress) {
          if ((_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
            error: Error()
          }), Utils) : Utils).isNull(sceneName)) {
            (_crd && Logger === void 0 ? (_reportPossibleCrUseOfLogger({
              error: Error()
            }), Logger) : Logger).warn("[SceneLoader] Scene name cannot be null or empty!");
            return;
          } // 开始预加载场景


          director.preloadScene(sceneName, (loadedCount, totalCount) => {
            //进度更新回调
            var progress = totalCount > 0 ? loadedCount / totalCount : 0;
            onProgress == null || onProgress(null, progress); // 通知进度（未完成）
          }, //加载完成回调
          (error, sceneAsset) => {
            if (error) {
              (_crd && Logger === void 0 ? (_reportPossibleCrUseOfLogger({
                error: Error()
              }), Logger) : Logger).error("[SceneLoader] Failed to preload scene \"" + sceneName + "\":", error);
              onProgress == null || onProgress(error, 0); // 通知失败

              return;
            }

            onComplete == null || onComplete(); //预加载成功

            (_crd && Logger === void 0 ? (_reportPossibleCrUseOfLogger({
              error: Error()
            }), Logger) : Logger).log("[SceneLoader] Scene \"" + sceneName + "\" preloaded successfully");
            onProgress == null || onProgress(null, 1);
          });
        }
        /**
         * 预加载场景成功后跳转 不黑屏这种
         * @param sceneName 场景名字
         */


        static enteScene(sceneName) {
          if ((_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
            error: Error()
          }), Utils) : Utils).isNull(sceneName)) return;
          this.preloadScene(sceneName, () => {
            //启动场景
            (_crd && uiMgr === void 0 ? (_reportPossibleCrUseOfuiMgr({
              error: Error()
            }), uiMgr) : uiMgr).showScene('main');
          });
        }
        /**
         * 播放spine动画
         * @param file "spine/effect_hecheng"
         * @param name "effect"
         * @param parent 
         * @param pos 
         * @param removetime 
         * @returns 
         */


        static playSkAni(file, aniName, parent, pos, removetime) {
          return _asyncToGenerator(function* () {
            if (removetime === void 0) {
              removetime = -1;
            }

            var node = new Node();
            node.parent = parent;
            node.position = pos;
            node.layer = Layers.BitMask.UI_2D;
            var skd = node.addComponent(sp.Skeleton);
            var data = yield (_crd && bundleMgr === void 0 ? (_reportPossibleCrUseOfbundleMgr({
              error: Error()
            }), bundleMgr) : bundleMgr).loadAsset((_crd && GameConst === void 0 ? (_reportPossibleCrUseOfGameConst({
              error: Error()
            }), GameConst) : GameConst).bundleName.resources, file, sp.SkeletonData);
            skd.skeletonData = data;
            skd.setAnimation(0, aniName, false);

            if (removetime != -1) {
              tween(node).delay(removetime).call(() => {
                (_crd && PoolManager === void 0 ? (_reportPossibleCrUseOfPoolManager({
                  error: Error()
                }), PoolManager) : PoolManager).putNode(node);
              }).start();
            }

            return node;
          })();
        }

      }) || _class));

      _cclegacy._RF.pop();

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