using System.Collections.Generic;
using System.Linq;
using Cthangover.Core.Factories.Impls;
using Cthangover.Core.Items;
namespace Cthangover.Core.Settings
{
///
/// Tracks which crafting recipes the player has unlocked. Internally
/// a of recipe IDs that provides O(1)
/// lookup. Recipes can be queried by
/// via , which resolves each ID through
/// and
/// filters the resulting objects.
///
public class RecipeData : IRecipeData
{
/// Set of known recipe IDs (duplicate insertion is silently ignored).
public HashSet Data { get; set; } = new();
///
/// Unlocks a recipe by ID. Returns false if the recipe
/// was already known (duplicate).
///
public bool Add(string id)
{
return Data.Add(id);
}
/// true if the recipe with the given ID is already unlocked.
public bool Has(string id)
{
return Data.Contains(id);
}
///
/// Returns all known recipes that belong to the specified
/// . Each ID is resolved via
///
/// and filtered; IDs that resolve to null are silently
/// dropped.
///
public List GetRecipesByType(WorkbenchType type)
{
return Data.Select(o => RecipeFactory.Instance.Get(o))
.Where(o => o.WorkbenchType == type)
.ToList();
}
}
}