PGRData/Resources/Scripts/XConfig/XCharacterUiEffectConfig.lua
2022-12-26 14:06:01 +05:30

75 lines
No EOL
3.2 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

XCharacterUiEffectConfig = XCharacterUiEffectConfig or {}
local TABLE_CHARACTER_UI_EFFECT = "Client/Character/CharacterUiEffect.tab"
local TABLE_FASHION = "Share/Fashion/Fashion.tab"
local CharacterUiEffectTable = {}
local EffectDictionary = {}
function XCharacterUiEffectConfig.Init()
EffectDictionary = {}
CharacterUiEffectTable = XTableManager.ReadByIntKey(TABLE_CHARACTER_UI_EFFECT, XTable.XTableCharacterUiEffect, "Id")
local FashionTemplates = XTableManager.ReadByIntKey(TABLE_FASHION, XTable.XTableFashion, "Id")
for _, v in pairs(CharacterUiEffectTable) do
if not v.FashionId then
XLog.Error(string.format("CharacterUiEffect表出错存在没有填FashionId的数据表地址:" .. TABLE_CHARACTER_UI_EFFECT))
end
if not v.EffectPath then
XLog.Error(string.format("CharacterUiEffect表出错存在没有填EffectPath的数据表地址:" .. TABLE_CHARACTER_UI_EFFECT .. "Id:" .. v.Id))
end
local fashionTemplate = FashionTemplates[v.FashionId]
if not fashionTemplate then
XLog.ErrorTableDataNotFound("CharacterUiEffectConfig.Init", "Fashion", TABLE_FASHION, "fashionId", tostring(v.FashionId))
return
end
local characterId = fashionTemplate.CharacterId
local character = EffectDictionary[characterId]
if not character then
EffectDictionary[characterId] = {}
character = EffectDictionary[characterId]
end
local fashion = character[v.FashionId]
if not fashion then
character[v.FashionId] = {}
fashion = character[v.FashionId]
end
if v.ActionId then
fashion[v.ActionId] = v
else
if not fashion.DefaultEffect then
fashion.DefaultEffect = v
else
XLog.Error("CharacterUiEffect表出错一个FashionId只能有一个不填写ActionId的数据项FashionId: " .. v.FashionId)
end
end
end
end
function XCharacterUiEffectConfig.GetCharacterUiEffectById(id)
return CharacterUiEffectTable[id]
end
function XCharacterUiEffectConfig.GetEffectInfo(characterId, fashionId, actionId)
if not characterId or not fashionId then
XLog.Error(string.format("XCharacterUiEffectConfig.GetEffectInfo出错必须参数存在空值,characterId: %s,fashionId: %s",
tostring(characterId), tostring(fashionId)))
return nil
end
local character = EffectDictionary[characterId]
if not character then
--XLog.ErrorTableDataNotFound("XCharacterUiEffectConfig.GetEffectInfo", "Ui角色动作特效", TABLE_CHARACTER_UI_EFFECT, "CharacterId", tostring(characterId))
return nil
end
local fashion = character[fashionId]
if not fashion then
--XLog.ErrorTableDataNotFound("XCharacterUiEffectConfig.GetEffectInfo", "Ui角色动作特效", TABLE_CHARACTER_UI_EFFECT, "FashionId", tostring(fashionId))
return nil
end
local cfg
if actionId then
cfg = fashion[actionId]
else
cfg = fashion.DefaultEffect
end
if not cfg then
return nil
end
return cfg.Id, cfg.EffectRootName, cfg.EffectPath
end