neon-sprawl/server/NeonSprawl.Server/Game/Npc/NpcBehaviorDefinitionCatalo...

26 lines
1.2 KiB
C#

using System.Collections.ObjectModel;
namespace NeonSprawl.Server.Game.Npc;
/// <summary>In-memory NPC behavior catalog loaded at startup (NEO-88). Game callers should use INpcBehaviorDefinitionRegistry (NEO-89).</summary>
public sealed class NpcBehaviorDefinitionCatalog(
string npcBehaviorsDirectory,
IReadOnlyDictionary<string, NpcBehaviorDefRow> byId,
int catalogJsonFileCount)
{
/// <summary>Absolute path to the directory that was enumerated for <c>*_npc_behaviors.json</c> catalogs.</summary>
public string NpcBehaviorsDirectory { get; } = npcBehaviorsDirectory;
public IReadOnlyDictionary<string, NpcBehaviorDefRow> ById { get; } =
new ReadOnlyDictionary<string, NpcBehaviorDefRow>(new Dictionary<string, NpcBehaviorDefRow>(byId, StringComparer.Ordinal));
public int DistinctBehaviorCount => ById.Count;
/// <summary>Number of <c>*_npc_behaviors.json</c> files under <see cref="NpcBehaviorsDirectory"/>.</summary>
public int CatalogJsonFileCount { get; } = catalogJsonFileCount;
/// <summary>Resolves a catalog row by stable behavior <paramref name="id"/>.</summary>
public bool TryGetBehavior(string id, out NpcBehaviorDefRow? row) =>
ById.TryGetValue(id, out row);
}