CatTimeOut.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. e =
  5. (this && this.__decorate) ||
  6. function (t, e, i, s) {
  7. var o,
  8. a = arguments.length,
  9. n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
  10. if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
  11. else
  12. for (var r = t.length - 1; 0 <= r; r--)
  13. (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
  14. return 3 < a && n && Object.defineProperty(e, i, n), n;
  15. };
  16. Object.defineProperty(i, "__esModule", {value: !0});
  17. const s = t("App"),
  18. o = t("RoleService"),
  19. a = t("Chef"),
  20. n = t("ChefAI"),
  21. {ccclass: r} = cc._decorator;
  22. e = e(
  23. [r],
  24. (e = class extends cc.Component {
  25. constructor() {
  26. super(...arguments),
  27. (this.progress = null),
  28. (this.manAI = null),
  29. (this.leftTime = null),
  30. (this._hireEndTime = 0),
  31. (this._holdTime = 0),
  32. (this._callBack = null),
  33. (this._target = null);
  34. }
  35. onLoad() {
  36. this.manAI = this.getComponent(n.default);
  37. const t = s.default.NodePoolMsr.catLefttimeProgressPool.pop();
  38. (t.zIndex = -1), (this.progress = t.getComponent(cc.ProgressBar)), this.node.addChild(t);
  39. }
  40. update(t) {}
  41. onDestroy() {
  42. this.progress.isValid && this.progress.node.destroy();
  43. }
  44. setLeftTime(t, e) {
  45. (this._hireEndTime = t), (this._holdTime = e), (this.update = this.updateProgress);
  46. }
  47. setCallBack(t, e) {
  48. (this._callBack = t), (this._target = e);
  49. }
  50. removeImmediately() {
  51. this.update = this.checkCanDestory;
  52. }
  53. checkCanDestory() {
  54. (this.manAI.state !== n.AI_STATE.NONE &&
  55. this.manAI.state !== n.AI_STATE.REST &&
  56. this.manAI.state !== n.AI_STATE.MOVE_TO_REST &&
  57. this.manAI.state !== n.AI_STATE.DEEP_REST) ||
  58. (o.default.ins.removeEmployee(this.getComponent(a.default)),
  59. this._callBack && this._callBack.call(this._target));
  60. }
  61. updateProgress() {
  62. var t = (this._hireEndTime - s.default.DateUtils.Now()) / this._holdTime;
  63. 0 < t
  64. ? (this.progress.progress = t)
  65. : ((this.progress.progress = 1e-4), (this.update = this.checkCanDestory));
  66. }
  67. })
  68. );
  69. i.default = e;