Fix egg cooking and make microwave code a little less bad (#35459)
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
using Content.Shared.Kitchen;
|
||||
|
||||
namespace Content.Server.Kitchen.Components;
|
||||
|
||||
/// <summary>
|
||||
@@ -8,4 +6,9 @@ namespace Content.Server.Kitchen.Components;
|
||||
[RegisterComponent]
|
||||
public sealed partial class ActivelyMicrowavedComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The microwave this entity is actively being microwaved by.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public EntityUid? Microwave;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Part;
|
||||
using Content.Shared.Chemistry.Components.SolutionManager;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Chemistry.Reaction;
|
||||
using Content.Shared.Construction.EntitySystems;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Destructible;
|
||||
@@ -101,6 +102,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
SubscribeLocalEvent<ActiveMicrowaveComponent, EntRemovedFromContainerMessage>(OnActiveMicrowaveRemove);
|
||||
|
||||
SubscribeLocalEvent<ActivelyMicrowavedComponent, OnConstructionTemperatureEvent>(OnConstructionTemp);
|
||||
SubscribeLocalEvent<ActivelyMicrowavedComponent, SolutionRelayEvent<ReactionAttemptEvent>>(OnReactionAttempt);
|
||||
|
||||
SubscribeLocalEvent<FoodRecipeProviderComponent, GetSecretRecipesEvent>(OnGetSecretRecipes);
|
||||
}
|
||||
@@ -126,7 +128,8 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
|
||||
private void OnActiveMicrowaveInsert(Entity<ActiveMicrowaveComponent> ent, ref EntInsertedIntoContainerMessage args)
|
||||
{
|
||||
AddComp<ActivelyMicrowavedComponent>(args.Entity);
|
||||
var microwavedComp = AddComp<ActivelyMicrowavedComponent>(args.Entity);
|
||||
microwavedComp.Microwave = ent.Owner;
|
||||
}
|
||||
|
||||
private void OnActiveMicrowaveRemove(Entity<ActiveMicrowaveComponent> ent, ref EntRemovedFromContainerMessage args)
|
||||
@@ -134,10 +137,33 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
EntityManager.RemoveComponentDeferred<ActivelyMicrowavedComponent>(args.Entity);
|
||||
}
|
||||
|
||||
// Stop items from transforming through constructiongraphs while being microwaved.
|
||||
// They might be reserved for a microwave recipe.
|
||||
private void OnConstructionTemp(Entity<ActivelyMicrowavedComponent> ent, ref OnConstructionTemperatureEvent args)
|
||||
{
|
||||
args.Result = HandleResult.False;
|
||||
return;
|
||||
}
|
||||
|
||||
// Stop reagents from reacting if they are currently reserved for a microwave recipe.
|
||||
// For example Egg would cook into EggCooked, causing it to not being removed once we are done microwaving.
|
||||
private void OnReactionAttempt(Entity<ActivelyMicrowavedComponent> ent, ref SolutionRelayEvent<ReactionAttemptEvent> args)
|
||||
{
|
||||
if (!TryComp<ActiveMicrowaveComponent>(ent.Comp.Microwave, out var activeMicrowaveComp))
|
||||
return;
|
||||
|
||||
if (activeMicrowaveComp.PortionedRecipe.Item1 == null) // no recipe selected
|
||||
return;
|
||||
|
||||
var recipeReagents = activeMicrowaveComp.PortionedRecipe.Item1.IngredientsReagents.Keys;
|
||||
|
||||
foreach (var reagent in recipeReagents)
|
||||
{
|
||||
if (args.Event.Reaction.Reactants.ContainsKey(reagent))
|
||||
{
|
||||
args.Event.Cancelled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -176,33 +202,29 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
// this is spaghetti ngl
|
||||
foreach (var item in component.Storage.ContainedEntities)
|
||||
{
|
||||
if (!TryComp<SolutionContainerManagerComponent>(item, out var solMan))
|
||||
// use the same reagents as when we selected the recipe
|
||||
if (!_solutionContainer.TryGetDrainableSolution(item, out var solutionEntity, out var solution))
|
||||
continue;
|
||||
|
||||
// go over every solution
|
||||
foreach (var (_, soln) in _solutionContainer.EnumerateSolutions((item, solMan)))
|
||||
foreach (var (reagent, _) in recipe.IngredientsReagents)
|
||||
{
|
||||
var solution = soln.Comp.Solution;
|
||||
foreach (var (reagent, _) in recipe.IngredientsReagents)
|
||||
// removed everything
|
||||
if (!totalReagentsToRemove.ContainsKey(reagent))
|
||||
continue;
|
||||
|
||||
var quant = solution.GetTotalPrototypeQuantity(reagent);
|
||||
|
||||
if (quant >= totalReagentsToRemove[reagent])
|
||||
{
|
||||
// removed everything
|
||||
if (!totalReagentsToRemove.ContainsKey(reagent))
|
||||
continue;
|
||||
|
||||
var quant = solution.GetTotalPrototypeQuantity(reagent);
|
||||
|
||||
if (quant >= totalReagentsToRemove[reagent])
|
||||
{
|
||||
quant = totalReagentsToRemove[reagent];
|
||||
totalReagentsToRemove.Remove(reagent);
|
||||
}
|
||||
else
|
||||
{
|
||||
totalReagentsToRemove[reagent] -= quant;
|
||||
}
|
||||
|
||||
_solutionContainer.RemoveReagent(soln, reagent, quant);
|
||||
quant = totalReagentsToRemove[reagent];
|
||||
totalReagentsToRemove.Remove(reagent);
|
||||
}
|
||||
else
|
||||
{
|
||||
totalReagentsToRemove[reagent] -= quant;
|
||||
}
|
||||
|
||||
_solutionContainer.RemoveReagent(solutionEntity.Value, reagent, quant);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,7 +563,8 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
continue;
|
||||
}
|
||||
|
||||
AddComp<ActivelyMicrowavedComponent>(item);
|
||||
var microwavedComp = AddComp<ActivelyMicrowavedComponent>(item);
|
||||
microwavedComp.Microwave = uid;
|
||||
|
||||
string? solidID = null;
|
||||
int amountToAdd = 1;
|
||||
@@ -560,33 +583,20 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
}
|
||||
|
||||
if (solidID is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (solidsDict.ContainsKey(solidID))
|
||||
{
|
||||
if (!solidsDict.TryAdd(solidID, amountToAdd))
|
||||
solidsDict[solidID] += amountToAdd;
|
||||
}
|
||||
else
|
||||
{
|
||||
solidsDict.Add(solidID, amountToAdd);
|
||||
}
|
||||
|
||||
if (!TryComp<SolutionContainerManagerComponent>(item, out var solMan))
|
||||
// only use reagents we have access to
|
||||
// you have to break the eggs before we can use them!
|
||||
if (!_solutionContainer.TryGetDrainableSolution(item, out var _, out var solution))
|
||||
continue;
|
||||
|
||||
foreach (var (_, soln) in _solutionContainer.EnumerateSolutions((item, solMan)))
|
||||
foreach (var (reagent, quantity) in solution.Contents)
|
||||
{
|
||||
var solution = soln.Comp.Solution;
|
||||
foreach (var (reagent, quantity) in solution.Contents)
|
||||
{
|
||||
if (reagentDict.ContainsKey(reagent.Prototype))
|
||||
reagentDict[reagent.Prototype] += quantity;
|
||||
else
|
||||
reagentDict.Add(reagent.Prototype, quantity);
|
||||
}
|
||||
if (!reagentDict.TryAdd(reagent.Prototype, quantity))
|
||||
reagentDict[reagent.Prototype] += quantity;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
- Egg
|
||||
- Meat
|
||||
- type: Food
|
||||
trash:
|
||||
trash:
|
||||
- Eggshells
|
||||
- type: Sprite
|
||||
sprite: Objects/Consumable/Food/egg.rsi
|
||||
@@ -61,13 +61,6 @@
|
||||
# all below are for egg cooking/exploding
|
||||
- type: AtmosExposed
|
||||
- type: Temperature
|
||||
currentTemperature: 290
|
||||
- type: InternalTemperature
|
||||
# ~1mm shell and ~1cm of albumen
|
||||
thickness: 0.011
|
||||
area: 0.04
|
||||
# conductivity of egg shell based on a paper from Romanoff and Romanoff (1949)
|
||||
conductivity: 0.456
|
||||
|
||||
# Splat
|
||||
- type: entity
|
||||
@@ -135,6 +128,3 @@
|
||||
- type: Temperature
|
||||
# preserve temperature from the boiling step
|
||||
currentTemperature: 344
|
||||
- type: Construction
|
||||
graph: Egg
|
||||
node: boiled
|
||||
|
||||
@@ -4,12 +4,6 @@
|
||||
start: start
|
||||
graph:
|
||||
- node: start
|
||||
edges:
|
||||
- to: boiled
|
||||
steps:
|
||||
- minTemperature: 344
|
||||
- node: boiled
|
||||
entity: FoodEggBoiled
|
||||
edges:
|
||||
- to: explode
|
||||
completed:
|
||||
@@ -18,6 +12,7 @@
|
||||
types:
|
||||
Blunt: 10
|
||||
steps:
|
||||
# egg explodes some time after the water in it boils and increases pressure, guessing ~110C
|
||||
- minTemperature: 383
|
||||
# egg explodes some time after the water in it boils and increases pressure
|
||||
# high enough so you can still microwave them for 5 seconds safely
|
||||
- minTemperature: 473.15 # 200°C
|
||||
- node: explode
|
||||
|
||||
@@ -262,10 +262,11 @@
|
||||
result: FoodBurgerMcguffin
|
||||
time: 10
|
||||
group: Savory
|
||||
reagents:
|
||||
Egg: 12
|
||||
solids:
|
||||
FoodBreadBun: 1
|
||||
FoodCheeseSlice: 1
|
||||
FoodEgg: 2
|
||||
|
||||
- type: microwaveMealRecipe
|
||||
id: RecipeBurgerMcrib
|
||||
@@ -348,12 +349,12 @@
|
||||
group: Savory
|
||||
reagents:
|
||||
TableSalt: 5
|
||||
Egg: 12
|
||||
solids:
|
||||
FoodBreadBun: 1
|
||||
FoodMeat: 2
|
||||
FoodCheeseSlice: 2
|
||||
FoodTomato: 2
|
||||
FoodEgg: 2
|
||||
|
||||
- type: microwaveMealRecipe
|
||||
id: RecipeTofuBurger
|
||||
|
||||
Reference in New Issue
Block a user