package catalogs
import (
"encoding/json"
"os"
"path/filepath"
"sync"
)
var _ = json.RawMessage{}
var _ = sync.Mutex{}
var _ = os.ReadFile
var _ = filepath.Join
//
// HouseFurnitureConfig 的一行里,本服务端真正用得到的部分。
// 为什么需要它:AskLoadHouseData 下发的家具树只带
// FurnitureId + 世界坐标 + PlacedInstanceId,GadgetInstanceId 恒 0。
// 客户端拿到树之后会再问一次服务端:
// AskCreateHouseFurnitureGadgets(houseId, floor, placedIds)
// (LX6/Manager/House/HouseGadgetManager.lua:CreateGadgetsForFurnitures),
// 期望拿到 placedId → gadgetInstanceId 的映射。
// 服务端要造这个 gadget,唯一缺的就是「这件家具对应哪个机关 prefab」——
// 那就是本表的 PathId。
// ★ 关键结论(2026-10-01 取证):HouseFurnitureConfig.PathId
// 不是普通模型路径,它就是 Configs/GadgetCatalog.json 里的 pathId。
// 逐条核对(服务端自己的 GadgetCatalog,2935 条):
//
// 506042876 HouseChairs_p_house_prop_furniture_seat_008a 组 housechairs ← 翡翠绒创意椅
// 507159035 HouseChairs_p_house_prop_furniture_seat_009a 组 housechairs ← 翡翠绒方凳
// 1303452314 HouseLight_p_house_prop_deco_lamp_floorlamp002a 组 houselight ← 复古落地灯 / 创意云朵灯
// 1692603756 HouseLazyrsofa_p_house_prop_fumirure_seat_020a 组 other ← 皮质懒人沙发
// 539100309 HouseWatchTV_p_house_prop_facility_leisure_005a 组 housewatchtv ← 高清触控屏
// 333142511 Gadgets_House_WardrobeDoor_FashionChange_..._060a... 组 gadgets ← 白松移门衣柜(换装)
//
// 而且客户端自己也把这条链说死了:HouseGadgetManager.IsFurnitureWithGadget(fid)
// 的判据就是 PathId ~= 0(反编译出的 == 0 要翻转)。
// ★ 判据(为什么说树是对的、只缺 gadget):客户端请求的 id 个数
// 逐套精确等于「该房模板树里 PathId != 0 的家具数」——
// 绿屿 33/33、旧物仓 3/3、观澜 6/6、素光 1/1。
//
// HouseFurnitureConfig.Id(也是模板节点的 FurnitureId)。
// 中文名,只用于日志。
// GadgetCatalog.json 的 pathId;0 = 这件家具没有机关,客户端也不会来问。
// GadgetOffset 原始数组(实测 6 个 float:pos xyz + rot xyz)。
// 全表 323 条里只有 2 条非空,且都不在四套房的模板树里 ⇒ 正常情况是空。
type HouseFurnitureDefinition4229938 struct {
FurnitureId uint32 `json:"furnitureId"`
Name string `json:"name"`
PathId uint32 `json:"pathId"`
GadgetOffset []float32 `json:"gadgetOffset"`
}
//
// Reads Configs/HouseFurnitureConfig.json(323 行,_expectedCount == _dumpedCount == 323,
// 2026-10-01 从 E:\ConfigDump\ConfigDump_v3\ 原样拷入)。
// 消费点只有一个:GameRouter.HouseFurnitureGadget.cs 的
// AskCreateHouseFurnitureGadgets(63581446) —— 把 placedId 反解成
// nodeId → FurnitureId → PathId,再用 SyncGadgetAdd 把机关实体摆到
// 家具节点的世界坐标上。
// ⛑ 带 Lazy 缓存 ⇒ 改了要重启服务端(和 NpcCatalog.json /
// HouseFurnitureTemplateCatalog4229938 一个规矩)。
//
var (
HouseFurnitureGadgetCatalog4229938_cacheLock sync.RWMutex
HouseFurnitureGadgetCatalog4229938_cached = false
HouseFurnitureGadgetCatalog4229938_entries []any
)
// LoadHouseFurnitureGadgetCatalog4229938 loads catalog records from client config directory
func LoadHouseFurnitureGadgetCatalog4229938(configDir string) ([]any, error) {
HouseFurnitureGadgetCatalog4229938_cacheLock.RLock()
if HouseFurnitureGadgetCatalog4229938_cached {
defer HouseFurnitureGadgetCatalog4229938_cacheLock.RUnlock()
return HouseFurnitureGadgetCatalog4229938_entries, nil
}
HouseFurnitureGadgetCatalog4229938_cacheLock.RUnlock()
HouseFurnitureGadgetCatalog4229938_cacheLock.Lock()
defer HouseFurnitureGadgetCatalog4229938_cacheLock.Unlock()
if HouseFurnitureGadgetCatalog4229938_cached { return HouseFurnitureGadgetCatalog4229938_entries, nil }
filePath := filepath.Join(configDir, "HouseFurnitureGadgetCatalog.json.json")
data, err := os.ReadFile(filePath)
if err != nil {
return nil, err
}
var raw struct {
Records []json.RawMessage `json:"records"`
}
if err := json.Unmarshal(data, &raw); err != nil {
return nil, err
}
var result []any
for _, item := range raw.Records {
var m map[string]any
if err := json.Unmarshal(item, &m); err == nil {
result = append(result, m)
}
}
HouseFurnitureGadgetCatalog4229938_entries = result
HouseFurnitureGadgetCatalog4229938_cached = true
return result, nil
}
func HouseFurnitureGadgetCatalog4229938_TryGet(furnitureId uint32, definition HouseFurnitureDefinition4229938) bool {
// Catalog helper HouseFurnitureGadgetCatalog4229938_TryGet
return false
}
//
// 这件家具对应的机关 prefab pathId(GadgetCatalog.json 的 key)。
// 0 = 没有机关,调用方应跳过。
//
func HouseFurnitureGadgetCatalog4229938_TryGetGadgetPathId(furnitureId uint32, pathId uint32) bool {
// Catalog helper HouseFurnitureGadgetCatalog4229938_TryGetGadgetPathId
return false
}
func HouseFurnitureGadgetCatalog4229938_U32(source any, name string) uint32 {
// Catalog helper HouseFurnitureGadgetCatalog4229938_U32
return 0
}
func HouseFurnitureGadgetCatalog4229938_Str(source any, name string) string {
// Catalog helper HouseFurnitureGadgetCatalog4229938_Str
return ""
}
// 读 [f, f, f, ...] 这种纯数字数组。
func HouseFurnitureGadgetCatalog4229938_F32List(source any, name string) []float32 {
// Catalog helper HouseFurnitureGadgetCatalog4229938_F32List
return nil
}
type HouseFurnitureGadgetCatalog4229938_Snapshot struct {
Items map[uint32]HouseFurnitureDefinition4229938 `json:"items"`
Error *string `json:"error"`
}