mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-03-01 00:35:36 +08:00
优化架构
This commit is contained in:
60
gs/config/gadget_data.go
Normal file
60
gs/config/gadget_data.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"hk4e/gs/constant"
|
||||
"hk4e/logger"
|
||||
"os"
|
||||
)
|
||||
|
||||
type GadgetData struct {
|
||||
Id int32 `json:"id"`
|
||||
Type string `json:"type"`
|
||||
JsonName string `json:"jsonName"`
|
||||
IsInteractive bool `json:"isInteractive"`
|
||||
Tags []string `json:"tags"`
|
||||
ItemJsonName string `json:"itemJsonName"`
|
||||
InteeIconName string `json:"inteeIconName"`
|
||||
NameTextMapHash int64 `json:"nameTextMapHash"`
|
||||
CampID int32 `json:"campID"`
|
||||
LODPatternName string `json:"LODPatternName"`
|
||||
|
||||
// 计算属性
|
||||
TypeX uint16 `json:"-"`
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) loadGadgetData() {
|
||||
g.GadgetDataMap = make(map[int32]*GadgetData)
|
||||
fileNameList := []string{"GadgetExcelConfigData.json"}
|
||||
for _, fileName := range fileNameList {
|
||||
fileData, err := os.ReadFile(g.excelBinPrefix + fileName)
|
||||
if err != nil {
|
||||
logger.LOG.Error("open file error: %v", err)
|
||||
continue
|
||||
}
|
||||
list := make([]map[string]any, 0)
|
||||
err = json.Unmarshal(fileData, &list)
|
||||
if err != nil {
|
||||
logger.LOG.Error("parse file error: %v", err)
|
||||
continue
|
||||
}
|
||||
for _, v := range list {
|
||||
i, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
logger.LOG.Error("parse file error: %v", err)
|
||||
continue
|
||||
}
|
||||
gadgetData := new(GadgetData)
|
||||
err = json.Unmarshal(i, gadgetData)
|
||||
if err != nil {
|
||||
logger.LOG.Error("parse file error: %v", err)
|
||||
continue
|
||||
}
|
||||
g.GadgetDataMap[gadgetData.Id] = gadgetData
|
||||
}
|
||||
}
|
||||
logger.LOG.Info("load %v GadgetData", len(g.GadgetDataMap))
|
||||
for _, v := range g.GadgetDataMap {
|
||||
v.TypeX = constant.EntityTypeConst.STRING_MAP[v.Type]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user