
                (function() {
                    var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined';
                    var __module = nodeEnv ? module : {exports:{}};
                    var __filename = 'preview-scripts/assets/Script/Notification.js';
                    var __require = nodeEnv ? function (request) {
                        return cc.require(request);
                    } : function (request) {
                        return __quick_compile_project__.require(request, __filename);
                    };
                    function __define (exports, require, module) {
                        if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict";
cc._RF.push(module, 'f2518+0IHRGOY+ueIhGtEeA', 'Notification');
// Script/Notification.ts

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Notification = void 0;
//全局通知
var Notification = {
    _eventMap: [],
    on: function (masgId, callback, target) {
        if (this._eventMap[masgId] === undefined) {
            this._eventMap[masgId] = [];
        }
        this._eventMap[masgId].push({ callback: callback, target: target });
    },
    emit: function (masgId, parameter) {
        var array = this._eventMap[masgId];
        if (array === undefined)
            return;
        for (var i = 0; i < array.length; i++) {
            var element = array[i];
            if (element)
                element.callback.call(element.target, parameter);
        }
    },
    off: function (masgId, callback) {
        var array = this._eventMap[masgId];
        if (array === undefined)
            return;
        for (var i = 0; i < array.length; i++) {
            var element = array[i];
            if (element && element.callback === callback) {
                array[i] = undefined;
                break;
            }
        }
    },
    offMasgId: function (masgId) {
        this._eventMap[masgId] = undefined;
    },
    removeAllMsg: function () {
        for (var k in this._eventMap) {
            if (this._eventMap[k]) {
                this.offMasgId(k);
            }
        }
    }
};
exports.Notification = Notification;

cc._RF.pop();
                    }
                    if (nodeEnv) {
                        __define(__module.exports, __require, __module);
                    }
                    else {
                        __quick_compile_project__.registerModuleFunc(__filename, function () {
                            __define(__module.exports, __require, __module);
                        });
                    }
                })();
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFzc2V0c1xcU2NyaXB0XFxOb3RpZmljYXRpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs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ZF0gPSBbXTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9ldmVudE1hcFttYXNnSWRdLnB1c2goeyBjYWxsYmFjazogY2FsbGJhY2ssIHRhcmdldDogdGFyZ2V0IH0pO1xuICAgIH0sXG5cbiAgICBlbWl0OiBmdW5jdGlvbiAobWFzZ0lkLCBwYXJhbWV0ZXIpIHtcbiAgICAgICAgbGV0IGFycmF5ID0gdGhpcy5fZXZlbnRNYXBbbWFzZ0lkXTtcbiAgICAgICAgaWYgKGFycmF5ID09PSB1bmRlZmluZWQpIHJldHVybjtcblxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFycmF5Lmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICBsZXQgZWxlbWVudCA9IGFycmF5W2ldO1xuICAgICAgICAgICAgaWYgKGVsZW1lbnQpIGVsZW1lbnQuY2FsbGJhY2suY2FsbChlbGVtZW50LnRhcmdldCwgcGFyYW1ldGVyKTtcbiAgICAgICAgfVxuICAgIH0sXG5cbiAgICBvZmY6IGZ1bmN0aW9uIChtYXNnSWQsIGNhbGxiYWNrKSB7XG4gICAgICAgIGxldCBhcnJheSA9IHRoaXMuX2V2ZW50TWFwW21hc2dJZF07XG4gICAgICAgIGlmIChhcnJheSA9PT0gdW5kZWZpbmVkKSByZXR1cm47XG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyYXkubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIGxldCBlbGVtZW50ID0gYXJyYXlbaV07XG4gICAgICAgICAgICBpZiAoZWxlbWVudCAmJiBlbGVtZW50LmNhbGxiYWNrID09PSBjYWxsYmFjaykge1xuICAgICAgICAgICAgICAgIGFycmF5W2ldID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcblxuICAgIG9mZk1hc2dJZDogZnVuY3Rpb24gKG1hc2dJZCkge1xuICAgICAgICB0aGlzLl9ldmVudE1hcFttYXNnSWRdID0gdW5kZWZpbmVkO1xuICAgIH0sXG5cbiAgICByZW1vdmVBbGxNc2c6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgZm9yIChsZXQgayBpbiB0aGlzLl9ldmVudE1hcCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuX2V2ZW50TWFwW2tdKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5vZmZNYXNnSWQoayk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG59O1xuXG5leHBvcnQgeyBOb3RpZmljYXRpb24gfTsiXX0=