Files
chuanqi-server-instance/LogicServer/data/functions/Common/ActorEventDispatcher.lua
2024-12-16 20:45:03 +08:00

71 lines
2.4 KiB
Lua
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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, //玩家登出 参数1人物id
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