72 lines
1.5 KiB
Lua
72 lines
1.5 KiB
Lua
require "Game.IExtendConfig"
|
|
require "Game.IGameInfo"
|
|
---
|
|
-- a net ExtendManager
|
|
ExtendManager = {
|
|
|
|
}
|
|
|
|
local _extendMap = {}
|
|
|
|
local _isUpdate = false
|
|
local _isInit = false
|
|
|
|
local function __new_config(data)
|
|
local ec = reimport(data.bundle .. ".ExtendConfig")
|
|
print("初始化ExtendManager===>>>" .. data.bundle)
|
|
--pt(data)
|
|
local config = ec.new()
|
|
ec.game_data = data
|
|
_extendMap[data.game_id] = config
|
|
return config
|
|
end
|
|
|
|
function ExtendManager.Init(game_list)
|
|
if _isInit then return end
|
|
for i = 1, #game_list do
|
|
local game = game_list[i]
|
|
__new_config(game)
|
|
end
|
|
|
|
_isInit = true
|
|
end
|
|
|
|
-- 更新扩展玩法到最新数据
|
|
function ExtendManager.UpdateExtend(data)
|
|
if not data then return end
|
|
local tem = _extendMap[data.game_id]
|
|
if tem and (not GameApplication.Instance.buildApp) then
|
|
return
|
|
end
|
|
if tem and tem.game_data.version ~= data.version then
|
|
GameApplication.Instance:UnExtendLua(data)
|
|
tem:UnAllAssets()
|
|
end
|
|
__new_config(data)
|
|
end
|
|
|
|
function ExtendManager.RemoveExtend(data)
|
|
local tem = _extendMap[data.game_id]
|
|
if tem then
|
|
GameApplication.Instance:UnExtendLua(data)
|
|
tem:UnAllAssets()
|
|
end
|
|
end
|
|
|
|
function ExtendManager.GetExtendConfig(id)
|
|
return _extendMap[id]
|
|
end
|
|
|
|
function ExtendManager.GetGameData(id)
|
|
local data = _extendMap[id]
|
|
if not data then
|
|
return nil
|
|
end
|
|
return data.game_data
|
|
end
|
|
|
|
function ExtendManager.Destroy()
|
|
_extendMap = {}
|
|
_isInit = false
|
|
end
|