difenduandada
2024-12-31 34abe6963b344c882358274957f4b992456fee40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
"use strict";
cc._RF.push(module, '09beffHJFVKu66tOjY0aWs1', 'red_mgr');
// Scripts/common/red_mgr.js
 
"use strict";
 
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
 
window.RedIds = {
  PartnerSummon: 1,
  Endless: 2,
  StoneDungeon: 3,
  Primus: 4,
  Heroexpedit: 5,
  StarTower: 6,
  Hallow: 7,
  NewfirstchargeModel: 8,
  HeroAll: 21,
  RefuseHero: 22,
  GuildDonate: 10,
  //公会捐献
  GuildActive: 11,
  //公会活跃
  GuildBoss: 12,
  //公会副本
  GuildSkill: 13,
  //公会技能
  Ladder: 101 //跨服天梯
 
};
window.RedMgr = cc.Class({
  ctor: function ctor() {
    this.handler_queue = []; // this.mainloop_timer = gcore.Timer.set(this.mainloop.bind(this), 1000, -1);        
  },
  addCalHandler: function addCalHandler(handler, id) {
    if (!handler) return;
 
    if (id) {
      var handler_data = {};
      handler_data.handler = handler;
      handler_data.id = id;
      var had_in_queue = false;
 
      for (var handler_i in this.handler_queue) {
        if (_typeof(this.handler_queue[handler_i]) == "object") {
          if (this.handler_queue[handler_i].id === id) {
            had_in_queue = true;
            break;
          }
        }
      }
 
      if (had_in_queue) {
        return;
      } else {
        handler = handler_data;
      }
    }
 
    this.handler_queue.push(handler);
    if (!this.mainloop_timer) this.mainloop_timer = gcore.Timer.set(this.mainloop.bind(this), 1000, -1);
  },
  mainloop: function mainloop() {
    var cur_handler = this.handler_queue.shift();
 
    if (cur_handler) {
      if (typeof cur_handler == "function") {
        cur_handler();
      } else {
        if (cur_handler = cur_handler.handler) cur_handler();
      }
    }
 
    if (this.handler_queue.length == 0) {
      if (this.mainloop_timer) {
        gcore.Timer.del(this.mainloop_timer);
        this.mainloop_timer = null;
      }
    }
  }
});
 
RedMgr.getInstance = function () {
  if (!RedMgr.instance) {
    RedMgr.instance = new RedMgr();
  }
 
  return RedMgr.instance;
};
 
module.exports = RedMgr;
 
cc._RF.pop();