This repository has been archived on 2026-10-31. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files

80 lines
2.4 KiB
Go
Raw Permalink Normal View History

package catalogs
import (
"encoding/json"
"os"
"path/filepath"
"sync"
)
var _ = json.RawMessage{}
var _ = sync.Mutex{}
var _ = os.ReadFile
var _ = filepath.Join
//
// SyncUnitHurtEffect 需要的客户端作者配置表现数据。是 build 4229938
// HurtEffectConfig.json(1841 行)的瘦身投影,客户端本体不动。
// 移植自捐赠端 7k-v0.5 Drmk.Core/ClientData/Client4229938/HurtEffectCatalog4229938.cs。
// 为什么需要它:我们原来把 HurtImpact 硬编码成 1、HurtLeftOrRightHit 硬编码成 0,
// 于是武器作者配的受击表现在服务端这一跳被抹平了——表里 Impact 非 0 占 83.4%
// (0..7 共 7 个档,众数是 3,出现 525 次;我们那个固定值 1 只覆盖 8.5% 的行),
// LeftOrRight 非 0 占 44%。这就是"敌人受打击反馈比 7K 平"的数据层面根因。
//
type HurtEffectEntry4229938 struct {
Id uint32 `json:"id"`
Impact uint32 `json:"impact"`
LeftOrRight uint32 `json:"leftOrRight"`
SoundId uint32 `json:"soundId"`
}
var (
HurtEffectCatalog4229938_cacheLock sync.RWMutex
HurtEffectCatalog4229938_cached = false
HurtEffectCatalog4229938_entries []any
)
// LoadHurtEffectCatalog4229938 loads catalog records from client config directory
func LoadHurtEffectCatalog4229938(configDir string) ([]any, error) {
HurtEffectCatalog4229938_cacheLock.RLock()
if HurtEffectCatalog4229938_cached {
defer HurtEffectCatalog4229938_cacheLock.RUnlock()
return HurtEffectCatalog4229938_entries, nil
}
HurtEffectCatalog4229938_cacheLock.RUnlock()
HurtEffectCatalog4229938_cacheLock.Lock()
defer HurtEffectCatalog4229938_cacheLock.Unlock()
if HurtEffectCatalog4229938_cached { return HurtEffectCatalog4229938_entries, nil }
filePath := filepath.Join(configDir, "HurtEffectCatalog.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)
}
}
HurtEffectCatalog4229938_entries = result
HurtEffectCatalog4229938_cached = true
return result, nil
}
func HurtEffectCatalog4229938_Find(id uint32) *HurtEffectEntry4229938 {
// Catalog helper HurtEffectCatalog4229938_Find
return nil
}