Files
Main/Assets/GameAssets/Resources/Lua/Common/CustomLib/LuaDelegateManager/LuaDelegateHander.lua
2025-01-25 04:38:09 +08:00

44 lines
942 B
Lua
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.

------------------------------------------------
--作者:何健
--日期2019-05-29
--文件LuaDelegateHander.lua
--模块LuaDelegateHander
--描述:委托句柄的定义
------------------------------------------------
--委托句柄定义
local LuaDelegateHander={
--引用计数
Ref = 0,
--函数调用者
Caller = nil,
--函数
Func = nil,
--形成的事件句柄
Handler = nil;
};
--新的事件Handler
function LuaDelegateHander:New(func, caller)
local _m = Utils.DeepCopy(self);
_m.Caller = caller;
_m.Func = func;
_m.Ref = 1;
if caller == nil then
_m.Handler = func;
else
_m.Handler = Utils.Handler(func,caller);
end
return _m;
end
----引用计数加一
function LuaDelegateHander:IncRef()
self.Ref = self.Ref + 1
end
--引用计数减一
function LuaDelegateHander:DecRef()
self.Ref = self.Ref - 1
end
return LuaDelegateHander;