VoxeLibre/mods/CORE/mcl_damage_source/init.lua
2021-03-17 11:08:14 +01:00

24 lines
488 B
Lua

MCLDamageSource = class()
function MCLDamageSource:constructor(tbl, hitter)
for k, v in pairs(tbl or {}) do
self[k] = v
end
self.hitter = hitter
end
MCLDamageSource:__getter("direct_object", function(self)
local hitter = self.hitter
if not hitter then
return
end
return mcl_object_mgr.get(hitter)
end)
MCLDamageSource:__getter("source_object", function(self)
local direct = self:direct_object()
if not direct then
return
end
return direct.source_object or direct
end)