Files
chuanqi-server/server/s1/LogicServer/data/functions/Common/ActorEventDispatcher.lua

71 lines
2.4 KiB
Lua
Raw Normal View History

2024-12-13 13:41:02 +08:00
module("ActorEventDispatcher", package.seeall)
local dispatcher = {}
-- @brief 注册事件分发器
-- @param evId 事件id
-- @param func 回调
function Reg(evId, func, file)
--必须有参数
if evId == nil or func == nil or file == nil then
print( debug.traceback() )
print( file )
assert(false)
end
--玩家事件
if evId >= aeMaxEventCount or evId <= aeNoEvent then
print("[ERROR][EventDispatcher] evId("..evId..") error!")
assert(false)
else
if dispatcher[evId] == nil then
dispatcher[evId] = {}
end
table.insert(dispatcher[evId], func)
System.regScriptEvent(enType, evId)
end
print("[TIP][EventDispatcher] Add Actor Event("..evId..") In File("..file.."), And Index="..table.maxn(dispatcher[evId]))
return true
end
function OnEvent(nIndex, evId, pActor, ...)
local func = dispatcher[evId][nIndex]
if func then
return func(pActor, ...)
end
return false
end
--[[ 详细见ActorEventDef.h
enum tagActorEventID
{
aeNoEvent = 0, //
aeLevel = 1, // 1
aeUserLogin = 2, // 1
aeUserLogout = 3, // 1id
aeOnActorDeath = 4, //
aeReliveTimeOut = 5, //5. 1
aeNewDayArrive = 6, //线0[]
aeOnActorBeKilled = 7, // []
aeWithDrawYuanBao = 8, // []
aeConsumeYb = 9, // []
aeOnEnterFuben = 10, // [id]
aeOnExitFuben = 11, //退 [退id]
aeGuild = 12, //
aeEquipComposite = 13, // [ItemID]
aeBuffRemoved = 14, //buff被删除事件
aeLeaveTeam = 15, //
aeCircle = 16, // []
aeChangeName = 17, //
aeAsyncOpResult = 18, // 1 2 3 4 5 6 7Sub类型
aeHero = 19, //
aeHurtMonster = 20, //
};
]]
--return EventDispatcher