92 lines
2.8 KiB
Go
92 lines
2.8 KiB
Go
package catalogs
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"encoding/json"
|
||
|
|
"os"
|
||
|
|
"path/filepath"
|
||
|
|
"sync"
|
||
|
|
)
|
||
|
|
|
||
|
|
var _ = json.RawMessage{}
|
||
|
|
var _ = sync.Mutex{}
|
||
|
|
var _ = os.ReadFile
|
||
|
|
var _ = filepath.Join
|
||
|
|
|
||
|
|
// One citizen inside a preset crowd group: the NPC template, the POI action it plays
|
||
|
|
// and the human-readable labels projected from the source spreadsheets (panel display only).
|
||
|
|
type CivilianGroupItem4229938 struct {
|
||
|
|
NpcFormworkId uint32 `json:"npcFormworkId"`
|
||
|
|
PoiActionId uint32 `json:"poiActionId"`
|
||
|
|
NpcName string `json:"npcName"`
|
||
|
|
NpcDesc string `json:"npcDesc"`
|
||
|
|
Action string `json:"action"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// A preset crowd group of 20 citizens, one per POI action.
|
||
|
|
type CivilianGroup4229938 struct {
|
||
|
|
Id int32 `json:"id"`
|
||
|
|
Label string `json:"label"`
|
||
|
|
Category string `json:"category"`
|
||
|
|
SystemOnly bool `json:"systemOnly"`
|
||
|
|
Items []CivilianGroupItem4229938 `json:"items"`
|
||
|
|
}
|
||
|
|
|
||
|
|
//
|
||
|
|
// Reads Configs/CivilianGroups.json, produced by _gen_civilian_groups.py from
|
||
|
|
// NPC与敌人ID.xlsx (sheet 「NPC ID清单」) and NPC反应全清单.txt.
|
||
|
|
// Selection rules baked into the generated file (agreed 2026-09-18):
|
||
|
|
// NPC — 类型=人形角色, 物种=人形, 默认阵营=2, 标签不含 占位/测试;按体型(少男/少女/成男/成女/
|
||
|
|
// 中年…)与反应名匹配,全库尽量不重复。
|
||
|
|
// 反应 — 清单里去重后的每一个 POI 动作,每组 20 个,★ 系统行为排在最后。
|
||
|
|
// Regenerate with: _gen_civilian_groups.py, then _check_civilian_groups.py.
|
||
|
|
//
|
||
|
|
var (
|
||
|
|
CivilianGroupCatalog4229938_cacheLock sync.RWMutex
|
||
|
|
CivilianGroupCatalog4229938_cached = false
|
||
|
|
CivilianGroupCatalog4229938_entries []any
|
||
|
|
)
|
||
|
|
|
||
|
|
// LoadCivilianGroupCatalog4229938 loads catalog records from client config directory
|
||
|
|
func LoadCivilianGroupCatalog4229938(configDir string) ([]any, error) {
|
||
|
|
CivilianGroupCatalog4229938_cacheLock.RLock()
|
||
|
|
if CivilianGroupCatalog4229938_cached {
|
||
|
|
defer CivilianGroupCatalog4229938_cacheLock.RUnlock()
|
||
|
|
return CivilianGroupCatalog4229938_entries, nil
|
||
|
|
}
|
||
|
|
CivilianGroupCatalog4229938_cacheLock.RUnlock()
|
||
|
|
|
||
|
|
CivilianGroupCatalog4229938_cacheLock.Lock()
|
||
|
|
defer CivilianGroupCatalog4229938_cacheLock.Unlock()
|
||
|
|
if CivilianGroupCatalog4229938_cached { return CivilianGroupCatalog4229938_entries, nil }
|
||
|
|
|
||
|
|
filePath := filepath.Join(configDir, "CivilianGroupCatalog.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)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
CivilianGroupCatalog4229938_entries = result
|
||
|
|
CivilianGroupCatalog4229938_cached = true
|
||
|
|
return result, nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func CivilianGroupCatalog4229938_Find(id int32) *CivilianGroup4229938 {
|
||
|
|
// Catalog helper CivilianGroupCatalog4229938_Find
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|