if (args.Storage != uid)
return;
var materialWhitelist = new List<ProtoId<MaterialPrototype>>();
- var recipes = GetAllBaseRecipes(component);
+ var recipes = GetAvailableRecipes(uid, component, true);
foreach (var id in recipes)
{
if (!_proto.TryIndex(id, out var proto))
}
[PublicAPI]
- public bool TryGetAvailableRecipes(EntityUid uid, [NotNullWhen(true)] out List<ProtoId<LatheRecipePrototype>>? recipes, [NotNullWhen(true)] LatheComponent? component = null)
+ public bool TryGetAvailableRecipes(EntityUid uid, [NotNullWhen(true)] out List<ProtoId<LatheRecipePrototype>>? recipes, [NotNullWhen(true)] LatheComponent? component = null, bool getUnavailable = false)
{
recipes = null;
if (!Resolve(uid, ref component))
return false;
- recipes = GetAvailableRecipes(uid, component);
+ recipes = GetAvailableRecipes(uid, component, getUnavailable);
return true;
}
- public List<ProtoId<LatheRecipePrototype>> GetAvailableRecipes(EntityUid uid, LatheComponent component)
+ public List<ProtoId<LatheRecipePrototype>> GetAvailableRecipes(EntityUid uid, LatheComponent component, bool getUnavailable = false)
{
- var ev = new LatheGetRecipesEvent(uid)
+ var ev = new LatheGetRecipesEvent(uid, getUnavailable)
{
Recipes = new List<ProtoId<LatheRecipePrototype>>(component.StaticRecipes)
};
foreach (var recipe in latheComponent.DynamicRecipes)
{
- if (!component.UnlockedRecipes.Contains(recipe) || args.Recipes.Contains(recipe))
+ if (!(args.getUnavailable || component.UnlockedRecipes.Contains(recipe)) || args.Recipes.Contains(recipe))
continue;
args.Recipes.Add(recipe);
}
{
if (uid != args.Lathe || !TryComp<TechnologyDatabaseComponent>(uid, out var technologyDatabase))
return;
- if (!HasComp<EmaggedComponent>(uid))
+ if (!args.getUnavailable && !HasComp<EmaggedComponent>(uid))
return;
foreach (var recipe in component.EmagDynamicRecipes)
{
- if (!technologyDatabase.UnlockedRecipes.Contains(recipe) || args.Recipes.Contains(recipe))
+ if (!(args.getUnavailable || technologyDatabase.UnlockedRecipes.Contains(recipe)) || args.Recipes.Contains(recipe))
continue;
args.Recipes.Add(recipe);
}
using Content.Shared.Research.Prototypes;
using Robust.Shared.GameStates;
+using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
namespace Content.Shared.Lathe
{
- [RegisterComponent, NetworkedComponent]
- [AutoGenerateComponentState]
+ [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class EmagLatheRecipesComponent : Component
{
/// <summary>
/// All of the dynamic recipes that the lathe is capable to get using EMAG
/// </summary>
- [DataField("emagDynamicRecipes", customTypeSerializer: typeof(PrototypeIdListSerializer<LatheRecipePrototype>))]
- [AutoNetworkedField]
- public List<string> EmagDynamicRecipes = new();
+ [DataField, AutoNetworkedField]
+ public List<ProtoId<LatheRecipePrototype>> EmagDynamicRecipes = new();
/// <summary>
/// All of the static recipes that the lathe is capable to get using EMAG
/// </summary>
- [DataField("emagStaticRecipes", customTypeSerializer: typeof(PrototypeIdListSerializer<LatheRecipePrototype>))]
- [AutoNetworkedField]
- public List<string> EmagStaticRecipes = new();
+ [DataField, AutoNetworkedField]
+ public List<ProtoId<LatheRecipePrototype>> EmagStaticRecipes = new();
}
}