neon-sprawl/server/NeonSprawl.Server/Game/Crafting/RecipeDefinitionCatalog.cs

25 lines
1.2 KiB
C#

using System.Collections.ObjectModel;
namespace NeonSprawl.Server.Game.Crafting;
/// <summary>In-memory recipe catalog loaded at startup (NEO-66). NEO-67 adds injectable recipe definition registry for game callers.</summary>
public sealed class RecipeDefinitionCatalog(
string recipesDirectory,
IReadOnlyDictionary<string, RecipeDefRow> byId,
int catalogJsonFileCount)
{
/// <summary>Absolute path to the directory that was enumerated for <c>*_recipes.json</c> catalogs.</summary>
public string RecipesDirectory { get; } = recipesDirectory;
public IReadOnlyDictionary<string, RecipeDefRow> ById { get; } = new ReadOnlyDictionary<string, RecipeDefRow>(new Dictionary<string, RecipeDefRow>(byId, StringComparer.Ordinal));
public int DistinctRecipeCount => ById.Count;
/// <summary>Number of <c>*_recipes.json</c> files under <see cref="RecipesDirectory"/>.</summary>
public int CatalogJsonFileCount { get; } = catalogJsonFileCount;
/// <summary>Resolves a catalog row by stable recipe <paramref name="id"/> (includes embedded I/O rows).</summary>
public bool TryGetRecipe(string id, out RecipeDefRow? row) =>
ById.TryGetValue(id, out row);
}