
-- 衣柜动作包物品信息（分类和ID）
-- DlgType 分类
local ActionPackageInfo = {
    [1]={ 
        ["Type"] = 9500, 
        ["ID"] = 9501,
        ["DlgType"] = 2, 
    },
	--Blaze的动作
	[2]={ 
        ["Type"] = 9503, 
        ["ID"] = 9504,
        ["DlgType"] = 2, 
    },
	--Zooko的动作
	[3]={ 
        ["Type"] = 9504, 
        ["ID"] = 9505,
        ["DlgType"] = 2, 
    },
	[4]={ 
        ["Type"] = 9502, 
        ["ID"] = 9502,
        ["DlgType"] = 1, 
    },
	-- 邪月降临
	[5]={ 
        ["Type"] = 9506, 
        ["ID"] = 9506,
        ["DlgType"] = 1, 
    },
}


-- 动作包所对应的资源图片（表现数据）
-- Ani 衣柜展示的图片
-- ActTypeInfo 这个动作包的动作信息,包括TypeNum：对应动作包的种类信息，以及每个种类所包含的动作
local ActionPackageTypeInfo = {
    [9500]={ 
        ["HotTag"] = 0, 
        ["NewTag"] = 0, 
        ["Ani"] = "yigui_dz_3107", 
        ["ActTypeInfo"] = { 
            ["TypeNum"] = 2, 
            [1] = { [1] = 3108, [2] = 3109 },
            [2] = { [1] = 3107 },
        },
    },

    [9503]={ 
        ["HotTag"] = 0, 
        ["NewTag"] = 0, 
        ["Ani"] = "yigui_dz_3106", 
        ["ActTypeInfo"] = { 
            ["TypeNum"] = 2, 
            [1] = { [1] = 3102, [2] = 3104 },
            [2] = { [1] = 3106 },
        },
    },
	
	[9504]={ 
        ["HotTag"] = 0, 
        ["NewTag"] = 0, 
        ["Ani"] = "yigui_dz_3106", 
        ["ActTypeInfo"] = { 
            ["TypeNum"] = 2, 
            [1] = { [1] = 3102, [2] = 3104 },
            [2] = { [1] = 3106 },
        },
    },
	
	[9502]={ 
        ["HotTag"] = 0, 
        ["NewTag"] = 0, 
        ["Ani"] = "yigui_dz_3112", 
        ["ActTypeInfo"] = { 
            ["TypeNum"] = 1, 
            [1] = { [1] = 3112},
        },
    },
	
	[9506]={ 
        ["HotTag"] = 0, 
        ["NewTag"] = 0, 
        ["Ani"] = "yigui_dz_3114", 
        ["ActTypeInfo"] = { 
            ["TypeNum"] = 1, 
            -- [1] = { [1] = 3114, [2] = 3115 },
			[1] = { [1] = 3114,}
        },
    },
}

-- 该物品对应的解锁条件
-- VIP消费等级
-- Item 持有物品
local ActionPackageCondition = {
	[95009501] = { ["Item"] = 2100095, ["CostVIPLev"] = 0,},
	[95039504] = { ["Item"] = 2169645, ["CostVIPLev"] = 0,},
	[95049505] = { ["Item"] = 2169165, ["CostVIPLev"] = 0,},
	[95029502] = { ["Item"] = 0, ["CostVIPLev"] = 0,},
	[95069506] = { ["Item"] = 0, ["CostVIPLev"] = 0,},
}


local function GetActionPackageConditionById(idItem, key1)
    if ActionPackageCondition[idItem] == nil then
        return nil
    end

    if ActionPackageCondition[idItem][key1] == nil then
        return nil
    end
    
    return ActionPackageCondition[idItem][key1]
end

-- 衣柜展示时动作配套的光效
local YiGuiActionEffect = {
	-- X/Y/Z 为空间中的偏移 X左右 Z上下 Y相对模型的层级     RX/RY/RZ 分别关于XYZ三个轴的旋转角度    ["Loop"] 表示是否是循环光效（不会随动作循环重置而重新加载光效）
    [3108] = { ["Loop"] = 0, ["Scale"] = 1.2, ["Rotate"] = 0, ["Effect"] = "tzsb_985", ["X"] = 45, ["Y"] = -15, ["Z"] = 120, ["RX"] = 35, ["RY"] = -15, ["RZ"] =  -90,},
    [3109] = { ["Loop"] = 0, ["Scale"] = 1.2, ["Rotate"] = 45, ["Effect"] = "tzsb_986", ["X"] = 95, ["Y"] = -15, ["Z"] = 228, ["RX"] = 15, ["RY"] = -15, ["RZ"] =  -45,},
    [3107] = { ["Loop"] = 1, ["Scale"] = 1.2, ["Rotate"] = 0, ["Effect"] = "tzsb_984", ["X"] = 100, ["Y"] = -30, ["Z"] = 240, ["RX"] = 30, ["RY"] = -15, ["RZ"] =  -90,},
    [3100] = { ["Loop"] = 0, ["Scale"] = 1.5, ["Rotate"] = 0, ["Effect"] = "yiguidz_3100", ["X"] = 113, ["Y"] = 10, ["Z"] = 240, ["RX"] = 0, ["RY"] = -20, ["RZ"] =  -90,},
    [3101] = { ["Loop"] = 0, ["Scale"] = 2.0, ["Rotate"] = 0, ["Effect"] = "yiguidz_3101", ["X"] = 0, ["Y"] = 20, ["Z"] = 60, ["RX"] = 30, ["RY"] = -15, ["RZ"] =  0,},
    [3106] = { ["Loop"] = 1, ["Scale"] = 2.0, ["Rotate"] = 0, ["Effect"] = "tzsb_815", ["X"] = 120, ["Y"] = -20, ["Z"] = 220, ["RX"] = 0, ["RY"] = -10, ["RZ"] =  -90,},
    [3102] = { ["Loop"] = 0, ["Scale"] = 2.0, ["Rotate"] = 0, ["Effect"] = "tzsb_816", ["X"] = 120, ["Y"] = -20, ["Z"] = 220, ["RX"] = 0, ["RY"] = -10, ["RZ"] =  -90,},
    [3104] = { ["Loop"] = 0, ["Scale"] = 2.0, ["Rotate"] = 0, ["Effect"] = "tzsb_816", ["X"] = 120, ["Y"] = -20, ["Z"] = 220, ["RX"] = 0, ["RY"] = -10, ["RZ"] =  -90,},
    [3112] = { ["Loop"] = 0, ["Scale"] = 2.5, ["Rotate"] = 45, ["Effect"] = "yiguidz_3112", ["X"] = 108, ["Y"] = 30, ["Z"] = 208, ["RX"] = -15, ["RY"] = -15, ["RZ"] =  -40,},
    [3113] = { ["Loop"] = 0, ["Scale"] = 2.5, ["Rotate"] = 0, ["Effect"] = "yiguidz_3113", ["X"] = 108, ["Y"] = 30, ["Z"] = 208, ["RX"] = -15, ["RY"] = -15, ["RZ"] =  -40,},
    [3114] = { ["Loop"] = 0, ["Scale"] = 1.5, ["Rotate"] = 0, ["Effect"] = "yiguidz_3114", ["X"] = 108, ["Y"] = 30, ["Z"] = 208, ["RX"] = -15, ["RY"] = -15, ["RZ"] =  -40,},
    [3115] = { ["Loop"] = 0, ["Scale"] = 1.5, ["Rotate"] = 0, ["Effect"] = "yiguidz_3115", ["X"] = 108, ["Y"] = 30, ["Z"] = 208, ["RX"] = -15, ["RY"] = -15, ["RZ"] =  -40,},
}

local ActionReplace = {
    -- 动作包
    [9500] = {
        --要替换的动作ID = 替换后ActionPackageInfo的ActTypeInfo里的集合
        [230] = 1,
        [250] = 2,
    },
        [9501] = {
        --要替换的动作ID = 替换后ActionPackageInfo的ActTypeInfo里的集合
        [230] = 1,
    },
    [9503] = {
        [230] = 1,
        [250] = 2,
    },
    [9504] = {
        [230] = 1,
        [250] = 2,
    },
    [9502] = {
        [230] = 1,
        [250] = 2,
    },

    [9506] = {
        [230] = 1,
        [250] = 2,
    },
}

local function GetYiGuiActionEffect(id, key)
    if YiGuiActionEffect[id] == nil then
        return nil
    end

    if YiGuiActionEffect[id][key] == nil then
        return nil
    end

    return YiGuiActionEffect[id][key]
end

local function GetOringnActionByGroup(idpackage, group)
    local type = math.floor(idpackage / 10000)
    if ActionReplace[type] == nil then
        return 0
    end

    for k, v in pairs(ActionReplace[type]) do
        if v == group then
            return k
        end
    end

    return 0
end

local function GetCurActionReplaceGroup(idpackage, action)
    local type = math.floor( idpackage / 10000 );

    if ActionReplace[type] == nil then
        return 0
    end

    if ActionReplace[type][action] == nil then
        return 0
    end

    return ActionReplace[type][action]
end


local function GetActionPackageTypeInfo(nIndex, key1, key2, key3)
    if ActionPackageTypeInfo[nIndex] == nil then
        return nil
    end

    if ActionPackageTypeInfo[nIndex][key1] == nil then
        return nil
    end

    if key1 ~= "ActTypeInfo" then
        return ActionPackageTypeInfo[nIndex][key1]
    end

    if ActionPackageTypeInfo[nIndex][key1][key2] == nil then
        return nil
    end

    if key2 == "TypeNum" then
        return ActionPackageTypeInfo[nIndex][key1][key2]
    end

    if key3 == "ActNum" then
        return #ActionPackageTypeInfo[nIndex][key1][key2]
    end

    if ActionPackageTypeInfo[nIndex][key1][key2][key3] == nil then
        return nil
    end
    
    return ActionPackageTypeInfo[nIndex][key1][key2][key3] 
end

-- 新增 DefaultDlgType ，用来配置页面打开后默认分类
local DefaultDlgType = 0
local function GetActionPackageInfo(nIndex, key1)
    if nIndex == "DefaultDlgType" then
        return DefaultDlgType
    end
    
    if nIndex == "Amount" then
        return #ActionPackageInfo
    end

    if ActionPackageInfo[nIndex] == nil then
        return nil
    end

    if ActionPackageInfo[nIndex][key1] == nil then
        return nil
    end

    return ActionPackageInfo[nIndex][key1] 
end

local function Unload()
    ActionPackageInfo = nil
end

local ActionPackageCollect = {
    Unload = Unload,
    GetYiGuiActionEffect = GetYiGuiActionEffect,
    GetActionPackageInfo = GetActionPackageInfo,
    GetOringnActionByGroup = GetOringnActionByGroup,
    GetCurActionReplaceGroup = GetCurActionReplaceGroup,
    GetActionPackageConditionById = GetActionPackageConditionById,
    GetActionPackageTypeInfo = GetActionPackageTypeInfo,
}

-- global
ActionPackageCollect_Unload = ActionPackageCollect.Unload
ActionPackageCollect_GetActionPackageTypeInfo = ActionPackageCollect.GetActionPackageTypeInfo
ActionPackageCollect_GetActionPackageConditionById = ActionPackageCollect.GetActionPackageConditionById
ActionPackageCollect_GetOringnActionByGroup = ActionPackageCollect.GetOringnActionByGroup
ActionPackageCollect_GetCurActionReplaceGroup = ActionPackageCollect.GetCurActionReplaceGroup
ActionPackageCollect_GetActionPackageInfo = ActionPackageCollect.GetActionPackageInfo
ActionPackageCollect_GetYiGuiActionEffect =ActionPackageCollect.GetYiGuiActionEffect

return ActionPackageCollect