Line 8: |
Line 8: |
| local equipments = {} | | local equipments = {} |
| | | |
− | local function requireEquipmentModule(name) | + | local function requireEquipmentModule(name, is_enemy) |
− | local success, data = U.requireModule('Data/Equipment/' .. name) | + | local success, data |
| + | if not is_enemy then |
| + | success, data = U.requireModule('Data/Equipment/' .. name) |
| + | if not success then |
| + | success, data = U.requireModule('Data/Item/' .. name) |
| + | end |
| + | if not success then |
| + | success, data = U.requireModule('Data/PseudoItem/' .. name) |
| + | end |
| + | if not success then |
| + | data = U.find(EquipmentCollection, name, '_name') or {_name = name} |
| + | success = true |
| + | end |
| + | end |
| if not success then | | if not success then |
| success, data = U.requireModule('Data/EnemyEquipment/' .. name) | | success, data = U.requireModule('Data/EnemyEquipment/' .. name) |
− | end
| |
− | if not success then
| |
− | success, data = U.requireModule('Data/Item/' .. name)
| |
− | end
| |
− | if not success then
| |
− | success, data = U.requireModule('Data/PseudoItem/' .. name)
| |
− | end
| |
− | if not success then
| |
− | data = U.find(EquipmentCollection, name, '_name') or {_name = name}
| |
| end | | end |
| return data | | return data |
| end | | end |
| | | |
− | function Equipment:create(name) | + | function Equipment:create(name, is_enemy) |
| if not name then | | if not name then |
| return EquipmentData() | | return EquipmentData() |
| end | | end |
| if not equipments[name] then | | if not equipments[name] then |
− | equipments[name] = EquipmentData(requireEquipmentModule(name)) | + | equipments[name] = EquipmentData(requireEquipmentModule(name, is_enemy)) |
| end | | end |
| return equipments[name] | | return equipments[name] |