static int TriggerListener(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 4 && LuaScriptMgr.CheckTypes(L, 1, typeof(IOLuaHelper), typeof(int), typeof(int), typeof(bool))) { IOLuaHelper obj = (IOLuaHelper)LuaScriptMgr.GetNetObjectSelf(L, 1, "IOLuaHelper"); int arg0 = (int)LuaDLL.lua_tonumber(L, 2); int arg1 = (int)LuaDLL.lua_tonumber(L, 3); bool arg2 = LuaDLL.lua_toboolean(L, 4); obj.TriggerListener(arg0, arg1, arg2); return(0); } else if (count == 4 && LuaScriptMgr.CheckTypes(L, 1, typeof(IOLuaHelper), typeof(EnumIOEvent), typeof(int), typeof(bool))) { IOLuaHelper obj = (IOLuaHelper)LuaScriptMgr.GetNetObjectSelf(L, 1, "IOLuaHelper"); EnumIOEvent arg0 = (EnumIOEvent)LuaScriptMgr.GetLuaObject(L, 2); int arg1 = (int)LuaDLL.lua_tonumber(L, 3); bool arg2 = LuaDLL.lua_toboolean(L, 4); obj.TriggerListener(arg0, arg1, arg2); return(0); } else { LuaDLL.luaL_error(L, "invalid arguments to method: IOLuaHelper.TriggerListener"); } return(0); }
static int RemoveListener(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(IOLuaHelper), typeof(int), typeof(string))) { IOLuaHelper obj = (IOLuaHelper)LuaScriptMgr.GetNetObjectSelf(L, 1, "IOLuaHelper"); int arg0 = (int)LuaDLL.lua_tonumber(L, 2); string arg1 = LuaScriptMgr.GetString(L, 3); obj.RemoveListener(arg0, arg1); return(0); } else if (count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(IOLuaHelper), typeof(EnumIOEvent), typeof(string))) { IOLuaHelper obj = (IOLuaHelper)LuaScriptMgr.GetNetObjectSelf(L, 1, "IOLuaHelper"); EnumIOEvent arg0 = (EnumIOEvent)LuaScriptMgr.GetLuaObject(L, 2); string arg1 = LuaScriptMgr.GetString(L, 3); obj.RemoveListener(arg0, arg1); return(0); } else { LuaDLL.luaL_error(L, "invalid arguments to method: IOLuaHelper.RemoveListener"); } return(0); }
/// <summary> /// /// </summary> /// <param name="_type"></param> /// <param name="_handle"></param> /// <returns></returns> private bool HasRegestered(EnumIOEvent _type, string _guid) { if (m_eventDict[_type].ContainsKey(_guid)) { Debug.Log("Event " + _guid + " has already been regestered!"); return(true); } return(false); }
/// <summary> /// /// </summary> /// <param name="_type"></param> /// <param name="_handle"></param> public void RegesterListener(EnumIOEvent _type, UtilCommon.OnIOEventHandle _handle, string _guid) { if (!m_eventDict.ContainsKey(_type)) { m_eventDict.Add(_type, new Dictionary <string, UtilCommon.OnIOEventHandle>()); } if (!HasRegestered(_type, _guid)) { m_eventDict[_type].Add(_guid, _handle); } }
/// <summary> /// /// </summary> /// <param name="_type"></param> /// <param name="_handle"></param> public void RemoveListener(EnumIOEvent _type, string _guid) { if (m_eventDict.ContainsKey(_type)) { if (m_eventDict[_type].ContainsKey(_guid)) { m_eventDict[_type].Remove(_guid); } if (m_eventDict[_type].Count <= 0) { m_eventDict.Remove(_type); } } }
/// <summary> /// /// </summary> /// <param name="_type"></param> /// <param name="_playerID"></param> /// <param name="_value"></param> public void TriggerListener(EnumIOEvent _type, int _playerID = 0, bool _flag = true) { if (null == m_eventDict || !m_eventDict.ContainsKey(_type)) { return; } Dictionary <string, UtilCommon.OnIOEventHandle> dict = m_eventDict[_type]; List <UtilCommon.OnIOEventHandle> list = new List <UtilCommon.OnIOEventHandle>(dict.Values); for (int i = 0; i < dict.Count; ++i) { UtilCommon.OnIOEventHandle handle = list[i]; if (null != handle) { handle(_playerID, _flag); } } }
/// <summary> /// /// </summary> /// <param name="_num"></param> /// <param name="_handle"></param> public void RegesterListener(int _num, UtilCommon.OnIOEventHandle _handle, string _guid) { EnumIOEvent _type = (EnumIOEvent)_num; RegesterListener(_type, _handle, _guid); }
/// <summary> /// /// </summary> /// <param name="_num"></param> /// <param name="_playerID"></param> /// <param name="_value"></param> public void TriggerListener(int _num, int _playerID = 0, bool _flag = true) { EnumIOEvent _type = (EnumIOEvent)_num; TriggerListener(_type, _playerID, _flag); }
/// <summary> /// /// </summary> /// <param name="_num"></param> /// <param name="_handle"></param> public void RemoveListener(int _num, string _guid) { EnumIOEvent _type = (EnumIOEvent)_num; RemoveListener(_type, _guid); }
static int RegesterListener(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 4 && LuaScriptMgr.CheckTypes(L, 1, typeof(IOLuaHelper), typeof(int), typeof(UtilCommon.OnIOEventHandle), typeof(string))) { IOLuaHelper obj = (IOLuaHelper)LuaScriptMgr.GetNetObjectSelf(L, 1, "IOLuaHelper"); int arg0 = (int)LuaDLL.lua_tonumber(L, 2); UtilCommon.OnIOEventHandle arg1 = null; LuaTypes funcType3 = LuaDLL.lua_type(L, 3); if (funcType3 != LuaTypes.LUA_TFUNCTION) { arg1 = (UtilCommon.OnIOEventHandle)LuaScriptMgr.GetLuaObject(L, 3); } else { LuaFunction func = LuaScriptMgr.GetLuaFunction(L, 3); arg1 = (param0, param1) => { int top = func.BeginPCall(); LuaScriptMgr.Push(L, param0); LuaScriptMgr.Push(L, param1); func.PCall(top, 2); func.EndPCall(top); }; } string arg2 = LuaScriptMgr.GetString(L, 4); obj.RegesterListener(arg0, arg1, arg2); return(0); } else if (count == 4 && LuaScriptMgr.CheckTypes(L, 1, typeof(IOLuaHelper), typeof(EnumIOEvent), typeof(UtilCommon.OnIOEventHandle), typeof(string))) { IOLuaHelper obj = (IOLuaHelper)LuaScriptMgr.GetNetObjectSelf(L, 1, "IOLuaHelper"); EnumIOEvent arg0 = (EnumIOEvent)LuaScriptMgr.GetLuaObject(L, 2); UtilCommon.OnIOEventHandle arg1 = null; LuaTypes funcType3 = LuaDLL.lua_type(L, 3); if (funcType3 != LuaTypes.LUA_TFUNCTION) { arg1 = (UtilCommon.OnIOEventHandle)LuaScriptMgr.GetLuaObject(L, 3); } else { LuaFunction func = LuaScriptMgr.GetLuaFunction(L, 3); arg1 = (param0, param1) => { int top = func.BeginPCall(); LuaScriptMgr.Push(L, param0); LuaScriptMgr.Push(L, param1); func.PCall(top, 2); func.EndPCall(top); }; } string arg2 = LuaScriptMgr.GetString(L, 4); obj.RegesterListener(arg0, arg1, arg2); return(0); } else { LuaDLL.luaL_error(L, "invalid arguments to method: IOLuaHelper.RegesterListener"); } return(0); }