26 lines
1.2 KiB
C#
26 lines
1.2 KiB
C#
using System.Collections.ObjectModel;
|
|
|
|
namespace NeonSprawl.Server.Game.Encounters;
|
|
|
|
/// <summary>In-memory encounter catalog loaded at startup (NEO-101). Game callers should use <see cref="IEncounterDefinitionRegistry"/> (NEO-102).</summary>
|
|
public sealed class EncounterDefinitionCatalog(
|
|
string encountersDirectory,
|
|
IReadOnlyDictionary<string, EncounterDefRow> byId,
|
|
int catalogJsonFileCount)
|
|
{
|
|
/// <summary>Absolute path to the directory that was enumerated for <c>*_encounters.json</c> catalogs.</summary>
|
|
public string EncountersDirectory { get; } = encountersDirectory;
|
|
|
|
public IReadOnlyDictionary<string, EncounterDefRow> ById { get; } =
|
|
new ReadOnlyDictionary<string, EncounterDefRow>(new Dictionary<string, EncounterDefRow>(byId, StringComparer.Ordinal));
|
|
|
|
public int DistinctEncounterCount => ById.Count;
|
|
|
|
/// <summary>Number of <c>*_encounters.json</c> files under <see cref="EncountersDirectory"/>.</summary>
|
|
public int CatalogJsonFileCount { get; } = catalogJsonFileCount;
|
|
|
|
/// <summary>Resolves a catalog row by stable encounter <paramref name="id"/>.</summary>
|
|
public bool TryGetEncounter(string id, out EncounterDefRow? row) =>
|
|
ById.TryGetValue(id, out row);
|
|
}
|