forked from endernon/PGRData
1261 lines
No EOL
40 KiB
Lua
1261 lines
No EOL
40 KiB
Lua
XFurnitureConfigs = XFurnitureConfigs or {}
|
|
|
|
--家具交互点被使用情况
|
|
XFurnitureInteractUsedType = {
|
|
None = 1, --空,未被占用
|
|
Character = 2, --被构造体占用
|
|
Block = 4, --交互点被阻挡,无法使用
|
|
}
|
|
|
|
XFurnitureConfigs.FURNITURE_CATEGORY_ALL_ID = 0
|
|
XFurnitureConfigs.MAX_FURNITURE_ATTR_LEVEL = 5
|
|
XFurnitureConfigs.FURNITURE_SUIT_CATEGORY_ALL_ID = 1
|
|
|
|
XFurnitureConfigs.BASE_SUIT_ID = 4 --基础套装Id
|
|
|
|
XFurnitureConfigs.GainType = {
|
|
Create = 1, --创建
|
|
Refit = 2, --改装
|
|
Remake = 3, --重置
|
|
}
|
|
|
|
XFurnitureConfigs.XFurnitureAdditionType = {
|
|
Mood = 0,
|
|
Vitality = 1,
|
|
AttrA = 2,
|
|
AttrB = 3,
|
|
AttrC = 4,
|
|
AttrAPercent = 5,
|
|
AttrBPercent = 6,
|
|
AttrCPercent = 7,
|
|
AttrTotal = 8,
|
|
AttrTotalPercent = 9,
|
|
Count = 10
|
|
}
|
|
|
|
-- 家具摆放类型
|
|
XFurniturePlaceType = {
|
|
Ground = 1, -- 地板
|
|
Wall = 2, -- 墙
|
|
Ceiling = 3, -- 天花板
|
|
OnGround = 4, -- 摆放在地板上
|
|
OnWall = 5, -- 摆放在墙上
|
|
}
|
|
|
|
-- 家具类型
|
|
XFurnitureConfigs.HomeSurfaceBaseType = {
|
|
Ground = 25001, --地板
|
|
Wall = 25002, --墙
|
|
Ceiling = 25003, --天花板
|
|
}
|
|
|
|
-- 家具Attr类型
|
|
XFurnitureConfigs.AttrType = {
|
|
AttrA = 1, --美观(红)
|
|
AttrB = 2, --舒适(黄)
|
|
AttrC = 3, --实用(蓝)
|
|
AttrAll = 4, --总值
|
|
}
|
|
|
|
-- 家具操作状态
|
|
XFurnitureConfigs.FURNITURE_STATE = {
|
|
RECYCLE = 1, -- 回收状态
|
|
DETAILS = 2, -- 查看详情状态
|
|
SELECT = 3, -- 选择家具或者图纸状态
|
|
SELECTSINGLE = 4 --家具单选状态
|
|
}
|
|
|
|
--- 家具摆放类型
|
|
XFurnitureConfigs.HomeLocateType = {
|
|
Replace = 0, --直接替换
|
|
LocateGround = 1, --摆放在地板上
|
|
LocateWall = 2, --悬挂墙上
|
|
}
|
|
|
|
--- 增减
|
|
XFurnitureConfigs.FurnitureOperate = {
|
|
Delete = 0, --增加
|
|
Add = 1, --减少
|
|
}
|
|
|
|
--- 家具点击播放动画类型
|
|
XFurnitureConfigs.FurnitureAnimationType = {
|
|
None = 0, -- 不播放
|
|
Once = 1, -- 点击播放一次
|
|
Repeat = 2, -- 连续播放动画
|
|
}
|
|
|
|
--- 家具额外属性
|
|
XFurnitureConfigs.FurnitureAdditionType = {
|
|
Mood = 0,
|
|
Vitality = 1,
|
|
AttrTotal = 2,
|
|
AttrTotalPercent = 3,
|
|
Count = 4,
|
|
}
|
|
|
|
XFurnitureConfigs.HomePlatType = {
|
|
Ground = 0, -- 地板
|
|
Wall = 1, -- 墙
|
|
}
|
|
|
|
--排序优先级选项
|
|
XFurnitureConfigs.PriorSortType = {
|
|
All = 0, -- 全选
|
|
Unuse = 1, -- 未使用
|
|
Use = 2, -- 使用中
|
|
}
|
|
|
|
--家具排序方式
|
|
XFurnitureConfigs.FurnitureOrderType = {
|
|
ScoreDescend = 0, --分数升序
|
|
ScoreAsscend = 1, --分数降序
|
|
LevelDescend = 2, --等级升序
|
|
LevelAsscend = 3, --等级降序
|
|
}
|
|
|
|
--排序优先级选项
|
|
XFurnitureConfigs.MajorType = {
|
|
Refit = 1, -- 改造
|
|
Frunitue = 2, -- 家具
|
|
}
|
|
|
|
--家具位置交换类型
|
|
XFurnitureConfigs.PosChangeType = {
|
|
None = 0, -- 不能交换
|
|
Red = 1, -- 红方
|
|
Black = 2, -- 黑方
|
|
White = 3, -- 白方
|
|
Greed = 4, -- 绿方
|
|
Purple = 5, -- 紫方
|
|
Gold = 6, -- 金方
|
|
}
|
|
|
|
|
|
-- 属性分级颜色
|
|
XFurnitureConfigs.FurnitureAttrColor = {
|
|
[1] = CS.XTextManager.GetText("FurnitureColorC"),
|
|
[2] = CS.XTextManager.GetText("FurnitureColorC"),
|
|
[3] = CS.XTextManager.GetText("FurnitureColorB"),
|
|
[4] = CS.XTextManager.GetText("FurnitureColorA"),
|
|
[5] = CS.XTextManager.GetText("FurnitureColorS"),
|
|
}
|
|
|
|
|
|
-- 属性标签分级颜色
|
|
XFurnitureConfigs.FurnitureAttrTagColor = {
|
|
[1] = "#62DE4AFF",
|
|
[2] = "#62DE4AFF",
|
|
[3] = "#34AFF8FF",
|
|
[4] = "#D07EFFFF",
|
|
[5] = "#FFB400FF",
|
|
}
|
|
|
|
XFurnitureConfigs.FurnitureAttrLevel = {
|
|
[1] = CS.XTextManager.GetText("FurnitureQualityC"),
|
|
[2] = CS.XTextManager.GetText("FurnitureQualityC"),
|
|
[3] = CS.XTextManager.GetText("FurnitureQualityB"),
|
|
[4] = CS.XTextManager.GetText("FurnitureQualityA"),
|
|
[5] = CS.XTextManager.GetText("FurnitureQualityS"),
|
|
}
|
|
|
|
XFurnitureConfigs.FurnitureAttrLevelId = {
|
|
LevelC = 2,
|
|
LevelB = 3,
|
|
LevelA = 4,
|
|
LevelS = 5
|
|
}
|
|
|
|
local CLIENT_FURNITURE_SUIT = "Client/Hostel/FurnitureSuit.tab"
|
|
local CLIENT_FURNITURE_VIEWANGLE = "Client/Hostel/FurnitureViewAngle.tab"
|
|
local CLIENT_FURNITURE_COLOUR = "Client/Hostel/FurnitureColour.tab"
|
|
local TABLE_DORM_FURNITURE_TYPE_PATH = "Client/Dormitory/DormFurnitureType.tab"
|
|
local TABLE_DORM_FURNITURE_TAG_TYPE_PATH = "Client/Dormitory/DormFurnitureTagType.tab"
|
|
local TABLE_DORM_FURNITURE_SINGLE_LEVEL_PATH = "Client/Dormitory/FurnitureSingleAttrLevel.tab"
|
|
|
|
local TABLE_DORM_FURNITURE_ANIMATION_PATH = "Client/Dormitory/DormFurnitureAnimation.tab"
|
|
|
|
local SHARE_FURNITURE = "Share/Dormitory/Furniture/Furniture.tab"
|
|
local SHARE_FURNITURE_LEVEL = "Share/Dormitory/Furniture/FurnitureLevel.tab"
|
|
local SHARE_FURNITURE_TYPE = "Share/Dormitory/Furniture/FurnitureType.tab"
|
|
local SHARE_FURNITURE_ADDITIONALATTR = "Share/Dormitory/Furniture/FurnitureAdditionalAttr.tab"
|
|
local SHARE_FURNITURE_FURNITURE_CREATEATTR = "Share/Dormitory/Furniture/FurnitureCreateAttr.tab"
|
|
local SHARE_FURNITURE_FURNITURE_BASE_ATTR = "Share/Dormitory/Furniture/FurnitureBaseAttr.tab"
|
|
local SHARE_FURNITURE_FURNITURE_EXTRA_ATTR = "Share/Dormitory/Furniture/FurnitureExtraAttr.tab"
|
|
local SHARE_FURNTIURE_REWARD = "Share/Dormitory/Furniture/FurnitureReward.tab"
|
|
local SHARE_FURNTIURE_BEHAVIOR = "Share/Dormitory/Furniture/FurnitureBehavior.tab"
|
|
local SHARE_FURNITURE_PUT_NUM = "Share/Dormitory/Furniture/FurniturePutNum.tab"
|
|
|
|
local FurnitureSuitTemplates = {}
|
|
local FurnitureViewAngle = {}
|
|
local FurnitureColour = {}
|
|
|
|
local FurnitureTemplates = {}
|
|
local FurnitureMinorDatas = {} --{Minor, {Category, {suitId, cfgs}}}
|
|
local FurnitureSuitDatas = {} --{suitId, cfgs}
|
|
local FurnitureLevelTemplates = {}
|
|
local FurnitureTypeTemplates = {}
|
|
local FurnitureTagTypeTemplates = {}
|
|
local FurnitureAdditionalAttr = {}
|
|
local FurnitureCreateAttr = {}
|
|
local FurnitureBaseAttrTemplate = {}
|
|
local FurnitureExtraAttrTemplate = {}
|
|
local FurnitureTypeGroupList = {}
|
|
local FurnitureRewardTemplate = {}
|
|
local FurnitureBehaviorTemplate = {}
|
|
local FurniturePutNumTemplates = {}
|
|
|
|
local FurnitureSingleAttrLevelTemplate = {}
|
|
local FurnitureSingleAttrLevelIndex = {}
|
|
|
|
local FurnitureToDrawingMap = {}--家具改装所需的图纸
|
|
local DrawingToFurnitureMap = {}--图纸能改装的家具
|
|
local DrawingPicMap = {}
|
|
local DormFurnitureTypeTemplate = {} -- 家具喜好度类型配置表
|
|
local DormFurnitureTypeAttsDic = {} -- 家具属性
|
|
local DormFurnitureAnimation = {} -- 家具动画配置表
|
|
|
|
XFurnitureConfigs.Incresment = CS.XGame.ClientConfig:GetInt("FurnitureInvestmentIncreaseStep")
|
|
XFurnitureConfigs.DefaultIcon = CS.XGame.ClientConfig:GetString("FurnitureDefaultIcon")
|
|
XFurnitureConfigs.DefaultCreateName = CS.XGame.ClientConfig:GetString("FurnitureDefaultName")
|
|
XFurnitureConfigs.DefaultResetName = CS.XGame.ClientConfig:GetString("FurnitureDefaultResetName")
|
|
XFurnitureConfigs.MaxCreateCount = CS.XGame.Config:GetInt("DormMaxCreateCount")
|
|
XFurnitureConfigs.MaxRemouldCount = CS.XGame.Config:GetInt("DormMaxRemouldCount")
|
|
XFurnitureConfigs.MaxRemakeCount = CS.XGame.Config:GetInt("DormMaxRemakeCount")
|
|
XFurnitureConfigs.MaxPutFurnitureCount = CS.XGame.Config:GetInt("DormMaxPutFurnitureCount")
|
|
XFurnitureConfigs.MaxTotalFurnitureCount = CS.XGame.Config:GetInt("DormMaxTotalFurnitureCount")
|
|
XFurnitureConfigs.MaxDrawBuyCount = CS.XGame.Config:GetInt("DormMaxDrawBuyCount")
|
|
|
|
local function InitFurnitureTypeGroupConfig()
|
|
local map = {}
|
|
for _, cfg in pairs(FurnitureTypeTemplates) do
|
|
local newId = cfg.MajorType * 100 + cfg.MinorType
|
|
|
|
local data = map[newId]
|
|
if not data then
|
|
data = {}
|
|
data.MinorType = cfg.MinorType
|
|
data.MinorName = cfg.MinorName
|
|
data.CategoryMap = {}
|
|
map[newId] = data
|
|
end
|
|
|
|
local category = {}
|
|
category.Category = cfg.Category
|
|
category.CategoryName = cfg.CategoryName
|
|
|
|
data.CategoryMap[category.Category] = category
|
|
end
|
|
|
|
for _, data in pairs(map) do
|
|
data.CategoryList = {}
|
|
|
|
for _, v in pairs(data.CategoryMap) do
|
|
table.insert(data.CategoryList, v)
|
|
end
|
|
|
|
data.CategoryMap = nil
|
|
if #data.CategoryList > 1 then
|
|
local category = {}
|
|
category.Category = 0
|
|
category.CategoryName = CS.XTextManager.GetText("FurnitureWholeText")
|
|
table.insert(data.CategoryList, 1, category)
|
|
end
|
|
|
|
table.insert(FurnitureTypeGroupList, data)
|
|
end
|
|
end
|
|
|
|
local function InitFurnitureLevelConfigs(configs)
|
|
for _, config in pairs(configs) do
|
|
if not FurnitureLevelTemplates[config.FurnitureType] then
|
|
FurnitureLevelTemplates[config.FurnitureType] = {}
|
|
end
|
|
table.insert(FurnitureLevelTemplates[config.FurnitureType], config)
|
|
end
|
|
end
|
|
|
|
|
|
local function InitFurnitureSingleAttrLevelConfigs(configs)
|
|
for _, config in pairs(configs) do
|
|
if not FurnitureSingleAttrLevelIndex[config.FurnitureType] then
|
|
FurnitureSingleAttrLevelIndex[config.FurnitureType] = {}
|
|
end
|
|
table.insert(FurnitureSingleAttrLevelIndex[config.FurnitureType], config)
|
|
end
|
|
end
|
|
|
|
local function InitFurnitureMinorTemplates(config)
|
|
local typeConfig = FurnitureTypeTemplates[config.TypeId]
|
|
if not typeConfig then
|
|
XLog.ErrorTableDataNotFound("XFurnitureConfigs.InitFurnitureMinorTemplates",
|
|
"FurnitureType", SHARE_FURNITURE_TYPE, "Id", tostring(config.TypeId))
|
|
return
|
|
end
|
|
|
|
if not FurnitureMinorDatas[typeConfig.MinorType] then
|
|
FurnitureMinorDatas[typeConfig.MinorType] = {}
|
|
end
|
|
|
|
if not FurnitureMinorDatas[typeConfig.MinorType][typeConfig.Category] then
|
|
FurnitureMinorDatas[typeConfig.MinorType][typeConfig.Category] = {}
|
|
end
|
|
|
|
if not FurnitureMinorDatas[typeConfig.MinorType][typeConfig.Category] then
|
|
FurnitureMinorDatas[typeConfig.MinorType][typeConfig.Category] = {}
|
|
end
|
|
|
|
if not FurnitureMinorDatas[typeConfig.MinorType][typeConfig.Category][config.SuitId] then
|
|
FurnitureMinorDatas[typeConfig.MinorType][typeConfig.Category][config.SuitId] = {}
|
|
end
|
|
|
|
table.insert(FurnitureMinorDatas[typeConfig.MinorType][typeConfig.Category][config.SuitId], config.Id)
|
|
end
|
|
|
|
local function InitFurnitureBehaviorTemplates(configs)
|
|
for _, v in pairs(configs) do
|
|
FurnitureBehaviorTemplate[v.FurnitureId] = FurnitureBehaviorTemplate[v.FurnitureId] or {}
|
|
FurnitureBehaviorTemplate[v.FurnitureId][v.State] = v
|
|
end
|
|
end
|
|
|
|
function XFurnitureConfigs.Init()
|
|
FurnitureSuitTemplates = XTableManager.ReadByIntKey(CLIENT_FURNITURE_SUIT, XTable.XTableFurnitureSuit, "Id")
|
|
FurnitureViewAngle = XTableManager.ReadByIntKey(CLIENT_FURNITURE_VIEWANGLE, XTable.XTableFurnitureViewAngle, "MinorType")
|
|
FurnitureColour = XTableManager.ReadByIntKey(CLIENT_FURNITURE_COLOUR, XTable.XTableFurntiureColour, "Id")
|
|
FurnitureTemplates = XTableManager.ReadByIntKey(SHARE_FURNITURE, XTable.XTableFurniture, "Id")
|
|
FurnitureTypeTemplates = XTableManager.ReadByIntKey(SHARE_FURNITURE_TYPE, XTable.XTableFurnitureType, "Id")
|
|
FurniturePutNumTemplates = XTableManager.ReadByIntKey(SHARE_FURNITURE_PUT_NUM, XTable.XTableFurniturePutNum, "PutId")
|
|
local typeCount = XFurnitureConfigs.GetFurnitureTemplateTypeCount()
|
|
if XFurnitureConfigs.MaxCreateCount < XFurnitureConfigs.GetFurnitureTemplateTypeCount() then
|
|
local tmpStr = "XFurnitureConfigs.Init error: DormMaxCreateCount is less than FurnitureType count, DormMaxCreateCount is "
|
|
XLog.Error(tmpStr .. tostring(XFurnitureConfigs.MaxCreateCount) .. ",DormMaxCreateCount is " .. tostring(typeCount))
|
|
return
|
|
end
|
|
|
|
FurnitureTagTypeTemplates = XTableManager.ReadByIntKey(TABLE_DORM_FURNITURE_TAG_TYPE_PATH, XTable.XTableDormFurnitureTagType, "Id")
|
|
FurnitureSingleAttrLevelTemplate = XTableManager.ReadByIntKey(TABLE_DORM_FURNITURE_SINGLE_LEVEL_PATH, XTable.XTableFurnitureSingleAttrLevel, "Id")
|
|
|
|
FurnitureAdditionalAttr = XTableManager.ReadByIntKey(SHARE_FURNITURE_ADDITIONALATTR, XTable.XTableFurnitureAdditionalAttr, "AttributeId")
|
|
FurnitureCreateAttr = XTableManager.ReadByIntKey(SHARE_FURNITURE_FURNITURE_CREATEATTR, XTable.XTableFurnitureCreateAttr, "Id")
|
|
FurnitureBaseAttrTemplate = XTableManager.ReadByIntKey(SHARE_FURNITURE_FURNITURE_BASE_ATTR, XTable.XTableFurnitureBaseAttr, "Id")
|
|
FurnitureExtraAttrTemplate = XTableManager.ReadByIntKey(SHARE_FURNITURE_FURNITURE_EXTRA_ATTR, XTable.XTableFurnitureExtraAttr, "Id")
|
|
FurnitureRewardTemplate = XTableManager.ReadByIntKey(SHARE_FURNTIURE_REWARD, XTable.XTableFurnitureReward, "Id")
|
|
DormFurnitureTypeTemplate = XTableManager.ReadByIntKey(TABLE_DORM_FURNITURE_TYPE_PATH, XTable.XTableDormFurnitureType, "Id")
|
|
DormFurnitureAnimation = XTableManager.ReadByIntKey(TABLE_DORM_FURNITURE_ANIMATION_PATH, XTable.XTableDormFunitureAnimation, "Id")
|
|
local furnitureLevelTemplates = XTableManager.ReadByIntKey(SHARE_FURNITURE_LEVEL, XTable.XTableFurnitureLevel, "Id")
|
|
local furnitureBehaviorTemplate = XTableManager.ReadByIntKey(SHARE_FURNTIURE_BEHAVIOR, XTable.XTableFurnitureBehavior, "Id")
|
|
|
|
InitFurnitureTypeGroupConfig()
|
|
InitFurnitureLevelConfigs(furnitureLevelTemplates)
|
|
InitFurnitureSingleAttrLevelConfigs(FurnitureSingleAttrLevelTemplate)
|
|
InitFurnitureBehaviorTemplates(furnitureBehaviorTemplate)
|
|
|
|
-- 改装功能家具映射 and 家具分类
|
|
for k, v in pairs(FurnitureTemplates) do
|
|
if v.PicId ~= nil and v.PicId > 0 then
|
|
FurnitureToDrawingMap[k] = v.PicId
|
|
DrawingToFurnitureMap[v.PicId] = k
|
|
|
|
if DrawingPicMap[v.TypeId] == nil then
|
|
DrawingPicMap[v.TypeId] = {}
|
|
end
|
|
table.insert(DrawingPicMap[v.TypeId], {
|
|
FurnitureId = v.Id,
|
|
TypeId = v.TypeId,
|
|
PicId = v.PicId,
|
|
GainType = v.GainType
|
|
})
|
|
end
|
|
|
|
local isAllSuit = XFurnitureConfigs.IsAllSuit(v.SuitId)
|
|
local id = isAllSuit and 0 or v.SuitId
|
|
if not FurnitureSuitDatas[id] then
|
|
FurnitureSuitDatas[id] = 0
|
|
end
|
|
|
|
if not FurnitureSuitDatas[0] then
|
|
FurnitureSuitDatas[0] = 0
|
|
end
|
|
|
|
if id ~= 0 then
|
|
FurnitureSuitDatas[0] = FurnitureSuitDatas[0] + 1
|
|
end
|
|
|
|
FurnitureSuitDatas[id] = FurnitureSuitDatas[id] + 1
|
|
|
|
if v.SuitId ~= 0 then
|
|
InitFurnitureMinorTemplates(v)
|
|
end
|
|
end
|
|
end
|
|
|
|
-- 获取家具额外属性加成配置分数
|
|
function XFurnitureConfigs.GetAdditionalAddScore(id)
|
|
local currentAttr = FurnitureAdditionalAttr[id]
|
|
|
|
if not currentAttr then
|
|
XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetAdditionalAddScore",
|
|
"FurnitureAdditionalAttr", SHARE_FURNITURE_ADDITIONALATTR, "Id", tostring(id))
|
|
return 0
|
|
end
|
|
|
|
return currentAttr.AddScore or 0
|
|
end
|
|
|
|
-- 获取家具额外属性加成配置表
|
|
function XFurnitureConfigs.GetAdditionAttrConfigById(id)
|
|
local t = FurnitureAdditionalAttr[id]
|
|
if not t then
|
|
XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetAdditionAttrConfigById",
|
|
"FurnitureAdditionalAttr", SHARE_FURNITURE_ADDITIONALATTR, "Id", tostring(id))
|
|
return nil
|
|
end
|
|
|
|
return t
|
|
end
|
|
|
|
-- 获取喜好度类型配置表
|
|
function XFurnitureConfigs.GetDormFurnitureType(id)
|
|
local t = DormFurnitureTypeTemplate[id]
|
|
if not t then
|
|
XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetDormFurnitureType", "DormFurnitureType", TABLE_DORM_FURNITURE_TYPE_PATH, "Id", tostring(id))
|
|
return nil
|
|
end
|
|
|
|
return t
|
|
end
|
|
|
|
-- 获取家具动画配置表
|
|
function XFurnitureConfigs.GetDormFurnitureAnimation(id)
|
|
local t = DormFurnitureAnimation[id]
|
|
if not t then
|
|
XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetDormFurnitureAnimation",
|
|
"DormFurnitureAnimation", TABLE_DORM_FURNITURE_ANIMATION_PATH, "Id", tostring(id))
|
|
return nil
|
|
end
|
|
|
|
return t
|
|
end
|
|
|
|
--获取行为节点Id
|
|
function XFurnitureConfigs.GetFurnitureBehavior(furnitureId, state)
|
|
if not FurnitureBehaviorTemplate or not FurnitureBehaviorTemplate[furnitureId] then
|
|
XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetFurnitureBehavior",
|
|
"FurnitureBehavior", SHARE_FURNTIURE_BEHAVIOR, "furnitureId", tostring(furnitureId))
|
|
return
|
|
end
|
|
|
|
if not FurnitureBehaviorTemplate[furnitureId][state] then
|
|
XLog.Error("FurnitureBehaviorTemplate State not exist", furnitureId, state)
|
|
return
|
|
end
|
|
|
|
return FurnitureBehaviorTemplate[furnitureId][state]
|
|
end
|
|
|
|
function XFurnitureConfigs.GetOnceAnimationType(furnitureId)
|
|
local furniture = XFurnitureConfigs.GetFurnitureBaseTemplatesById(furnitureId)
|
|
if not furniture then
|
|
return nil
|
|
end
|
|
|
|
local t = XFurnitureConfigs.GetDormFurnitureAnimation(furniture.AnimationId)
|
|
if not t then
|
|
return nil
|
|
end
|
|
|
|
return t.ClickType
|
|
end
|
|
|
|
-- 获取家具动画类型
|
|
function XFurnitureConfigs.GetOnceAnimationType(furnitureId)
|
|
local furniture = XFurnitureConfigs.GetFurnitureBaseTemplatesById(furnitureId)
|
|
if not furniture then
|
|
return nil
|
|
end
|
|
|
|
local t = XFurnitureConfigs.GetDormFurnitureAnimation(furniture.AnimationId)
|
|
if not t then
|
|
return nil
|
|
end
|
|
|
|
return t.ClickType
|
|
end
|
|
|
|
-- 根据构造体ID获取家具交互动画名
|
|
function XFurnitureConfigs.GetDormFurnitureAnimationByCharId(furnitureId, charId)
|
|
local furniture = XFurnitureConfigs.GetFurnitureBaseTemplatesById(furnitureId)
|
|
if not furniture then
|
|
return nil
|
|
end
|
|
|
|
local t = XFurnitureConfigs.GetDormFurnitureAnimation(furniture.AnimationId)
|
|
if not t then
|
|
return nil
|
|
end
|
|
|
|
for k, v in pairs(t.CharacterId) do
|
|
if charId == v and t.CharacterAnimationName[k] then
|
|
return t.CharacterAnimationName[k]
|
|
end
|
|
end
|
|
|
|
return nil
|
|
end
|
|
|
|
-- 获取家具动画名
|
|
function XFurnitureConfigs.GetOnceAnimationName(furnitureId)
|
|
local furniture = XFurnitureConfigs.GetFurnitureBaseTemplatesById(furnitureId)
|
|
if not furniture then
|
|
return nil
|
|
end
|
|
|
|
local t = XFurnitureConfigs.GetDormFurnitureAnimation(furniture.AnimationId)
|
|
if not t then
|
|
return nil
|
|
end
|
|
|
|
if t.ClickType == XFurnitureConfigs.FurnitureAnimationType.Once then
|
|
return t.OnceAnimationName
|
|
elseif t.ClickType == XFurnitureConfigs.FurnitureAnimationType.Repeat then
|
|
return t.RepaatAnimationName
|
|
end
|
|
|
|
return nil
|
|
end
|
|
|
|
-- 获取喜好度类型Icon
|
|
function XFurnitureConfigs.GetDormFurnitureTypeIcon(id)
|
|
local t = XFurnitureConfigs.GetDormFurnitureType(id)
|
|
return t.TypeIcon
|
|
end
|
|
|
|
-- 获取喜好度类型Name
|
|
function XFurnitureConfigs.GetDormFurnitureTypeName(id)
|
|
local t = XFurnitureConfigs.GetDormFurnitureType(id)
|
|
return t.TypeName
|
|
end
|
|
|
|
function XFurnitureConfigs.GetFurniturePutNumCfg(putId)
|
|
return FurniturePutNumTemplates[putId]
|
|
end
|
|
|
|
-- 获取家具分类数据
|
|
function XFurnitureConfigs.GetFurnitureTemplatePartType()
|
|
local parts = {}
|
|
for _, part in pairs(FurnitureTypeTemplates) do
|
|
if not parts[part.MinorType] then
|
|
parts[part.MinorType] = {}
|
|
parts[part.MinorType].MinorName = part.MinorName
|
|
parts[part.MinorType].Categorys = {}
|
|
end
|
|
local categoryInfo = {}
|
|
categoryInfo.Category = part.Category
|
|
categoryInfo.CategoryName = part.CategoryName
|
|
categoryInfo.Id = part.Id
|
|
|
|
parts[part.MinorType].Categorys[part.Id] = categoryInfo
|
|
end
|
|
|
|
return parts
|
|
end
|
|
|
|
-- 获取家具分类数据数量
|
|
function XFurnitureConfigs.GetFurnitureTemplateTypeCount()
|
|
local count = 0
|
|
for _, _ in pairs(FurnitureTypeTemplates) do
|
|
count = count + 1
|
|
end
|
|
|
|
return count
|
|
end
|
|
|
|
-- 获取家具分类数据List
|
|
function XFurnitureConfigs.GetFurnitureTemplateTypeList()
|
|
local list = {}
|
|
for _, part in pairs(FurnitureTypeTemplates) do
|
|
table.insert(list, part)
|
|
end
|
|
table.sort(list, function(a, b)
|
|
return a.Id < b.Id
|
|
end)
|
|
return list
|
|
end
|
|
|
|
-- 随机属性描述
|
|
function XFurnitureConfigs.GetAdditionalRandomIntroduce(id)
|
|
local currentAttr = FurnitureAdditionalAttr[id]
|
|
|
|
if not currentAttr then
|
|
XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetAdditionalRandomIntroduce",
|
|
"FurnitureAdditionalAttr", SHARE_FURNITURE_ADDITIONALATTR, "Id", tostring(id))
|
|
return
|
|
end
|
|
|
|
return currentAttr.Introduce or ""
|
|
end
|
|
|
|
-- 获取评分词条
|
|
function XFurnitureConfigs.GetAdditionalRandomEntry(id, removeScore)
|
|
local addRandom = XFurnitureConfigs.GetAdditionAttrConfigById(id)
|
|
local quality = addRandom.QualityType < 0 and 2 or addRandom.QualityType
|
|
local color = XFurnitureConfigs.FurnitureAttrColor[quality]
|
|
local level = XFurnitureConfigs.FurnitureAttrLevel[quality]
|
|
if removeScore then
|
|
return string.format("<color=%s>%s</color>", color, level)
|
|
else
|
|
return string.format("<color=%s>%s%d</color>", color, level, addRandom.AddScore)
|
|
end
|
|
end
|
|
|
|
-- 获取一组随机属性描述
|
|
function XFurnitureConfigs.GetGroupRandomIntroduce(groupId, removeScore)
|
|
if DormFurnitureTypeAttsDic[groupId] then
|
|
return DormFurnitureTypeAttsDic[groupId]
|
|
end
|
|
|
|
local tmpRemoveScore = removeScore or false
|
|
local groupIntroduce = {}
|
|
local data = {}
|
|
for _, v in pairs(FurnitureAdditionalAttr) do
|
|
if groupId == v.GroupId then
|
|
table.insert(groupIntroduce, {
|
|
Id = v.AttributeId,
|
|
Introduce = v.Introduce,
|
|
QualityType = v.QualityType,
|
|
AddDes = XFurnitureConfigs.GetAdditionalRandomEntry(v.AttributeId, tmpRemoveScore) or ""
|
|
})
|
|
end
|
|
end
|
|
|
|
if _G.next(groupIntroduce) then
|
|
table.sort(groupIntroduce, function(a, b)
|
|
return a.QualityType > b.QualityType
|
|
end)
|
|
end
|
|
|
|
for _, v in pairs(groupIntroduce) do
|
|
if not data[v.AddDes] then
|
|
data[v.AddDes] = {}
|
|
end
|
|
table.insert(data[v.AddDes], v)
|
|
end
|
|
|
|
DormFurnitureTypeAttsDic[groupId] = data
|
|
|
|
return data
|
|
end
|
|
|
|
-- 家具风格套装
|
|
function XFurnitureConfigs.GetFurnitureSuitTemplates()
|
|
return FurnitureSuitTemplates
|
|
end
|
|
|
|
-- 家具风格套装
|
|
function XFurnitureConfigs.GetFurnitureSuitTemplatesList()
|
|
local list = {}
|
|
for _, v in pairs(FurnitureSuitTemplates) do
|
|
table.insert(list, v)
|
|
end
|
|
table.sort(list, function(a, b)
|
|
return a.Id < b.Id
|
|
end)
|
|
return list
|
|
end
|
|
|
|
-- 宿舍套装类型名字
|
|
function XFurnitureConfigs.GetFurnitureSuitName(id)
|
|
local d = FurnitureSuitTemplates[id]
|
|
if not d then
|
|
return
|
|
end
|
|
|
|
return d.SuitName
|
|
end
|
|
|
|
function XFurnitureConfigs.IsAllSuit(suitId)
|
|
return suitId == nil or suitId == 0 or suitId == 1
|
|
end
|
|
|
|
-- 属性标签
|
|
function XFurnitureConfigs.GetFurnitureTagTypeTemplates()
|
|
return FurnitureTagTypeTemplates
|
|
end
|
|
|
|
-- 获取家具类型下Minor个数
|
|
function XFurnitureConfigs.GetCountByMinor(minor, suitId)
|
|
local minors = FurnitureMinorDatas[minor]
|
|
if not minors then
|
|
return 0
|
|
end
|
|
|
|
local count = 0
|
|
local isAllSuit = XFurnitureConfigs.IsAllSuit(suitId)
|
|
for _, categorys in pairs(minors) do
|
|
for id, suits in pairs(categorys) do
|
|
if isAllSuit or id == suitId then
|
|
count = count + #suits
|
|
end
|
|
end
|
|
end
|
|
|
|
return count
|
|
end
|
|
|
|
-- 获取家具类型下Category个数
|
|
function XFurnitureConfigs.GetCountByCategory(minor, category, suitId)
|
|
local minors = FurnitureMinorDatas[minor]
|
|
if not minors then
|
|
return 0
|
|
end
|
|
|
|
local categorys = minors[category]
|
|
if not categorys then
|
|
return 0
|
|
end
|
|
|
|
local count = 0
|
|
local isAllSuit = XFurnitureConfigs.IsAllSuit(suitId)
|
|
for id, suits in pairs(categorys) do
|
|
if isAllSuit or id == suitId then
|
|
count = count + #suits
|
|
end
|
|
end
|
|
|
|
return count
|
|
end
|
|
|
|
-- 获取家具类型下List
|
|
function XFurnitureConfigs.GetFurnitureCfgList(minorId, categoryId, suitId)
|
|
local list = {}
|
|
local minors = FurnitureMinorDatas[minorId]
|
|
if not minors then
|
|
return list
|
|
end
|
|
|
|
local isAllSuit = XFurnitureConfigs.IsAllSuit(suitId)
|
|
if not categoryId then
|
|
for _, categorys in pairs(minors) do
|
|
for id, suits in pairs(categorys) do
|
|
if isAllSuit or id == suitId then
|
|
for _, suit in ipairs(suits) do
|
|
local data = { ConfigId = suit }
|
|
table.insert(list, data)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
else
|
|
local categorys = minors[categoryId]
|
|
if not categorys then
|
|
return list
|
|
end
|
|
|
|
for id, suits in pairs(categorys) do
|
|
if isAllSuit or id == suitId then
|
|
for _, suit in ipairs(suits) do
|
|
local data = { ConfigId = suit }
|
|
table.insert(list, data)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
return list
|
|
end
|
|
|
|
function XFurnitureConfigs.GetFurnitureConfigIdList(minorType, category, suitId)
|
|
local minors = FurnitureMinorDatas[minorType]
|
|
if not minors then
|
|
return {}
|
|
end
|
|
|
|
local categories = minors[category]
|
|
if not categories then
|
|
return {}
|
|
end
|
|
|
|
local list = {}
|
|
local allSuit = XFurnitureConfigs.IsAllSuit(suitId)
|
|
|
|
for sId, suits in pairs(categories) do
|
|
if allSuit or sId == suitId then
|
|
list = appendArray(list, suits)
|
|
end
|
|
end
|
|
|
|
return list
|
|
end
|
|
|
|
-- 获取某个套装家具总个数
|
|
function XFurnitureConfigs.GetSuitCount(suitId)
|
|
if XFurnitureConfigs.IsAllSuit(suitId) then
|
|
suitId = 0
|
|
end
|
|
return FurnitureSuitDatas[suitId]
|
|
end
|
|
|
|
-- 获取家具类型列表,用于构建二级菜单
|
|
function XFurnitureConfigs.GetFurnitureTypeGroupList()
|
|
return FurnitureTypeGroupList
|
|
end
|
|
|
|
---@return XTable.XTableFurnitureSuit
|
|
function XFurnitureConfigs.GetFurnitureSuitTemplatesById(suitId)
|
|
local currentSuitTemplate = FurnitureSuitTemplates[suitId]
|
|
|
|
if not currentSuitTemplate then
|
|
XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetFurnitureSuitTemplatesById",
|
|
"FurnitureSuit", CLIENT_FURNITURE_SUIT, "suitId", tostring(suitId))
|
|
return
|
|
end
|
|
|
|
return currentSuitTemplate
|
|
end
|
|
|
|
-- 家具客户端数据
|
|
function XFurnitureConfigs.GetFurnitureBaseTemplatesById(id)
|
|
local currentTemplates = FurnitureTemplates[id]
|
|
|
|
if not currentTemplates then
|
|
XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetFurnitureBaseTemplatesById", "Furniture", SHARE_FURNITURE, "Id", tostring(id))
|
|
return
|
|
end
|
|
|
|
return currentTemplates
|
|
end
|
|
|
|
-- 家具名称
|
|
function XFurnitureConfigs.GetFurnitureNameById(id)
|
|
local currentTemplates = XFurnitureConfigs.GetFurnitureBaseTemplatesById(id)
|
|
return currentTemplates.Name
|
|
end
|
|
|
|
-- 家具Icon
|
|
function XFurnitureConfigs.GetFurnitureIconById(id)
|
|
local currentTemplates = XFurnitureConfigs.GetFurnitureBaseTemplatesById(id)
|
|
return currentTemplates.Icon
|
|
end
|
|
|
|
-- 家具描述
|
|
function XFurnitureConfigs.GetFurnitureDescriptionById(id)
|
|
local currentTemplates = XFurnitureConfigs.GetFurnitureBaseTemplatesById(id)
|
|
return currentTemplates.Desc
|
|
end
|
|
|
|
-- 家具大图标
|
|
function XFurnitureConfigs.GetFurnitureBigIconById(id)
|
|
local currentTemplates = XFurnitureConfigs.GetFurnitureBaseTemplatesById(id)
|
|
return currentTemplates.Icon
|
|
end
|
|
|
|
-- 属性类型
|
|
function XFurnitureConfigs.GetFurnitureAttrType()
|
|
local temp = {}
|
|
for k, v in pairs(DormFurnitureTypeTemplate) do
|
|
if k < XFurnitureConfigs.AttrType.AttrAll then
|
|
table.insert(temp, v)
|
|
end
|
|
end
|
|
|
|
return temp
|
|
end
|
|
|
|
-- 获取所有家具
|
|
function XFurnitureConfigs.GetAllFurnitures()
|
|
return FurnitureTemplates
|
|
end
|
|
|
|
-- 家具基础数据
|
|
---@return XTable.XTableFurniture
|
|
function XFurnitureConfigs.GetFurnitureTemplateById(id)
|
|
local currentTemplate = FurnitureTemplates[id]
|
|
|
|
if not currentTemplate then
|
|
XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetFurnitureTemplateById", "Furniture", SHARE_FURNITURE, "Id", tostring(id))
|
|
return
|
|
end
|
|
|
|
return currentTemplate
|
|
end
|
|
|
|
-- 判断家具类型
|
|
function XFurnitureConfigs.IsFurnitureMatchTypeByConfigId(configId, targetType)
|
|
local furnitureTemplates = XFurnitureConfigs.GetFurnitureTemplateById(configId)
|
|
if furnitureTemplates then
|
|
return furnitureTemplates.TypeId == targetType
|
|
end
|
|
return false
|
|
end
|
|
|
|
-- 获取家具类型配置表通过 ConfigID
|
|
function XFurnitureConfigs.GetFurnitureTypeCfgByConfigId(configId)
|
|
local furnitureTemplate = XFurnitureConfigs.GetFurnitureTemplateById(configId)
|
|
if not furnitureTemplate then
|
|
return nil
|
|
end
|
|
|
|
local typeTemplate = XFurnitureConfigs.GetFurnitureTypeById(furnitureTemplate.TypeId)
|
|
return typeTemplate
|
|
end
|
|
|
|
-- 摆放类型转地表类型
|
|
function XFurnitureConfigs.LocateTypeToXHomePlatType(locateType)
|
|
local type = nil
|
|
if locateType == XFurnitureConfigs.HomeLocateType.LocateGround then
|
|
type = CS.XHomePlatType.Ground
|
|
elseif locateType == XFurnitureConfigs.HomeLocateType.LocateWall then
|
|
type = CS.XHomePlatType.Wall
|
|
end
|
|
|
|
return type
|
|
end
|
|
|
|
-- 获取家具交互点列表
|
|
function XFurnitureConfigs.GetFurnitureInteractPosList(posStr)
|
|
local list = {}
|
|
|
|
local strs = string.Split(posStr, "|")
|
|
if strs and #strs > 0 then
|
|
for _, v in ipairs(strs) do
|
|
local xy = string.Split(v, "#")
|
|
if xy and #xy >= 2 then
|
|
local x = tonumber(xy[1])
|
|
local y = tonumber(xy[2])
|
|
if x and y then
|
|
local vec = {}
|
|
vec.x = x
|
|
vec.y = y
|
|
table.insert(list, vec)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
return list
|
|
end
|
|
|
|
-- 获取家具等级配置表
|
|
function XFurnitureConfigs.GetFurnitureLevelTemplate(furnitureType)
|
|
local currentTemplates = FurnitureLevelTemplates[furnitureType]
|
|
|
|
if not currentTemplates then
|
|
XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetFurnitureLevelTemplate",
|
|
"FurnitureLevel", SHARE_FURNITURE_LEVEL, "furnitureType", tostring(furnitureType))
|
|
return
|
|
end
|
|
|
|
return currentTemplates
|
|
end
|
|
-- 获取家具总属性分级描述
|
|
function XFurnitureConfigs.GetFurnitureTotalAttrLevelDescription(furnitureType, totalScore)
|
|
local quality = XFurnitureConfigs.GetFurnitureTotalAttrLevel(furnitureType, totalScore)
|
|
local color = XFurnitureConfigs.FurnitureAttrColor[quality] or XFurnitureConfigs.FurnitureAttrColor[1]
|
|
local level = XFurnitureConfigs.FurnitureAttrLevel[quality] or XFurnitureConfigs.FurnitureAttrLevel[1]
|
|
return string.format(CS.XGame.ClientConfig:GetString("DormAttrFormat"), color, level, totalScore)
|
|
end
|
|
|
|
|
|
function XFurnitureConfigs.GetFurnitureTotalAttrLevelNewColorDescription(furnitureType, totalScore)
|
|
local quality = XFurnitureConfigs.GetFurnitureTotalAttrLevel(furnitureType, totalScore)
|
|
local color = XFurnitureConfigs.FurnitureAttrTagColor[3]-- XFurnitureConfigs.FurnitureAttrTagColor[quality] or XFurnitureConfigs.FurnitureAttrTagColor[3]
|
|
local level = XFurnitureConfigs.FurnitureAttrLevel[quality] or XFurnitureConfigs.FurnitureAttrLevel[1]
|
|
return string.format(CS.XGame.ClientConfig:GetString("DormAttrFormat"), color, level, totalScore)
|
|
end
|
|
|
|
-- 获取家具总属性等级
|
|
function XFurnitureConfigs.GetFurnitureTotalAttrLevel(furnitureType, totalScore)
|
|
local temp = -1
|
|
local furntiureLevels = XFurnitureConfigs.GetFurnitureLevelTemplate(furnitureType)
|
|
local quality = 2
|
|
local maxScore = 0
|
|
local min = totalScore
|
|
for _, v in pairs(furntiureLevels) do
|
|
local minScore = v.MinScore
|
|
if totalScore >= minScore and minScore > temp then
|
|
temp = minScore
|
|
quality = v.Quality
|
|
min = v.MinScore
|
|
end
|
|
|
|
if v.MaxScore > maxScore then
|
|
maxScore = v.MaxScore
|
|
end
|
|
end
|
|
return quality, maxScore, min
|
|
end
|
|
|
|
-- 获取家具单个属性等级
|
|
function XFurnitureConfigs.GetFurnitureSingleAttrLevel(furnitureType, attrIndex, score)
|
|
local temp = -1
|
|
local furntiureLevels = FurnitureSingleAttrLevelIndex[furnitureType]
|
|
local quality = 2
|
|
local maxScore = 0
|
|
local mScore = score
|
|
|
|
for _, v in pairs(furntiureLevels) do
|
|
local minScore = v.AttrMinScore[attrIndex]
|
|
if score >= minScore and minScore > temp then
|
|
temp = minScore
|
|
quality = v.Quality
|
|
mScore = minScore
|
|
end
|
|
|
|
if v.AttrMaxScore[attrIndex] > maxScore then
|
|
maxScore = v.AttrMaxScore[attrIndex]
|
|
end
|
|
end
|
|
|
|
return quality, maxScore, mScore
|
|
end
|
|
|
|
-- 获取家具等级描述
|
|
function XFurnitureConfigs.GetFurnitureAttrLevelDescription(furnitureType, attrType, score)
|
|
local quality = XFurnitureConfigs.GetFurnitureAttrlevel(furnitureType, attrType, score)
|
|
local color = XFurnitureConfigs.FurnitureAttrColor[quality] or XFurnitureConfigs.FurnitureAttrColor[1]
|
|
local level = XFurnitureConfigs.FurnitureAttrLevel[quality] or XFurnitureConfigs.FurnitureAttrLevel[1]
|
|
return string.format(CS.XGame.ClientConfig:GetString("DormAttrFormat"), color, level, score)
|
|
end
|
|
|
|
|
|
-- 获取家具等级描述
|
|
function XFurnitureConfigs.GetFurnitureAttrLevelNewDescription(furnitureType, attrType, score)
|
|
local quality = XFurnitureConfigs.GetFurnitureAttrlevel(furnitureType, attrType, score)
|
|
local color = XFurnitureConfigs.FurnitureAttrTagColor[quality] or XFurnitureConfigs.FurnitureAttrTagColor[1]
|
|
local level = XFurnitureConfigs.FurnitureAttrLevel[quality] or XFurnitureConfigs.FurnitureAttrLevel[1]
|
|
return string.format(CS.XGame.ClientConfig:GetString("DormAttrFormat"), color, level, score)
|
|
end
|
|
|
|
|
|
-- 获取家具属性等级
|
|
function XFurnitureConfigs.GetFurnitureAttrlevel(furnitureType, attrType, score)
|
|
local temp = -1
|
|
local furntiureLevels = XFurnitureConfigs.GetFurnitureLevelTemplate(furnitureType)
|
|
local quality = 2
|
|
|
|
for _, v in pairs(furntiureLevels) do
|
|
local attrScore = v.AttrScore[attrType] or 0
|
|
if score >= attrScore and attrScore > temp then
|
|
temp = attrScore
|
|
quality = v.Quality
|
|
end
|
|
end
|
|
return quality
|
|
end
|
|
|
|
-- 获取家具摆放类型
|
|
function XFurnitureConfigs.GetFurniturePlaceType(furnitureTypeId)
|
|
if not furnitureTypeId then
|
|
XLog.Error("XFurnitureConfigs.GetFurniturePlaceType furnitureTypeId is nil.")
|
|
return
|
|
end
|
|
|
|
local typeCfg = FurnitureTypeTemplates[furnitureTypeId]
|
|
if not typeCfg then
|
|
XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetFurniturePlaceType", "FurnitureType", SHARE_FURNITURE_TYPE, "Id", tostring(furnitureTypeId))
|
|
return
|
|
end
|
|
|
|
if typeCfg.MajorType == 1 and typeCfg.MinorType == 1 then
|
|
return XFurniturePlaceType.Ground
|
|
elseif typeCfg.MajorType == 1 and typeCfg.MinorType == 2 then
|
|
return XFurniturePlaceType.Wall
|
|
elseif typeCfg.MajorType == 1 and typeCfg.MinorType == 3 then
|
|
return XFurniturePlaceType.Ceiling
|
|
elseif typeCfg.MajorType == 2 and typeCfg.MinorType == 6 then
|
|
return XFurniturePlaceType.OnWall
|
|
else
|
|
return XFurniturePlaceType.OnGround
|
|
end
|
|
end
|
|
|
|
-- 获取所有家具类型
|
|
---@return table<number,XTable.XTableFurnitureType>
|
|
function XFurnitureConfigs.GetAllFurnitureTypes()
|
|
return FurnitureTypeTemplates
|
|
end
|
|
|
|
-- 家具类型数据
|
|
---@return XTable.XTableFurnitureType
|
|
function XFurnitureConfigs.GetFurnitureTypeById(id)
|
|
local currentTemplates = FurnitureTypeTemplates[id]
|
|
|
|
if not currentTemplates then
|
|
XLog.Error("XFurnitureConfigs.GetFurnitureType not found by id : " .. tostring(id))
|
|
end
|
|
|
|
return currentTemplates
|
|
end
|
|
|
|
-- 家具属基础性数据
|
|
function XFurnitureConfigs.GetFurnitureBaseAttrValueById(id)
|
|
local furnitureBaseAttrTemplate = FurnitureBaseAttrTemplate[id]
|
|
|
|
if not furnitureBaseAttrTemplate then
|
|
return 0
|
|
end
|
|
|
|
return furnitureBaseAttrTemplate.Value
|
|
end
|
|
|
|
-- 家具属额外性数据
|
|
function XFurnitureConfigs.GetFurnitureExtraAttrsById(id)
|
|
local attrIds = {}
|
|
local furnitureExtraAttrTemplate = FurnitureExtraAttrTemplate[id]
|
|
|
|
if not furnitureExtraAttrTemplate then
|
|
return attrIds
|
|
end
|
|
|
|
return furnitureExtraAttrTemplate
|
|
end
|
|
|
|
function XFurnitureConfigs.GetFurnitureExtraAttrTotalValue(id)
|
|
if not FurnitureExtraAttrTemplate[id] then
|
|
return 0
|
|
end
|
|
|
|
return XFurnitureConfigs.GetFurnitureBaseAttrValueById(FurnitureExtraAttrTemplate[id].BaseAttrId)
|
|
+ XFurnitureConfigs.GetFurnitureBaseAttrValueById(FurnitureExtraAttrTemplate[id].RemakeExtraAttrId)
|
|
end
|
|
|
|
-- 最低,最高档位
|
|
function XFurnitureConfigs.GetFurnitureCreateMinAndMax()
|
|
local minConsume = FurnitureCreateAttr[1].MinConsume
|
|
local maxConsume = FurnitureCreateAttr[1].MinConsume
|
|
for _, v in pairs(FurnitureCreateAttr) do
|
|
if v.MinConsume < minConsume then
|
|
minConsume = v.MinConsume
|
|
end
|
|
if v.MinConsume > maxConsume then
|
|
maxConsume = v.MinConsume
|
|
end
|
|
end
|
|
return minConsume, maxConsume
|
|
end
|
|
|
|
---@param furniture XHomeFurnitureData
|
|
function XFurnitureConfigs.CheckFurnitureRemake(furniture, cost)
|
|
if not furniture then
|
|
return false
|
|
end
|
|
local template = XFurnitureConfigs.GetFurnitureTemplateById(furniture:GetConfigId())
|
|
if not template then
|
|
return false
|
|
end
|
|
local attrId
|
|
for id, temp in pairs(FurnitureCreateAttr) do
|
|
if temp.FurnitureType == template.TypeId and temp.MinConsume == cost then
|
|
attrId = id
|
|
break
|
|
end
|
|
end
|
|
|
|
if not attrId then
|
|
return false
|
|
end
|
|
|
|
local attr = FurnitureCreateAttr[attrId]
|
|
local totalScore = furniture:GetAttrTotal() - attr.ExtraAttrTotal[1]
|
|
local attrTotals = attr.AttrTotal
|
|
for i = #attrTotals, 1, -1 do
|
|
if attrTotals[i] >= totalScore then
|
|
return true
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
|
|
-- 根据家具拿到对应的图纸,一一对应,家具不一定有对应的图纸,如果没有则不能改装
|
|
function XFurnitureConfigs.GetDrawingByFurnitureId(furnitureId)
|
|
return FurnitureToDrawingMap[furnitureId]
|
|
end
|
|
|
|
-- 根据图纸拿到预览的家具,一一对应,图纸一定有对应的家具
|
|
function XFurnitureConfigs.GetPreviewFurnitureByDrawingId(drawingId)
|
|
return DrawingToFurnitureMap[drawingId]
|
|
end
|
|
|
|
function XFurnitureConfigs.GetRefitTypeDatas(typeId)
|
|
return DrawingPicMap[typeId]
|
|
end
|
|
|
|
-- 根据家具基础类型设置视角
|
|
function XFurnitureConfigs.GetFurnitureViewAngleByMinor(minor)
|
|
local currentViewAngle = FurnitureViewAngle[minor]
|
|
if not currentViewAngle then
|
|
XLog.Error("XFurnitureConfigs.GetFurnitureViewAngleByMinor is not found by minor :" .. tostring(minor))
|
|
return
|
|
end
|
|
return currentViewAngle
|
|
end
|
|
|
|
function XFurnitureConfigs.GetFurnitureColour(furnitureId)
|
|
return FurnitureColour[furnitureId]
|
|
end
|
|
|
|
-- 获取家具套装
|
|
function XFurnitureConfigs.GetFurnitureSuitConfig(configId)
|
|
local furnitureTemplate = XFurnitureConfigs.GetFurnitureTemplateById(configId)
|
|
if furnitureTemplate.SuitId <= 0 then
|
|
return nil
|
|
end
|
|
|
|
return XFurnitureConfigs.GetFurnitureSuitTemplatesById(furnitureTemplate.SuitId)
|
|
end
|
|
|
|
-- 图鉴显示配置数据
|
|
function XFurnitureConfigs.GetFieldGuideDatas()
|
|
local data = {}
|
|
|
|
for _, v in pairs(FurnitureTemplates) do
|
|
if v and v.SuitId and v.SuitId > 0 then
|
|
if not data[v.SuitId] then
|
|
data[v.SuitId] = {}
|
|
end
|
|
table.insert(data[v.SuitId], v)
|
|
end
|
|
end
|
|
|
|
return data
|
|
end
|
|
|
|
-- 获取家具回收奖励Id
|
|
function XFurnitureConfigs.GetFurnitureReturnId(configId)
|
|
local furnitureTemplate = XFurnitureConfigs.GetFurnitureTemplateById(configId)
|
|
if not furnitureTemplate.ReturnId or furnitureTemplate.ReturnId <= 0 then
|
|
return nil
|
|
end
|
|
|
|
return furnitureTemplate.ReturnId
|
|
end
|
|
|
|
function XFurnitureConfigs.GetFurnitureReward(id)
|
|
return FurnitureRewardTemplate[id]
|
|
end
|
|
|
|
-- 根据套装Id获取家具配置Id, 目前使用频率不高,若需要频繁使用请用缓存
|
|
function XFurnitureConfigs.GetFurnitureConfigIdsBySuitId(suitId)
|
|
if XFurnitureConfigs.IsAllSuit(suitId) then
|
|
return {}
|
|
end
|
|
local list = {}
|
|
for _, template in pairs(FurnitureTemplates) do
|
|
if template.SuitId == suitId then
|
|
table.insert(list, template.Id)
|
|
end
|
|
end
|
|
return list
|
|
end
|
|
|
|
-- 计算恢复速度
|
|
function XFurnitureConfigs.GetRecoverSpeed(speed)
|
|
local tempSpeed = string.format("%.1f", speed / 100)
|
|
|
|
if tempSpeed * 10 % 10 == 0 then
|
|
tempSpeed = string.format("%d", tempSpeed)
|
|
end
|
|
|
|
return tempSpeed
|
|
end |