-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSkillModifier.lua
More file actions
61 lines (60 loc) · 2.3 KB
/
SkillModifier.lua
File metadata and controls
61 lines (60 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
SkillModifier = {}
SkillModifier.__index = SkillModifier
SkillModifier.add_func = function()
end
SkillModifier.remove_func = function()
end
SkillModifier.default_params_func = function()
end
SkillModifier.check_func = function()
return true
end
SkillModifier.monster_check_func = function()
return true
end
function SkillModifier.new(modifer_name, weight)
local self = setmetatable({}, SkillModifier)
self.modifier_name = modifer_name
self.weight = weight
self.enable = true
self.component_childs = {}
self.info_func = function(ori_desc)
return gm.translate("skill_modifier." .. modifer_name .. ".name") .. ": " ..
gm.translate("skill_modifier." .. modifer_name .. ".description") .. "\n" .. ori_desc
end
return self
end
---@param fn function(modifier_data, modifier_index, ...) The function will be called when adding modifier.
function SkillModifier:set_add_func(fn)
self.add_func = fn
end
---@param fn function(modifier_data, modifier_index) The function will be called when removing modifier.
function SkillModifier:set_remove_func(fn)
self.remove_func = fn
end
---@param fn function(origin_description, data, ...) The function used to update modifier's infomation.
function SkillModifier:set_info_func(fn)
self.info_func = fn
end
-- be careful the param maybe table skill_params(table) or skill(YYObjectBase*)
---@param fn function(skill) The function used to set default paramaters,
function SkillModifier:set_default_params_func(fn)
self.default_params_func = fn
end
-- be careful the param maybe table skill_params(table) or skill(YYObjectBase*)
---@param fn function(skill) The function used to check if the modifier can be added.
function SkillModifier:set_check_func(fn)
self.check_func = fn
end
-- be careful the param maybe table skill_params(table) or skill(YYObjectBase*)
---@param fn function(skill) The function used to check if the modifier can be added.
function SkillModifier:set_monster_check_func(fn)
self.monster_check_func = fn
end
---@param fn function(skillPickup, modifier_index, ...) The function will be called when adding modifier to a skillPickup.
function SkillModifier:set_add_inst_func(fn)
self.add_inst_func = fn
end
function SkillModifier:register_component(component)
table.insert(self.component_childs, component)
end