146 lines
4.4 KiB
Go
146 lines
4.4 KiB
Go
package catalogs
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"sync"
|
|
)
|
|
|
|
var _ = json.RawMessage{}
|
|
var _ = sync.Mutex{}
|
|
var _ = os.ReadFile
|
|
var _ = filepath.Join
|
|
|
|
//
|
|
// Donor-build catalog entries for the static-NPC path, projected ahead of time.
|
|
// The donor reads the full 57 MB AgentConfig.json (and UrbanDiversityPOIActionConfig.json +
|
|
// BelongingBelongingUsageConfig.json) and computes persona / animSetTag / belonging items on
|
|
// load. v0.3 does not ship those source tables — it ships the same data already reduced to
|
|
// NpcCatalog.json and PoiActionCatalog.json, produced by the _gen_npc_catalog.py /
|
|
// _gen_poi_catalog.py pair. So this class is the donor's Load() with the derivation step
|
|
// already applied: every remaining field is a direct read of a projected column.
|
|
// Keep it that way — the point of this file is to reproduce the donor's *inputs*, not to
|
|
// refactor them. If a field ever has to change, change the projection script too.
|
|
//
|
|
type DonorNpcCatalogEntry4229938 struct {
|
|
Id uint32 `json:"id"`
|
|
Name string `json:"name"`
|
|
GeneralModelId uint32 `json:"generalModelId"`
|
|
AgentPersonaId uint32 `json:"agentPersonaId"`
|
|
AnimSetTag uint32 `json:"animSetTag"`
|
|
BehaviorActionConfigId uint32 `json:"behaviorActionConfigId"`
|
|
ActionGroupId uint32 `json:"actionGroupId"`
|
|
AiSettingId uint32 `json:"aiSettingId"`
|
|
InteractSettingId uint32 `json:"interactSettingId"`
|
|
}
|
|
|
|
var (
|
|
DonorNpcCatalog4229938_cacheLock sync.RWMutex
|
|
DonorNpcCatalog4229938_cached = false
|
|
DonorNpcCatalog4229938_entries []any
|
|
)
|
|
|
|
// LoadDonorNpcCatalog4229938 loads catalog records from client config directory
|
|
func LoadDonorNpcCatalog4229938(configDir string) ([]any, error) {
|
|
DonorNpcCatalog4229938_cacheLock.RLock()
|
|
if DonorNpcCatalog4229938_cached {
|
|
defer DonorNpcCatalog4229938_cacheLock.RUnlock()
|
|
return DonorNpcCatalog4229938_entries, nil
|
|
}
|
|
DonorNpcCatalog4229938_cacheLock.RUnlock()
|
|
|
|
DonorNpcCatalog4229938_cacheLock.Lock()
|
|
defer DonorNpcCatalog4229938_cacheLock.Unlock()
|
|
if DonorNpcCatalog4229938_cached { return DonorNpcCatalog4229938_entries, nil }
|
|
|
|
filePath := filepath.Join(configDir, "DonorNpcCatalog.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)
|
|
}
|
|
}
|
|
|
|
DonorNpcCatalog4229938_entries = result
|
|
DonorNpcCatalog4229938_cached = true
|
|
return result, nil
|
|
}
|
|
|
|
func DonorNpcCatalog4229938_TryGet(id uint32, entry DonorNpcCatalogEntry4229938) bool {
|
|
// Catalog helper DonorNpcCatalog4229938_TryGet
|
|
return false
|
|
}
|
|
|
|
type DonorPoiActionCatalogEntry4229938 struct {
|
|
Id uint32 `json:"id"`
|
|
MainActionGroup uint32 `json:"mainActionGroup"`
|
|
MainActions []uint32 `json:"mainActions"`
|
|
UsageId uint32 `json:"usageId"`
|
|
BelongingSceneItems []uint32 `json:"belongingSceneItems"`
|
|
}
|
|
|
|
var (
|
|
DonorPoiActionCatalog4229938_cacheLock sync.RWMutex
|
|
DonorPoiActionCatalog4229938_cached = false
|
|
DonorPoiActionCatalog4229938_entries []any
|
|
)
|
|
|
|
// LoadDonorPoiActionCatalog4229938 loads catalog records from client config directory
|
|
func LoadDonorPoiActionCatalog4229938(configDir string) ([]any, error) {
|
|
DonorPoiActionCatalog4229938_cacheLock.RLock()
|
|
if DonorPoiActionCatalog4229938_cached {
|
|
defer DonorPoiActionCatalog4229938_cacheLock.RUnlock()
|
|
return DonorPoiActionCatalog4229938_entries, nil
|
|
}
|
|
DonorPoiActionCatalog4229938_cacheLock.RUnlock()
|
|
|
|
DonorPoiActionCatalog4229938_cacheLock.Lock()
|
|
defer DonorPoiActionCatalog4229938_cacheLock.Unlock()
|
|
if DonorPoiActionCatalog4229938_cached { return DonorPoiActionCatalog4229938_entries, nil }
|
|
|
|
filePath := filepath.Join(configDir, "DonorPoiActionCatalog.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)
|
|
}
|
|
}
|
|
|
|
DonorPoiActionCatalog4229938_entries = result
|
|
DonorPoiActionCatalog4229938_cached = true
|
|
return result, nil
|
|
}
|
|
|
|
func DonorPoiActionCatalog4229938_TryGet(id uint32, entry DonorPoiActionCatalogEntry4229938) bool {
|
|
// Catalog helper DonorPoiActionCatalog4229938_TryGet
|
|
return false
|
|
}
|
|
|