Recipe fix

This commit is contained in:
dingo
2025-12-28 09:01:40 -05:00
parent 0589ecb783
commit f1b2749526
3 changed files with 85 additions and 7 deletions
+11
View File
@@ -29,6 +29,14 @@ public class CraftingHandler
}
public async Task InitializeAsync()
{
await RefreshRecipeCacheAsync();
}
/// <summary>
/// Refresh the recipe cache from database. Call this after recipes are modified in admin.
/// </summary>
public async Task RefreshRecipeCacheAsync()
{
using var scope = _scopeFactory.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<GameDbContext>();
@@ -40,6 +48,9 @@ public class CraftingHandler
_recipes = recipes.ToDictionary(r => r.Id);
// Clear old hash lookup and rebuild
_ingredientHashToRecipeId.Clear();
// Build ingredient hash lookup for recipe discovery
foreach (var recipe in recipes)
{