--- --- Generated by EmmyLua(https://github.com/EmmyLua) --- Created by PZM. --- DateTime: 2024/7/9 11:21 ---@class GlobalEventManger GlobalLuaEventManager = {} local this = GlobalLuaEventManager function this.Init() this.RegistEvents() end function this.RegistEvents() SL:RegisterLUAEvent(LUA_EVENT_ENTER_MAP,this.LUA_EVENT_ENTER_MAP) SL:RegisterLuaNetMsg(LuaMessageIdToClient.TIPS,this.TIPS) SL:RegisterLUAEvent(LUA_EVENT_PLAYER_CREATE, this.LUA_EVENT_PLAYER_CREATE) SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_SEND_GET_REWARD_MSG,this.RES_SEND_GET_REWARD_MSG) -- SL:RegisterLuaNetMsg(LuaMessageIdToClient.AFTER_ENTER_SECRET_REALM,this.AFTER_ENTER_SECRET_REALM) SL:RegisterLUAEvent(LUA_EVENT_CAREER_CHANGED, this.LUA_EVENT_CAREER_CHANGED) SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_ROLE_ATT_ADD_WAY,this.RES_ROLE_ATT_ADD_WAY) --跨服模式变化 SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_IN_OUT_CROSS_MAP,this.RES_IN_OUT_CROSS_MAP) SL:RegisterLuaNetMsg(MessageDef.ResViewUnionMessage,this.ResViewUnionMessage) SL:RegisterLuaNetMsg(MessageDef.ResQuitUnionMessage,this.ResQuitUnionMessage) SL:RegisterTrigger(LUA_TRIGGER_SET_STREAM,this.LUA_TRIGGER_SET_STREAM) SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_RECHARGE_TRADE_INFO,this.RES_RECHARGE_TRADE_INFO) SL:RegisterLUAEvent(LUA_EVENT_PLAYER_ENTER_MAP, this.LUA_EVENT_PLAYER_ENTER_MAP) SL:RegisterLUAEvent(LUA_EVENT_CHALLENGE_BOSS_MONSTER_POS_AFTER, this.LUA_EVENT_CHALLENGE_BOSS_MONSTER_POS_AFTER) SL:RegisterLUAEvent(LUA_EVENT_ROLE_LOGIN, this.LUA_EVENT_ROLE_LOGIN) SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_TASK_STATES_TO_FUNC_ON,this.RES_TASK_STATES_TO_FUNC_ON_MESSAGE) end function this:LUA_EVENT_ROLE_LOGIN() SL:SetLocalString("showMaxBagTips", "true") end function this.UnRegistEvents() SL:UnRegisterLUAEvent(LUA_EVENT_ENTER_MAP,this.LUA_EVENT_ENTER_MAP) SL:RegisterLUAEvent(LUA_EVENT_PLAYER_CREATE, this.LUA_EVENT_PLAYER_CREATE) SL:UnRegisterLuaNetMsg(LuaMessageIdToClient.RES_SEND_GET_REWARD_MSG,this.RES_SEND_GET_REWARD_MSG) SL:UnRegisterLUAEvent(LUA_EVENT_CAREER_CHANGED, this.LUA_EVENT_CAREER_CHANGED) SL:UnRegisterLuaNetMsg(LuaMessageIdToClient.RES_ROLE_ATT_ADD_WAY,this.RES_ROLE_ATT_ADD_WAY) SL:UnRegisterLuaNetMsg(LuaMessageIdToClient.RES_IN_OUT_CROSS_MAP,this.RES_IN_OUT_CROSS_MAP) SL:UnRegisterLuaNetMsg(MessageDef.ResViewUnionMessage,this.ResViewUnionMessage) SL:UnRegisterLuaNetMsg(MessageDef.ResQuitUnionMessage,this.ResQuitUnionMessage) SL:UnRegisterLUAEvent(LUA_EVENT_PLAYER_ENTER_MAP, this.LUA_EVENT_PLAYER_ENTER_MAP) SL:UnRegisterLUAEvent(LUA_EVENT_CHALLENGE_BOSS_MONSTER_POS_AFTER, this.LUA_EVENT_CHALLENGE_BOSS_MONSTER_POS_AFTER) SL:UnRegisterLUAEvent(LUA_EVENT_EXIT_GAME, this.LUA_EVENT_EXIT_GAME) SL:UnRegisterLUAEvent(LuaMessageIdToClient.RES_TASK_STATES_TO_FUNC_ON,this.RES_TASK_STATES_TO_FUNC_ON_MESSAGE) end function this.Reset() this.UnRegistEvents() end function this.LUA_TRIGGER_SET_STREAM(_,go, roleId,itemCfgId,strengthLevel) if not SL:HasConfig('cfg_equip_strengthen',itemCfgId) then return end if not this.tempEqupInfo then this.tempEqupInfo = {} end this.tempEqupInfo.cfgId = itemCfgId local liuGuangId = EquipFunc.GetEquipLiuGuangId(this.tempEqupInfo,strengthLevel) if liuGuangId then SL:SetMetaValue(EMetaVarSetKey.EQUIP_STREAMER_REFRESH,go,liuGuangId) end end --进入地图 预显示界面 function this.LUA_EVENT_ENTER_MAP(_, eventData) local isChangeMap = eventData GUI:UIPanel_Open("dev/outui/ExpMessage/Panel/KLUIExpMessage/KLUIExpMessagePanel") GUI:UIPanel_Open("dev/outui/Message/Panel/KLHorseRaceLamp/KLHorseRaceLampPanel") GUI:UIPanel_Open("dev/outui/Activity/Panel/KLActivityPreview/KLActivityPreviewPanel") Coroutine.Start(function() --预打开一下 if not isChangeMap then Coroutine.WaitForEndOfFrame() GUI:UIPanel_Open("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel", nil, nil, { x = -400, y = 0, relatePanel = "",isPreLoad = true }) GUI:UIPanel_Close("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel") end end) GUI:UIPanel_Open("dev/ui/Common/Panel/KLTop/KLTopPanel") --this.PreLoad() end function this.PreLoad(...) if this.isHasPreLoad then return end this.isHasPreLoad = true local co = Coroutine.Start(function() --Coroutine.WaitForEndOfFrame() --GUI:PreLoadUI("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel", 1) Coroutine.WaitForEndOfFrame() GUI:PreLoadUI("dev/ui/Bag/Panel/KLUIBag/KLUIBagPanel", 1) --Coroutine.WaitForEndOfFrame() --GUI:PreLoadUI("dev/ui/Common/Item/KLBagItem/KLBagItemItem",50) end ) end function this:TIPS(message) SL:TipMessage(message, 1, NoticeType.NoticeMid) end ---@param data {player:Player} function this.LUA_EVENT_PLAYER_CREATE(_,data) end function this.RES_SEND_GET_REWARD_MSG(_,data) local reward = {} for k, v in pairs(data) do reward[tonumber(k)] = tonumber(v) end SL:OpenRewardTips(reward,0) end ---进入秘境副本成功回包 function this.AFTER_ENTER_SECRET_REALM(_,data) local mapId = data.mapId GUI:UIPanel_Open("dev/outui/ChallengeBoss/Panel/KLChallengeBossPos/KLChallengeBossPosPanel",nil,nil,{mapId=mapId}) end --职业改变 function this.LUA_EVENT_CAREER_CHANGED(_, data) local preCareer = data.currentCareer local nextCareer = data.newCareer ---@type cfg_career_column local careerConfig = SL:GetConfig("cfg_career", nextCareer) if careerConfig.window == 1 then GUI:UIPanel_Open("dev/outui/Career/Panel/KLCareerChangePanel/KLCareerChangePanel", nil, nil, { currentCareer = nextCareer, originalCareer = preCareer }) end end function this.RES_ROLE_ATT_ADD_WAY(_,data) local addWay = data SL:MeData_GetRoleExtInfo().attAddWay = addWay SL:onLUAEvent(LUA_EVENT_SURE_ATTR_PLAN, data) end function this.RES_IN_OUT_CROSS_MAP(id, message) this.isCrossServer = message.type if this.isCrossServer and this.isCrossServer == 1 then if not SL:MeData_GetUnionId() or SL:MeData_GetUnionId() == 0 then SL:SetMetaValue(EMetaVarSetKey.SET_PKMODE, 0) SL:onLUAEvent(LUA_EVENT_CROSS_SERVER_PK_MODE,0) else SL:SetMetaValue(EMetaVarSetKey.SET_PKMODE, 5) SL:onLUAEvent(LUA_EVENT_CROSS_SERVER_PK_MODE,5) end end end function this.ResViewUnionMessage(id, message) if message.unionInfo and message.unionInfo.unionId then if this.isCrossServer and this.isCrossServer == 1 then if not SL:MeData_GetUnionId() or SL:MeData_GetUnionId() == 0 then SL:SetMetaValue(EMetaVarSetKey.SET_PKMODE, 0) SL:onLUAEvent(LUA_EVENT_CROSS_SERVER_PK_MODE,0) else SL:SetMetaValue(EMetaVarSetKey.SET_PKMODE, 5) SL:onLUAEvent(LUA_EVENT_CROSS_SERVER_PK_MODE,5) end end end end function this.ResQuitUnionMessage(id, message) if message.isQuit then if this.isCrossServer and this.isCrossServer == 1 then SL:SetMetaValue(EMetaVarSetKey.SET_PKMODE, 0) SL:onLUAEvent(LUA_EVENT_CROSS_SERVER_PK_MODE,0) end end end function this.LUA_EVENT_CHALLENGE_BOSS_MONSTER_POS_AFTER(id, message) this.data_LUA_EVENT_CHALLENGE_BOSS_MONSTER_POS_AFTER = message end function this.check_LUA_EVENT_CHALLENGE_BOSS_MONSTER_POS_AFTER(message) if not this.data_LUA_EVENT_CHALLENGE_BOSS_MONSTER_POS_AFTER then return end SL:ScheduleOnce(0.3, function() this.start_LUA_EVENT_CHALLENGE_BOSS_MONSTER_POS_AFTER(message) end) end function this.start_LUA_EVENT_CHALLENGE_BOSS_MONSTER_POS_AFTER(message) if not this.data_LUA_EVENT_CHALLENGE_BOSS_MONSTER_POS_AFTER then return end local message = this.data_LUA_EVENT_CHALLENGE_BOSS_MONSTER_POS_AFTER this.data_LUA_EVENT_CHALLENGE_BOSS_MONSTER_POS_AFTER = nil local map_id = SL:GetMetaValue(EMetaVarGetKey.MAP_ID) local map_line = SL:GetMetaValue(EMetaVarGetKey.MAP_LINE) if message.mapCfgId ~= map_id or message.line ~= map_line then return end local me_x = SL:MeData_GetCoord().x local me_y = SL:MeData_GetCoord().z local all_monster = {} local all_status = SL:GetMapMonsterStatus() local one = 1 for i, data in ipairs(all_status) do if data.configId == message.monsterCfgId and data.status == one then table.insert(all_monster,{configId=data.configId,x=data.pointX,y=data.pointY}) end end local num = 0 local index = 0 --SL:OpenWaitingUI({ msg = "寻怪中"}) local current_index = 1 local is_end = false this.wait = SL:Schedule(this.wait,0,Time.deltaTime,-1, function() if is_end then return end local current_time = Time.GetServerTime() if current_index <= #all_monster then local data = all_monster[current_index] local arrive, path = SL:SearchPath({x=me_x,z=me_y}, {x=data.x,z=data.y}) if arrive then data.num = path.n if num == 0 then num = data.num index = current_index else if num > data.num then num = data.num index = current_index end end end if current_index <= #all_monster then current_index = current_index+1 return end end if index > 0 then local pos_data = all_monster[index] SL:StopOnHook(true) this.pos_monster_id = message.monsterCfgId this.map_data = {message.mapCfgId, message.line, pos_data.x, pos_data.y} SL:Pathfinding(message.mapCfgId, message.line, pos_data.x, pos_data.y,this.MonserPosEnd,this.pos_monster_id) --SL:HideWaitingUI() SL:UnSchedule(this.wait) end end) end function this.LUA_EVENT_PLAYER_ENTER_MAP(id, message) this.check_LUA_EVENT_CHALLENGE_BOSS_MONSTER_POS_AFTER(message) end function this.MonserPosEnd(pos) if pos and pos.x and pos.z then this.scheduleId = SL:ScheduleOnce(0.1, function() SL:Pathfinding( this.map_data[1], this.map_data[2], pos.x, pos.z,this.BossPointOnHook) end) else SL:StartOnHook(true,true,this.pos_monster_id) end end function this.BossPointOnHook() SL:StartOnHook(true,true,this.pos_monster_id) end ---@param message recharge function this.RES_RECHARGE_TRADE_INFO(_,message) --[[if message and message.bubble then SL:onLUAEvent(LUA_EVENT_BUBBLETIPS_ADD,{id=PopoverType.Tip_MonthCardQJQuota}) else SL:onLUAEvent(LUA_EVENT_BUBBLETIPS_DEL,PopoverType.Tip_MonthCardQJQuota) end]] end function this.RES_TASK_STATES_TO_FUNC_ON_MESSAGE(_,message) if message then SL:ClearSystemFunctionState() local tempData = {} ---@type cfg_career_column local careerTbl = SL:GetMetaValue(EMetaVarGetKey.ME_CAREER_TAB_COLUMN) if careerTbl then for i, v in pairs(message) do local taskId = tonumber(i) local taskState = tonumber(v) ---@type cfg_system_switch_column[] --local tblList = cfg_system_switch_post.GetSystemBtnGetTaskInfo(careerTbl.id,taskId) local tblList = SL:CfgSystemSwitchPost_GetSystemBtnGetTaskInfo(careerTbl.id,taskId) if tblList then for j, k in pairs(tblList) do SL:SetMetaValue(EMetaVarSetKey.SET_SYSTEM_FUNCTION_TASK_STATE,k.systemName,taskState == TaskState.Accepted) tempData[k.btnPath] = k.btnPath end end ---@type cfg_system_switch_column[] --tblList = cfg_system_switch_post.GetSystemBtnFinishedTaskInfo(careerTbl.id,taskId) tblList = SL:CfgSystemSwitchPost_GetSystemBtnGetTaskInfo(careerTbl.id,taskId) if tblList then for j, k in pairs(tblList) do SL:SetMetaValue(EMetaVarSetKey.SET_SYSTEM_FUNCTION_TASK_STATE,k.systemName,SL:GetMetaValue(EMetaVarGetKey.GET_SYSTEM_FUNCTION_TASK_STATE,k.systemName) and true or taskState == TaskState.Completed) tempData[k.systemName] = k.btnPath end end end end for systemName, btnPath in pairs(tempData) do local isShow = SL:GetMetaValue(EMetaVarGetKey.IS_OPEN_SYSTEMFUNCTION, systemName) SL:ControlSystemPortalVisible(btnPath, isShow) end end end