Beispiel #1
0
    private void toTriggerEvent(int type, Object[] args)
    {
        if (_configDic == null)
        {
            return;
        }

        // if(CommonSetting.needTriggerLog)
        //  log("收到trigger消息",GameC.trigger.funcNameDic[type],args);

        SList <TriggerEventRegistData> list = _eventActiveDic.get(type);

        if (list == null || list.isEmpty())
        {
            return;
        }

        TriggerEvent evt = _eventPool.getOne();

        try
        {
            //设置参数
            evt.setArgs(type, args);

            initEvent(evt);
        }
        catch (Exception e)
        {
            errorLog("triggerEvent 设置参数错误", e);
        }

        evt.refCount++;

        TriggerEventRegistData[] values;
        TriggerEventRegistData   v;

        bool useTemp = false;

        if (list.size() > 1)
        {
            useTemp = true;

            _tempEventList.clear();

            values = list.getValues();

            for (int i = 0, len = list.size(); i < len; ++i)
            {
                values[i].isUsing = true;
                _tempEventList.add(values[i]);
            }

            list = _tempEventList;
        }

        values = list.getValues();

        for (int i = 0, len = list.size(); i < len; ++i)
        {
            v = values[i];

            TriggerArg arg = _argPool.getOne();
            arg.instance = getInstance(v.config.id);
            arg.evt      = evt;

            //检查事件
            if (!checkEventMatch(v.data, arg))
            {
                _argPool.back(arg);
                continue;
            }

            toRunTrigger(arg);
        }

        if (useTemp)
        {
            values = _tempEventList.getValues();

            for (int i = 0, len = _tempEventList.size(); i < len; ++i)
            {
                v = values[i];

                if (v.needRelease)
                {
                    _eventRegistDataPool.back(v);
                }
            }

            _tempEventList.clear();
        }

        //回收
        if ((--evt.refCount) == 0)
        {
            _eventPool.back(evt);
        }
    }