using System.Collections.ObjectModel; namespace NeonSprawl.Server.Game.Gathering; /// In-memory resource-node catalog loaded at startup (NEO-58). Game callers should use . public sealed class ResourceNodeCatalog( string resourceNodesDirectory, IReadOnlyDictionary nodesById, IReadOnlyDictionary yieldsByNodeDefId, int nodeCatalogJsonFileCount, int yieldCatalogJsonFileCount) { /// Absolute path to the directory enumerated for *_resource_nodes.json / *_resource_yields.json. public string ResourceNodesDirectory { get; } = resourceNodesDirectory; public IReadOnlyDictionary NodesById { get; } = new ReadOnlyDictionary(new Dictionary(nodesById, StringComparer.Ordinal)); public IReadOnlyDictionary YieldsByNodeDefId { get; } = new ReadOnlyDictionary(new Dictionary(yieldsByNodeDefId, StringComparer.Ordinal)); public int DistinctNodeCount => NodesById.Count; public int DistinctYieldCount => YieldsByNodeDefId.Count; /// Number of *_resource_nodes.json files under . public int NodeCatalogJsonFileCount { get; } = nodeCatalogJsonFileCount; /// Number of *_resource_yields.json files under . public int YieldCatalogJsonFileCount { get; } = yieldCatalogJsonFileCount; /// Resolves a node def by stable . public bool TryGetNode(string nodeDefId, out ResourceNodeDefRow? row) => NodesById.TryGetValue(nodeDefId, out row); /// Resolves the fixed yield row for . public bool TryGetYield(string nodeDefId, out ResourceYieldRow? row) => YieldsByNodeDefId.TryGetValue(nodeDefId, out row); }