Initial version - 1.2.0.60
EN: 1.2.0.60 CN: 1.2.0.61 JP: 1.2.0.63 KR: 1.2.0.67
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
local EntityEvent = class("EntityEvent")
|
||||
function EntityEvent:ctor(listener, nEntityId, callback)
|
||||
self._listener = listener
|
||||
self.nEntityId = nEntityId
|
||||
if type(callback) == "function" then
|
||||
self._callback = callback
|
||||
elseif type(callback) == "string" then
|
||||
local cb = listener[callback]
|
||||
if type(cb) == "function" then
|
||||
self._callback = cb
|
||||
else
|
||||
self._callback = nil
|
||||
end
|
||||
else
|
||||
self._callback = nil
|
||||
end
|
||||
end
|
||||
return EntityEvent
|
||||
@@ -0,0 +1,17 @@
|
||||
local Event = class("Event")
|
||||
function Event:ctor(listener, callback)
|
||||
self._listener = listener
|
||||
if type(callback) == "function" then
|
||||
self._callback = callback
|
||||
elseif type(callback) == "string" then
|
||||
local cb = listener[callback]
|
||||
if type(cb) == "function" then
|
||||
self._callback = cb
|
||||
else
|
||||
self._callback = nil
|
||||
end
|
||||
else
|
||||
self._callback = nil
|
||||
end
|
||||
end
|
||||
return Event
|
||||
@@ -0,0 +1,179 @@
|
||||
local EventId = {
|
||||
CSLuaManagerShutdown = 0,
|
||||
TemporaryBlockInput = 1,
|
||||
MainViewUIVisible = 2,
|
||||
MarkFullRectWH = 3,
|
||||
UIOperate = 4,
|
||||
HideProloguePanle = 5,
|
||||
UserEvent_CreateRole = 6.001,
|
||||
OpenPanel = 10,
|
||||
ClosePanel = 11,
|
||||
CloesCurPanel = 11.1,
|
||||
OpenMessageBox = 12,
|
||||
CloseMessageBox = 12.1,
|
||||
ClosePopupTips = 12.2,
|
||||
OpenLoading = 13,
|
||||
BlockInput = 14,
|
||||
UIBackConfirm = 15,
|
||||
UIHomeConfirm = 16,
|
||||
ShopPurchaseSuccess = 17,
|
||||
UpdateEnergy = 18,
|
||||
UpdateEnergyBattery = 18.1,
|
||||
UpdateWorldClass = 19,
|
||||
WorldMapOpenMonsterDetail = 20,
|
||||
WorldMapOpenRewardDetail = 20.1,
|
||||
SetSubTitle = 22,
|
||||
ClickWord = 22.1,
|
||||
StarTowerPass = 22.2,
|
||||
OpenLampNotice = 23,
|
||||
CloseLampNotice = 24,
|
||||
DoTweenPauseAll = 25,
|
||||
FormationLoadModel = 21,
|
||||
EquipmentChangeLockState = 47,
|
||||
DepotRefreshList = 53,
|
||||
RogueBossRewardOpenDetail = 55,
|
||||
RogueBossPausePanel = 56,
|
||||
DelBuildItemId = 57,
|
||||
OpenCharacterScreenPanel = 58,
|
||||
CharacterScreenConfirm = 59,
|
||||
CharacterSkinChange = 59.1,
|
||||
JumptoClick = 60,
|
||||
ClickStoneAdd = 61,
|
||||
OpenShopToggle = 62,
|
||||
QuestDataRefresh = 63,
|
||||
DailyQuestReceived = 63.1,
|
||||
TourQuestReceived = 63.2,
|
||||
TRChallengeQusetReceived = 63.3,
|
||||
TRNormalQusetReceived = 63.4,
|
||||
TourGroupReceived = 63.5,
|
||||
DailyQuestActiveReceived = 63.6,
|
||||
TutorialQuestReceived = 63.7,
|
||||
IsNewDay = 64,
|
||||
NewFuncUnlockWorldClass = 65,
|
||||
OpenFixedRoguelikeShop = 67,
|
||||
FixedRogueOpenTalentSkillSelect = 68,
|
||||
FixedRogueSelectTalentSkill = 69,
|
||||
OpenFixedRoguelikeDepotBtn = 70,
|
||||
OpenFixedRoguelikeDepotPanel = 71,
|
||||
FixedRoguelikeNotify = 72,
|
||||
FixedRoguelikeTeamLevelUp = 72.5,
|
||||
FixedRoguelikeQuestUpdate = 72.6,
|
||||
FixedRoguelikeQuestComplet = 72.7,
|
||||
FixedRoguelikeLevelUpNotify = 72.4,
|
||||
FixedRogueShowCompound = 73,
|
||||
FixedRogueShowLevelUp = 74,
|
||||
AvgClearAllChar = 90,
|
||||
AvgClearTalk = 91.1,
|
||||
AvgClearStage = 91.2,
|
||||
AvgSetCurtain = 91.3,
|
||||
AvgEnableStageCamera = 91.4,
|
||||
AvgShowHideTalkUI = 92,
|
||||
AvgAllMenuBtnEnable = 92.1,
|
||||
AvgSetAutoPlay = 93,
|
||||
AvgShowHideLog = 94,
|
||||
AvgMarkLog = 94.1,
|
||||
AvgLogBtnEnable = 94.2,
|
||||
AvgChoiceToReplyPhoneMessage = 94.3,
|
||||
AvgSkip = 95,
|
||||
AvgSkipCheck = 95.1,
|
||||
AvgSkipCheckIntro = 95.2,
|
||||
AvgChoiceMainRoleOS_In = 97,
|
||||
AvgChoiceMainRoleOS_Out = 98,
|
||||
AvgMainRoleTalk_Set = 98.1,
|
||||
AvgMainRoleTalk_Switch = 98.2,
|
||||
AvgMainRoleTalk_SetEmoji = 98.3,
|
||||
AvgMainRoleTalk_Shake = 98.4,
|
||||
AvgMainRoleTalk_Reset = 98.5,
|
||||
AvgTryResume = 98.6,
|
||||
AvgSpeedUp = 98.7,
|
||||
AvgResetSpeed = 98.8,
|
||||
AvgShowNextPhoneMessage = 99,
|
||||
AvgSelectPhoneMsgChoice = 99.1,
|
||||
AvgSetToPhoneMsgChoiceEnd = 99.3,
|
||||
AvgRefreshActionBar = 99.4,
|
||||
AvgBubbleShutDown = 96,
|
||||
AvgBubbleExit = "AvgBubbleExit",
|
||||
AvgBubbleShow = "AvgBubbleShow",
|
||||
AvgL2DAnimEvent_Start = "start",
|
||||
AvgL2DAnimEvent_Next = "next",
|
||||
AvgL2DAnimEvent_End = "end",
|
||||
AvgL2DAnimEvent_Done = "done",
|
||||
AvgL2DAnimEvent_FX = "cgfx",
|
||||
AvgL2DAnimEvent_LFX_ON = "lcgfx_on",
|
||||
AvgL2DAnimEvent_LFX_OFF = "lcgfx_off",
|
||||
AvgVoiceDuration = "AvgVoiceDuration",
|
||||
AvgVoiceEnd = "AvgVoiceEnd",
|
||||
WWiseVoiceEnd = "WWiseVoiceEnd",
|
||||
CoinResChange = 100,
|
||||
SetTopBarVisible = 101,
|
||||
SetCoinVisible = 101.1,
|
||||
SetEnergyVisible = 101.2,
|
||||
ShowSelectPerkPanel = 102,
|
||||
ShowSelectThemePerkPanel = 102.1,
|
||||
SelectPerk = 103,
|
||||
OpenOrCloseRogueBossPanel = 104,
|
||||
BattleDashboardVisible = 105,
|
||||
PasueAvgBubble = 199,
|
||||
MoveAvgBubbleRoot = 199.1,
|
||||
SendMsgEnterBattle = 200,
|
||||
EnterMainline = 201,
|
||||
AbandonBattle = 202,
|
||||
ChoseMainlineStory = 203,
|
||||
SendMsgEnterRoguelike = 300,
|
||||
AbandonRoguelike = 301,
|
||||
EnterRoguelike = 302,
|
||||
ShowRoguelikeDrop = 303,
|
||||
RoguelikePause = 305,
|
||||
AfterEnterMain = 306,
|
||||
RefrushMailView = 307,
|
||||
ShowCharacterSkillTips = 308,
|
||||
ShowCharacterTalentTips = 308.1,
|
||||
ShowTalentSkillTips = 308.2,
|
||||
ShowMonsterSkillTips = 308.3,
|
||||
ShowItemTips = 308.4,
|
||||
SetTransition = 309,
|
||||
TransAnimInClear = 309.1,
|
||||
TransAnimOutClear = 309.2,
|
||||
RefreshFateView = 310,
|
||||
RefreshFatePerkView = 311,
|
||||
WeaponRefresh = 312,
|
||||
RoguelikeMap = 313,
|
||||
BoardItemDragStart = 314,
|
||||
BoardItemDragging = 315,
|
||||
BoardItemDragEnd = 316,
|
||||
BoardItemOrderFinish = 317,
|
||||
BoardSelectItem = 318,
|
||||
BoardStartHangTimer = 319,
|
||||
ShowBubbleVoiceText = "ShowBubbleVoiceText",
|
||||
CharBgRefresh = 330,
|
||||
CharRelatePanelOpen = 331,
|
||||
CharRelatePanelClose = 332,
|
||||
CharRelatePanelAdvance = 333,
|
||||
CharRelatePanelBack = 334,
|
||||
PlayWeaponFadeAnim = 335,
|
||||
SubSkillDisplayInit = 336,
|
||||
AffinityQuestReceived = 337,
|
||||
AffinityChange = 338,
|
||||
ActivityDataChange = 340,
|
||||
LookUpCharStory = 341,
|
||||
JumpToSuccess = 350,
|
||||
HideCharBgActor = 351,
|
||||
RevertCharBgActor = 352,
|
||||
StarTowerLeave = 353,
|
||||
StarTowerMap = 401,
|
||||
StarTowerDepot = 402,
|
||||
FilterConfirm = 501,
|
||||
DispatchOpenCharList = 502,
|
||||
DispatchOpenBuildList = 503,
|
||||
DispatchReceiveReward = 504,
|
||||
DispatchCloseResultPanel = 505,
|
||||
DispatchRefreshPanel = 506,
|
||||
SettingsBattleClose = 510,
|
||||
CharTalentUIVisible = 511,
|
||||
GMToolShow = 998,
|
||||
GMToolClose = 998.1,
|
||||
GMToolClosePanel = 998.2,
|
||||
GMToolSelectOrder = 998.3,
|
||||
GMToolOpen = 999
|
||||
}
|
||||
return EventId
|
||||
@@ -0,0 +1,370 @@
|
||||
local Event = require("GameCore.Event.Event")
|
||||
local EntityEvent = require("GameCore.Event.EntityEvent")
|
||||
local TimerManager
|
||||
local TimerScaleType = require("GameCore.Timer.TimerScaleType")
|
||||
local TimerResetType = require("GameCore.Timer.TimerResetType")
|
||||
local EventManager = {}
|
||||
local mapEvent, mapTempAdd, mapTempRemove, mapOnHitEventId, timerCheckReset
|
||||
local timerCallback = function()
|
||||
local sEvent = ""
|
||||
for nId, _ in pairs(mapOnHitEventId or {}) do
|
||||
sEvent = sEvent .. tostring(nId) .. ", "
|
||||
end
|
||||
if sEvent ~= "" then
|
||||
printLog("EventManager 检查,没有复位事件:" .. sEvent)
|
||||
end
|
||||
end
|
||||
local CheckReset = function()
|
||||
if TimerManager == nil then
|
||||
TimerManager = require("GameCore.Timer.TimerManager")
|
||||
end
|
||||
if timerCheckReset == nil then
|
||||
timerCheckReset = TimerManager.Add(0, 10, EventManager, timerCallback, true, false, TimerScaleType.RealTime)
|
||||
else
|
||||
timerCheckReset:Reset(TimerResetType.ResetElapsed)
|
||||
end
|
||||
end
|
||||
local Pairlist = function(...)
|
||||
local tbParam = {}
|
||||
for i = 1, select("#", ...) do
|
||||
local param = select(i, ...)
|
||||
table.insert(tbParam, param)
|
||||
end
|
||||
return tbParam
|
||||
end
|
||||
local ProcAdd = function(nEventId)
|
||||
if mapEvent == nil or mapTempAdd == nil then
|
||||
return
|
||||
end
|
||||
local tbEventAdd = mapTempAdd[nEventId]
|
||||
if tbEventAdd == nil then
|
||||
return
|
||||
end
|
||||
if mapEvent[nEventId] == nil then
|
||||
mapTempAdd[nEventId] = nil
|
||||
return
|
||||
end
|
||||
local tbEventExist = mapEvent[nEventId]
|
||||
for iAdd, eventAdd in ipairs(tbEventAdd) do
|
||||
local bCanAdd = true
|
||||
for iExist, eventExist in ipairs(tbEventExist) do
|
||||
if eventExist._listener == eventAdd._listener and eventExist._callback == eventAdd._callback then
|
||||
bCanAdd = false
|
||||
break
|
||||
end
|
||||
end
|
||||
if bCanAdd == true then
|
||||
table.insert(tbEventExist, eventAdd)
|
||||
end
|
||||
end
|
||||
mapTempAdd[nEventId] = nil
|
||||
end
|
||||
local ProcRemove = function(nEventId)
|
||||
if mapEvent == nil or mapTempRemove == nil then
|
||||
return
|
||||
end
|
||||
local tbEventRemove = mapTempRemove[nEventId]
|
||||
if tbEventRemove == nil then
|
||||
return
|
||||
end
|
||||
if mapEvent[nEventId] == nil then
|
||||
mapTempRemove[nEventId] = nil
|
||||
return
|
||||
end
|
||||
local tbEventExist = mapEvent[nEventId]
|
||||
for iRemove, eventRemove in ipairs(tbEventRemove) do
|
||||
local nIndexExist
|
||||
for iExist, eventExist in ipairs(tbEventExist) do
|
||||
if eventExist._listener == eventRemove._listener and eventExist._callback == eventRemove._callback then
|
||||
nIndexExist = iExist
|
||||
break
|
||||
end
|
||||
end
|
||||
if nIndexExist ~= nil then
|
||||
table.remove(tbEventExist, nIndexExist)
|
||||
end
|
||||
end
|
||||
mapTempRemove[nEventId] = nil
|
||||
end
|
||||
function EventManager.Init()
|
||||
mapEvent = {}
|
||||
mapTempAdd = {}
|
||||
mapTempRemove = {}
|
||||
mapOnHitEventId = {}
|
||||
EventManager.InitEntityEvent()
|
||||
end
|
||||
function EventManager.Add(nEventId, listener, callback)
|
||||
if mapEvent == nil or mapOnHitEventId == nil or mapTempAdd == nil then
|
||||
return
|
||||
end
|
||||
if listener == nil or callback == nil then
|
||||
return
|
||||
end
|
||||
if mapOnHitEventId[nEventId] == nil then
|
||||
if mapEvent[nEventId] == nil then
|
||||
mapEvent[nEventId] = {}
|
||||
end
|
||||
local tbEvent = mapEvent[nEventId]
|
||||
for i, event in ipairs(tbEvent) do
|
||||
if event._listener == listener and event._callback == callback then
|
||||
return
|
||||
end
|
||||
end
|
||||
table.insert(tbEvent, Event.new(listener, callback))
|
||||
else
|
||||
if mapTempAdd[nEventId] == nil then
|
||||
mapTempAdd[nEventId] = {}
|
||||
end
|
||||
local tbEventAdd = mapTempAdd[nEventId]
|
||||
for i, eventAdd in ipairs(tbEventAdd) do
|
||||
if eventAdd._listener == listener and eventAdd._callback == callback then
|
||||
return
|
||||
end
|
||||
end
|
||||
table.insert(tbEventAdd, Event.new(listener, callback))
|
||||
end
|
||||
end
|
||||
function EventManager.Remove(nEventId, listener, callback)
|
||||
if mapEvent == nil or mapOnHitEventId == nil or mapTempRemove == nil then
|
||||
return
|
||||
end
|
||||
if listener == nil or callback == nil then
|
||||
return
|
||||
end
|
||||
if mapOnHitEventId[nEventId] == nil then
|
||||
local tbEvent = mapEvent[nEventId]
|
||||
if tbEvent == nil then
|
||||
return
|
||||
end
|
||||
local nIndex
|
||||
for i, event in ipairs(tbEvent) do
|
||||
if event._listener == listener and event._callback == callback then
|
||||
nIndex = i
|
||||
break
|
||||
end
|
||||
end
|
||||
if nIndex ~= nil then
|
||||
table.remove(tbEvent, nIndex)
|
||||
end
|
||||
else
|
||||
if mapTempRemove[nEventId] == nil then
|
||||
mapTempRemove[nEventId] = {}
|
||||
end
|
||||
local tbEventRemove = mapTempRemove[nEventId]
|
||||
for iRemove, eventRemove in ipairs(tbEventRemove) do
|
||||
if eventRemove._listener == listener and eventRemove._callback == callback then
|
||||
return
|
||||
end
|
||||
end
|
||||
table.insert(tbEventRemove, Event.new(listener, callback))
|
||||
end
|
||||
end
|
||||
function EventManager.RemoveAll(nEventId)
|
||||
mapEvent[nEventId] = nil
|
||||
mapTempAdd[nEventId] = nil
|
||||
mapTempRemove[nEventId] = nil
|
||||
end
|
||||
function EventManager.Hit(nEventId, ...)
|
||||
if mapEvent == nil or mapOnHitEventId == nil then
|
||||
return
|
||||
end
|
||||
CheckReset()
|
||||
local tbEvent = mapEvent[nEventId]
|
||||
if tbEvent ~= nil and mapOnHitEventId[nEventId] == nil then
|
||||
mapOnHitEventId[nEventId] = true
|
||||
for i, event in ipairs(tbEvent) do
|
||||
if event ~= nil and event._listener ~= nil and event._callback ~= nil then
|
||||
if AVG_EDITOR == true then
|
||||
local bIgnore = false
|
||||
if event._listener.GetPanelId ~= nil and AVG_EDITOR_PLAYING == true and event._listener:GetPanelId() == PanelId.AvgEditor then
|
||||
bIgnore = true
|
||||
end
|
||||
if bIgnore ~= true then
|
||||
event._callback(event._listener, ...)
|
||||
end
|
||||
else
|
||||
event._callback(event._listener, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
mapOnHitEventId[nEventId] = nil
|
||||
ProcAdd(nEventId)
|
||||
ProcRemove(nEventId)
|
||||
end
|
||||
end
|
||||
local mapEntityEvent, mapTempEntityEventAdd, mapTempEntityEventRemove, mapOnHitEntityEventId
|
||||
local ProcAddEntityEvent = function(nEventId)
|
||||
if mapEntityEvent == nil or mapTempEntityEventAdd == nil then
|
||||
return
|
||||
end
|
||||
local _mapExist = mapEntityEvent[nEventId]
|
||||
local _mapAdd = mapTempEntityEventAdd[nEventId]
|
||||
if _mapAdd == nil then
|
||||
return
|
||||
end
|
||||
if _mapExist == nil then
|
||||
mapTempEntityEventAdd[nEventId] = nil
|
||||
return
|
||||
end
|
||||
for nEntityId, tbEntityEventAdd in pairs(_mapAdd) do
|
||||
local tbEntityEventExist = _mapExist[nEntityId]
|
||||
if tbEntityEventExist == nil then
|
||||
_mapExist[nEntityId] = {}
|
||||
tbEntityEventExist = _mapExist[nEntityId]
|
||||
end
|
||||
for i, entityEventAdd in ipairs(tbEntityEventAdd) do
|
||||
local bCanAdd = true
|
||||
for ii, entityEventExist in ipairs(tbEntityEventExist) do
|
||||
if entityEventExist._listener == entityEventAdd._listener and entityEventExist._callback == entityEventAdd._callback then
|
||||
bCanAdd = false
|
||||
break
|
||||
end
|
||||
end
|
||||
if bCanAdd == true then
|
||||
table.insert(tbEntityEventExist, entityEventAdd)
|
||||
end
|
||||
end
|
||||
end
|
||||
mapTempEntityEventAdd[nEventId] = nil
|
||||
end
|
||||
local ProcRemoveEntityEvent = function(nEventId)
|
||||
if mapEntityEvent == nil or mapTempEntityEventRemove == nil then
|
||||
return
|
||||
end
|
||||
local _mapExist = mapEntityEvent[nEventId]
|
||||
local _mapRemove = mapTempEntityEventRemove[nEventId]
|
||||
if _mapRemove == nil then
|
||||
return
|
||||
end
|
||||
if _mapExist == nil then
|
||||
mapTempEntityEventRemove[nEventId] = nil
|
||||
return
|
||||
end
|
||||
for nEntityId, tbEntityEventRemove in pairs(_mapRemove) do
|
||||
local tbEntityEventExist = _mapExist[nEntityId]
|
||||
if tbEntityEventExist ~= nil then
|
||||
for i, entityEventRemove in ipairs(tbEntityEventRemove) do
|
||||
local nIndexExist
|
||||
for ii, entityEventExist in ipairs(tbEntityEventExist) do
|
||||
if entityEventExist._listener == entityEventRemove._listener and entityEventExist._callback == entityEventRemove._callback then
|
||||
nIndexExist = ii
|
||||
break
|
||||
end
|
||||
end
|
||||
if nIndexExist ~= nil then
|
||||
table.remove(tbEntityEventExist, nIndexExist)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
mapTempEntityEventRemove[nEventId] = nil
|
||||
end
|
||||
function EventManager.InitEntityEvent()
|
||||
mapEntityEvent = {}
|
||||
mapTempEntityEventAdd = {}
|
||||
mapTempEntityEventRemove = {}
|
||||
mapOnHitEntityEventId = {}
|
||||
end
|
||||
function EventManager.AddEntityEvent(nEventId, nEntityId, listener, callback)
|
||||
if mapEntityEvent == nil or mapOnHitEntityEventId == nil or mapTempEntityEventAdd == nil then
|
||||
return
|
||||
end
|
||||
if nEntityId == nil or listener == nil or callback == nil then
|
||||
return
|
||||
end
|
||||
if mapOnHitEntityEventId[nEventId] == nil then
|
||||
if mapEntityEvent[nEventId] == nil then
|
||||
mapEntityEvent[nEventId] = {}
|
||||
end
|
||||
local _map = mapEntityEvent[nEventId]
|
||||
if _map[nEntityId] == nil then
|
||||
mapEntityEvent[nEventId][nEntityId] = {}
|
||||
end
|
||||
local tbEntityEvent = _map[nEntityId]
|
||||
for i, entityEvent in ipairs(tbEntityEvent) do
|
||||
if entityEvent._listener == listener and entityEvent._callback == callback then
|
||||
return
|
||||
end
|
||||
end
|
||||
table.insert(tbEntityEvent, EntityEvent.new(listener, nEntityId, callback))
|
||||
else
|
||||
if mapTempEntityEventAdd[nEventId] == nil then
|
||||
mapTempEntityEventAdd[nEventId] = {}
|
||||
end
|
||||
local _map = mapTempEntityEventAdd[nEventId]
|
||||
if _map[nEntityId] == nil then
|
||||
mapTempEntityEventAdd[nEventId][nEntityId] = {}
|
||||
end
|
||||
local tbEntityEventAdd = _map[nEntityId]
|
||||
for i, entityEventAdd in ipairs(tbEntityEventAdd) do
|
||||
if entityEventAdd._listener == listener and entityEventAdd._callback == callback then
|
||||
return
|
||||
end
|
||||
end
|
||||
table.insert(tbEntityEventAdd, EntityEvent.new(listener, nEntityId, callback))
|
||||
end
|
||||
end
|
||||
function EventManager.RemoveEntityEvent(nEventId, nEntityId, listener, callback)
|
||||
if mapEntityEvent == nil or mapOnHitEntityEventId == nil or mapTempEntityEventRemove == nil then
|
||||
return
|
||||
end
|
||||
if nEntityId == nil or listener == nil or callback == nil then
|
||||
return
|
||||
end
|
||||
if mapOnHitEntityEventId[nEventId] == nil then
|
||||
local _map = mapEntityEvent[nEventId]
|
||||
if _map == nil then
|
||||
return
|
||||
end
|
||||
local tbEntityEvent = _map[nEntityId]
|
||||
if tbEntityEvent == nil then
|
||||
return
|
||||
end
|
||||
local nIndex
|
||||
for i, entityEvent in ipairs(tbEntityEvent) do
|
||||
if entityEvent._listener == listener and entityEvent._callback == callback then
|
||||
nIndex = i
|
||||
break
|
||||
end
|
||||
end
|
||||
if nIndex ~= nil then
|
||||
table.remove(tbEntityEvent, nIndex)
|
||||
end
|
||||
else
|
||||
if mapTempEntityEventRemove[nEventId] == nil then
|
||||
mapTempEntityEventRemove[nEventId] = {}
|
||||
end
|
||||
local _map = mapTempEntityEventRemove[nEventId]
|
||||
if _map[nEntityId] == nil then
|
||||
mapTempEntityEventRemove[nEventId][nEntityId] = {}
|
||||
end
|
||||
local tbEntityEventRemove = _map[nEntityId]
|
||||
for i, entityEventRemove in ipairs(tbEntityEventRemove) do
|
||||
if entityEventRemove._listener == listener and entityEventRemove._callback == callback then
|
||||
return
|
||||
end
|
||||
end
|
||||
table.insert(tbEntityEventRemove, EntityEvent.new(listener, nEntityId, callback))
|
||||
end
|
||||
end
|
||||
function EventManager.HitEntityEvent(nEventId, nEntityId, ...)
|
||||
if mapEntityEvent == nil or mapOnHitEntityEventId == nil then
|
||||
return
|
||||
end
|
||||
local _map = mapEntityEvent[nEventId]
|
||||
if _map ~= nil and mapOnHitEntityEventId[nEventId] == nil then
|
||||
local tbEntityEvent = _map[nEntityId]
|
||||
if tbEntityEvent ~= nil then
|
||||
mapOnHitEntityEventId[nEventId] = true
|
||||
for i, entityEvent in ipairs(tbEntityEvent) do
|
||||
if entityEvent ~= nil and entityEvent._listener ~= nil and entityEvent._callback ~= nil then
|
||||
entityEvent._callback(entityEvent._listener, ...)
|
||||
end
|
||||
end
|
||||
mapOnHitEntityEventId[nEventId] = nil
|
||||
ProcAddEntityEvent(nEventId)
|
||||
ProcRemoveEntityEvent(nEventId)
|
||||
end
|
||||
end
|
||||
end
|
||||
return EventManager
|
||||
Reference in New Issue
Block a user