diff --git a/Content.Server/Lathe/LatheSystem.cs b/Content.Server/Lathe/LatheSystem.cs index 9e06dca52b..8b1f3b471c 100644 --- a/Content.Server/Lathe/LatheSystem.cs +++ b/Content.Server/Lathe/LatheSystem.cs @@ -107,7 +107,7 @@ namespace Content.Server.Lathe if (args.Storage != uid) return; var materialWhitelist = new List>(); - var recipes = GetAllBaseRecipes(component); + var recipes = GetAvailableRecipes(uid, component, true); foreach (var id in recipes) { if (!_proto.TryIndex(id, out var proto)) @@ -126,18 +126,18 @@ namespace Content.Server.Lathe } [PublicAPI] - public bool TryGetAvailableRecipes(EntityUid uid, [NotNullWhen(true)] out List>? recipes, [NotNullWhen(true)] LatheComponent? component = null) + public bool TryGetAvailableRecipes(EntityUid uid, [NotNullWhen(true)] out List>? 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> GetAvailableRecipes(EntityUid uid, LatheComponent component) + public List> GetAvailableRecipes(EntityUid uid, LatheComponent component, bool getUnavailable = false) { - var ev = new LatheGetRecipesEvent(uid) + var ev = new LatheGetRecipesEvent(uid, getUnavailable) { Recipes = new List>(component.StaticRecipes) }; @@ -236,7 +236,7 @@ namespace Content.Server.Lathe 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); } @@ -246,11 +246,11 @@ namespace Content.Server.Lathe { if (uid != args.Lathe || !TryComp(uid, out var technologyDatabase)) return; - if (!HasComp(uid)) + if (!args.getUnavailable && !HasComp(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); } diff --git a/Content.Shared/Lathe/EmagLatheComponent.cs b/Content.Shared/Lathe/EmagLatheComponent.cs index 02a04b2024..9fe53c8d49 100644 --- a/Content.Shared/Lathe/EmagLatheComponent.cs +++ b/Content.Shared/Lathe/EmagLatheComponent.cs @@ -1,25 +1,23 @@ 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 { /// /// All of the dynamic recipes that the lathe is capable to get using EMAG /// - [DataField("emagDynamicRecipes", customTypeSerializer: typeof(PrototypeIdListSerializer))] - [AutoNetworkedField] - public List EmagDynamicRecipes = new(); + [DataField, AutoNetworkedField] + public List> EmagDynamicRecipes = new(); /// /// All of the static recipes that the lathe is capable to get using EMAG /// - [DataField("emagStaticRecipes", customTypeSerializer: typeof(PrototypeIdListSerializer))] - [AutoNetworkedField] - public List EmagStaticRecipes = new(); + [DataField, AutoNetworkedField] + public List> EmagStaticRecipes = new(); } } diff --git a/Content.Shared/Lathe/LatheComponent.cs b/Content.Shared/Lathe/LatheComponent.cs index 6bbdb61a42..e1110777dc 100644 --- a/Content.Shared/Lathe/LatheComponent.cs +++ b/Content.Shared/Lathe/LatheComponent.cs @@ -68,11 +68,14 @@ namespace Content.Shared.Lathe { public readonly EntityUid Lathe; + public bool getUnavailable; + public List> Recipes = new(); - public LatheGetRecipesEvent(EntityUid lathe) + public LatheGetRecipesEvent(EntityUid lathe, bool forced) { Lathe = lathe; + getUnavailable = forced; } }