91 lines
2.7 KiB
Go
91 lines
2.7 KiB
Go
package catalogs
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"sync"
|
|
)
|
|
|
|
var _ = json.RawMessage{}
|
|
var _ = sync.Mutex{}
|
|
var _ = os.ReadFile
|
|
var _ = filepath.Join
|
|
|
|
// One summonable AgentConfig row surfaced by the 生成敌人 / 生成NPC panel sections.
|
|
type NpcSummonEntry4229938 struct {
|
|
Id uint32 `json:"id"`
|
|
Name string `json:"name"`
|
|
EnemyClassType uint32 `json:"enemyClassType"`
|
|
GroupEnemy uint32 `json:"groupEnemy"`
|
|
AiSetting uint32 `json:"aiSetting"`
|
|
Hostile bool `json:"hostile"`
|
|
// AgentConfig.InitWeaponId — the weapon the client must bind for the unit to be able
|
|
// to attack / be hit. Falls back to 98005506 (黑金节奏手's weapon) when the row has none.
|
|
InitWeaponId uint32 `json:"initWeaponId"`
|
|
}
|
|
|
|
//
|
|
// Build-4229938 agent summon catalog, read from AgentSummonCatalog.json in the configured
|
|
// client-data directory.
|
|
// That file is a slim projection of the client's 55 MB AgentConfig.json (Id / CNName /
|
|
// EnemyClassType / GroupEnemy / AI) so the panel does not have to parse the full table at
|
|
// startup. Categorisation mirrors the client's own semantics: EnemyClassType 1/2/4/6/7 are
|
|
// hostile combat agents, EnemyClassType 9 is the civilian / "other" bucket.
|
|
//
|
|
var (
|
|
NpcSummonCatalog4229938_cacheLock sync.RWMutex
|
|
NpcSummonCatalog4229938_cached = false
|
|
NpcSummonCatalog4229938_entries []any
|
|
)
|
|
|
|
// LoadNpcSummonCatalog4229938 loads catalog records from client config directory
|
|
func LoadNpcSummonCatalog4229938(configDir string) ([]any, error) {
|
|
NpcSummonCatalog4229938_cacheLock.RLock()
|
|
if NpcSummonCatalog4229938_cached {
|
|
defer NpcSummonCatalog4229938_cacheLock.RUnlock()
|
|
return NpcSummonCatalog4229938_entries, nil
|
|
}
|
|
NpcSummonCatalog4229938_cacheLock.RUnlock()
|
|
|
|
NpcSummonCatalog4229938_cacheLock.Lock()
|
|
defer NpcSummonCatalog4229938_cacheLock.Unlock()
|
|
if NpcSummonCatalog4229938_cached { return NpcSummonCatalog4229938_entries, nil }
|
|
|
|
filePath := filepath.Join(configDir, "NpcSummonCatalog.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)
|
|
}
|
|
}
|
|
|
|
NpcSummonCatalog4229938_entries = result
|
|
NpcSummonCatalog4229938_cached = true
|
|
return result, nil
|
|
}
|
|
|
|
func NpcSummonCatalog4229938_Find(id uint32) *NpcSummonEntry4229938 {
|
|
// Catalog helper NpcSummonCatalog4229938_Find
|
|
return nil
|
|
}
|
|
|
|
func NpcSummonCatalog4229938_IsHostileClass(enemyClassType uint32) bool {
|
|
// Catalog helper NpcSummonCatalog4229938_IsHostileClass
|
|
return false
|
|
}
|
|
|