Skip to content

Commit

Permalink
Microwave recipe types (machine restrictions)
Browse files Browse the repository at this point in the history
  • Loading branch information
whatston3 committed Sep 22, 2024
1 parent 38190b3 commit aa8e1c4
Show file tree
Hide file tree
Showing 13 changed files with 353 additions and 17 deletions.
18 changes: 6 additions & 12 deletions Content.Server/Kitchen/Components/MicrowaveComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
using Robust.Shared.Containers;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Content.Shared.Kitchen; // Frontier
using Robust.Shared.Serialization; // Frontier
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; // Frontier

namespace Content.Server.Kitchen.Components
{
Expand Down Expand Up @@ -118,19 +121,10 @@ public sealed partial class MicrowaveComponent : Component

// Frontier: recipe type
/// <summary>
/// If this microwave can give ids accesses without exploding
/// the types of recipes that this "microwave" can handle.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public MicrowaveRecipeType RecipeType = MicrowaveRecipeType.Microwave;
}

// Frontier: microwave recipe types, to limit certain recipes to certain machines
[Flags]
public enum MicrowaveRecipeType
{
Microwave = 1,
Oven = 2,
Assembler = 4,
[DataField(customTypeSerializer: typeof(FlagSerializer<MicrowaveRecipeTypeFlags>)), ViewVariables(VVAccess.ReadWrite)]
public int ValidRecipeTypes = (int)MicrowaveRecipeType.Microwave;
}

public sealed class BeingMicrowavedEvent : HandledEntityEventArgs
Expand Down
9 changes: 8 additions & 1 deletion Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public override void Initialize()
SubscribeLocalEvent<ActiveMicrowaveComponent, EntRemovedFromContainerMessage>(OnActiveMicrowaveRemove);

SubscribeLocalEvent<ActivelyMicrowavedComponent, OnConstructionTemperatureEvent>(OnConstructionTemp);

SubscribeLocalEvent<MicrowaveComponent, RefreshPartsEvent>(OnRefreshParts); // Frontier
SubscribeLocalEvent<MicrowaveComponent, UpgradeExamineEvent>(OnUpgradeExamine); // Frontier
}
Expand Down Expand Up @@ -639,6 +639,13 @@ public static (FoodRecipePrototype, int) CanSatisfyRecipe(MicrowaveComponent com
return (recipe, 0);
}

// Frontier: microwave recipe machine types
if ((recipe.RecipeType & component.ValidRecipeTypes) == 0)
{
return (recipe, 0);
}
// End Frontier

foreach (var solid in recipe.IngredientsSolids)
{
if (!solids.ContainsKey(solid.Key))
Expand Down
20 changes: 20 additions & 0 deletions Content.Shared/Kitchen/MicrowaveMealRecipePrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Robust.Shared.Serialization; // Frontier

namespace Content.Shared.Kitchen
{
Expand Down Expand Up @@ -36,6 +38,11 @@ public sealed partial class FoodRecipePrototype : IPrototype
[DataField("time")]
public uint CookTime { get; private set; } = 5;

// Frontier: separate microwave recipe types.

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

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

// TODO Turn this into a ReagentQuantity[]
Expand All @@ -58,4 +65,17 @@ public FixedPoint2 IngredientCount()
return n;
}
}

// Frontier: microwave recipe types, to limit certain recipes to certain machines
[Flags, FlagsFor(typeof(MicrowaveRecipeTypeFlags))]
[Serializable, NetSerializable]
public enum MicrowaveRecipeType : int
{
Microwave = 1,
Oven = 2,
Assembler = 4,
MedicalAssembler = 8,
}

public sealed class MicrowaveRecipeTypeFlags { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
solids:
FoodBreadPlain: 1
FoodFlyAmanita: 3
recipeType: # Frontier
- Microwave # Frontier

- type: microwaveMealRecipe
id: RecipeCheeseCurds
name: cheese curds recipe
result: FoodCheeseCurds
time: 5
solids:
FoodCurdCheese: 1
FoodCurdCheese: 1
recipeType: # Frontier
- Oven # Frontier
- Microwave # Frontier
Loading

0 comments on commit aa8e1c4

Please sign in to comment.