Skip to content

Commit

Permalink
minor refactor (#2951)
Browse files Browse the repository at this point in the history
  • Loading branch information
whatston3 authored Feb 21, 2025
1 parent fd731e6 commit 5c9d7a2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public void ReloadRecipes()
// Recipes
foreach (var recipe in _protoMan.EnumeratePrototypes<FoodRecipePrototype>())
{
if (recipe.HideInGuidebook) // Frontier
continue; // Frontier

_sources.GetOrNew(recipe.Result).Add(new FoodRecipeData(recipe)); // Frontier: _sources<_recipes
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ private void OnPrototypesReloaded(PrototypesReloadedEventArgs args)

public void ReloadRecipes()
{
// TODO: add this code to the list of known recipes because this is spaghetti
_sources.Clear();

// Recipes
foreach (var recipe in _protoMan.EnumeratePrototypes<FoodRecipePrototype>())
{
if (recipe.HideInGuidebook)
continue;

MicrowaveRecipeType recipeType = (MicrowaveRecipeType)recipe.RecipeType;
if (recipeType.HasFlag(MicrowaveRecipeType.MedicalAssembler))
{
Expand All @@ -60,7 +62,7 @@ public void ReloadRecipes()
{
var proto = _protoMan.Index<EntityPrototype>(result);
ReagentQuantity[] reagents = [];
// Hack: assume
// Hack: assume there is only one solution in the result
if (proto.TryGetComponent<SolutionContainerManagerComponent>(out var manager, _componentFactory))
reagents = manager?.Solutions?.FirstOrNull()?.Value?.Contents?.ToArray() ?? [];

Expand Down
7 changes: 5 additions & 2 deletions Content.Shared/Kitchen/MicrowaveMealRecipePrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public sealed partial class FoodRecipePrototype : IPrototype
public string Result { get; private set; } = string.Empty;

// Frontier
[DataField("resultCount")]
[DataField]
public int ResultCount { get; private set; } = 1;
// End Frontier

Expand All @@ -40,9 +40,12 @@ public sealed partial class FoodRecipePrototype : IPrototype

// Frontier: separate microwave recipe types.

[DataField("recipeType", customTypeSerializer: typeof(FlagSerializer<MicrowaveRecipeTypeFlags>))]
[DataField(customTypeSerializer: typeof(FlagSerializer<MicrowaveRecipeTypeFlags>))]
public int RecipeType = (int)MicrowaveRecipeType.Microwave;

[DataField]
public bool HideInGuidebook;

public string Name => Loc.GetString(_name);

// TODO Turn this into a ReagentQuantity[]
Expand Down
5 changes: 5 additions & 0 deletions Resources/Prototypes/_NF/Recipes/Cooking/medical_recipes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
LeftFootHuman: 1
RightFootHuman: 1
recipeType: MedicalAssembler
hideInGuidebook: true

- type: microwaveMealRecipe
id: NFRecipeBuildABuddyGoblin
Expand All @@ -220,6 +221,7 @@
LeftFootGoblin: 1
RightFootGoblin: 1
recipeType: MedicalAssembler
hideInGuidebook: true

- type: microwaveMealRecipe
id: NFRecipeBuildABuddyReptilian
Expand All @@ -238,6 +240,7 @@
LeftFootReptilian: 1
RightFootReptilian: 1
recipeType: MedicalAssembler
hideInGuidebook: true

- type: microwaveMealRecipe
id: NFRecipeBuildABuddySlime
Expand All @@ -256,6 +259,7 @@
LeftFootSlime: 1
RightFootSlime: 1
recipeType: MedicalAssembler
hideInGuidebook: true

- type: microwaveMealRecipe
id: NFRecipeBuildABuddyVulpkanin
Expand All @@ -274,3 +278,4 @@
LeftFootVulpkanin: 1
RightFootVulpkanin: 1
recipeType: MedicalAssembler
hideInGuidebook: true

0 comments on commit 5c9d7a2

Please sign in to comment.