Skip to content

Commit a9c6e2b

Browse files
bynddark8Rinary1
andauthored
Adds dough to the cookbook + Functionality for listing chemical reactions as recipes. (#5354)
## Short description <!-- What do you propose to change with your PR? --> Adds recipes for various doughs to the guidebook. Creates the `guidebookGroups` method which allows for any chemical reaction to be formatted as a guidebook entry in the same style of every other food recipe. ## Why we need to add this <!-- What is the reason for adding these changes? Please post links to Discussions as well as Bug Reports here. Please describe how this will change the game balance. --> Extremely confusing for new players, suggested a number of times on discord (which you can find [here](https://discord.com/channels/1272545509562777621/1445184954098258034),[ here](https://discord.com/channels/1272545509562777621/1530129438094921808), and [here.](https://discord.com/channels/1272545509562777621/1501260930791641138)) The cookbook previously couldn't recognize any recipes that don't use a microwave, oven, stove, or deep fryer. This is necessary guidance for new players and a crucial part of cooking practically any dish. This aligns with the general philosophy of providing all necessary information by means accessible within the game, and avoids players having to turn to external websites or wikis to get simple recipes. If new dough/cooking chemical reactions are added in the future this works the same way as all the actual food recipes. Just tag the reaction using `guidebookGroups`. Documenting how to make things like condiments purely through chemical reactions is something that's made possible in this PR, and should probably be added to the guidebook but I'll save that for another day. ## Media (Video/Screenshots) <!-- If your PR contains in-game changes you must provide screenshots/videos of the changes. --> <img width="889" height="705" alt="image" src="https://github.com/user-attachments/assets/b41a25a1-44e9-40bb-83cd-0b9d54833369" /> fig 1. yup that's all it does. ## Checks <!-- check boxes for faster reviewing of your PR --> - [x] I do not require assistance to complete the PR. - [x] Before posting/requesting review of a PR, I have verified that the changes work. - [x] I have added screenshots/videos of the changes, or this PR does not change in-game mechanics. - [x] I affirm that my changes are licensed under the [MIT License](https://github.com/ss14Starlight/space-station-14/blob/Starlight/LICENSE.TXT) and grant permission for use in this repository under its conditions. **Changelog** <!-- If you want the players to know about changes made in this PR, specify them using the template outside the comment. Short and informative. --> :cl: bynddark8, Rinary1 - add: Introduces recipes for doughs and cake batter to the in game guidebook. - add: Introduces a method to document chemical reactions in the guidebook as cooking recipes. --------- Co-authored-by: Rinary <rinary.super@gmail.com>
1 parent a6a43ec commit a9c6e2b

11 files changed

Lines changed: 187 additions & 1 deletion

File tree

Content.Client/Guidebook/Controls/GuideMicrowaveEmbed.xaml.cs

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
using Content.Client.Guidebook.Richtext;
44
using Content.Client.Message;
55
using Content.Client.UserInterface.ControlExtensions;
6+
using Content.Shared.Chemistry.Reaction;
67
using Content.Shared.Chemistry.Reagent;
8+
using Content.Shared.EntityEffects.Effects.EntitySpawning;
79
using Content.Shared.Kitchen;
810
using JetBrains.Annotations;
911
using Robust.Client.AutoGenerated;
@@ -197,4 +199,107 @@ private void GenerateControl(FoodRecipePrototype recipe)
197199
GenerateCookTime(recipe);
198200
GenerateDeviceType(recipe);
199201
}
202+
203+
#region Starlight
204+
205+
public GuideMicrowaveEmbed(ReactionPrototype reaction) : this() => GenerateControl(reaction);
206+
207+
private void GenerateHeader(ReactionPrototype reaction)
208+
{
209+
if (TryGetPrimaryReactionResultEntity(reaction, out var resultEntity, out var amount))
210+
{
211+
RepresentedPrototype = resultEntity;
212+
IconContainer.AddChild(new GuideEntityEmbed(resultEntity.ID, false, false));
213+
214+
var escapedResultName = FormattedMessage.EscapeText(resultEntity.Name);
215+
ResultName.SetMarkup($"[bold]{escapedResultName}[/bold] x {amount}");
216+
ResultDescription.SetMarkup(FormattedMessage.EscapeText(resultEntity.Description));
217+
return;
218+
}
219+
220+
ResultName.SetMarkup(FormattedMessage.EscapeText(reaction.ID));
221+
ResultDescription.SetMarkup(string.Empty);
222+
}
223+
224+
private bool TryGetPrimaryReactionResultEntity(ReactionPrototype reaction, out EntityPrototype resultEntity, out int amount)
225+
{
226+
foreach (var effect in reaction.Effects)
227+
{
228+
if (effect is not SpawnEntity spawn)
229+
continue;
230+
231+
resultEntity = _prototype.Index<EntityPrototype>(spawn.Entity);
232+
amount = Math.Max(1, spawn.Number);
233+
return true;
234+
}
235+
236+
resultEntity = default!;
237+
amount = 0;
238+
return false;
239+
}
240+
241+
private void GenerateReactionIngredients(ReactionPrototype reaction)
242+
{
243+
foreach (var (reagentId, reactant) in reaction.Reactants.OrderByDescending(p => p.Value.Amount))
244+
{
245+
var reagent = _prototype.Index<ReagentPrototype>(reagentId);
246+
247+
var liquidColorMsg = new FormattedMessage();
248+
liquidColorMsg.AddMarkupOrThrow(Loc.GetString("guidebook-microwave-reagent-color-display", ("color", reagent.SubstanceColor)));
249+
liquidColorMsg.Pop();
250+
251+
var liquidColorLabel = new GuidebookRichPrototypeLink();
252+
liquidColorLabel.SetMessage(liquidColorMsg);
253+
liquidColorLabel.HorizontalAlignment = Control.HAlignment.Center;
254+
liquidColorLabel.LinkedPrototype = reagent;
255+
IngredientsGrid.AddChild(liquidColorLabel);
256+
257+
var liquidNameMsg = new FormattedMessage();
258+
liquidNameMsg.AddMarkupOrThrow("[bold]");
259+
liquidNameMsg.AddText(reagent.LocalizedName);
260+
liquidNameMsg.AddMarkupOrThrow("[/bold]");
261+
if (reactant.Catalyst)
262+
{
263+
liquidNameMsg.AddText(" ");
264+
liquidNameMsg.AddText(Loc.GetString("guidebook-microwave-reagent-catalyst-label"));
265+
}
266+
267+
var liquidNameLabel = new RichTextLabel();
268+
liquidNameLabel.SetMessage(liquidNameMsg);
269+
IngredientsGrid.AddChild(liquidNameLabel);
270+
271+
var liquidQuantityMsg = new FormattedMessage();
272+
liquidQuantityMsg.AddMarkupOrThrow(Loc.GetString("guidebook-microwave-reagent-quantity-display", ("amount", reactant.Amount)));
273+
liquidQuantityMsg.Pop();
274+
275+
var liquidQuantityLabel = new RichTextLabel();
276+
liquidQuantityLabel.SetMessage(liquidQuantityMsg);
277+
IngredientsGrid.AddChild(liquidQuantityLabel);
278+
}
279+
}
280+
281+
private void GenerateReactionCookTime()
282+
{
283+
var msg = new FormattedMessage();
284+
msg.AddMarkupOrThrow(Loc.GetString("guidebook-microwave-cook-time", ("time", 0)));
285+
msg.Pop();
286+
CookTimeLabel.SetMessage(msg);
287+
}
288+
289+
private void GenerateReactionDeviceType()
290+
{
291+
var msg = new FormattedMessage();
292+
msg.AddMarkupOrThrow(Loc.GetString("guidebook-microwave-device-type", ("type", "Chemistry")));
293+
msg.Pop();
294+
DeviceTypeLabel.SetMessage(msg);
295+
}
296+
297+
private void GenerateControl(ReactionPrototype reaction)
298+
{
299+
GenerateHeader(reaction);
300+
GenerateReactionIngredients(reaction);
301+
GenerateReactionCookTime();
302+
GenerateReactionDeviceType();
303+
}
304+
#endregion
200305
}

Content.Client/Guidebook/Controls/GuideMicrowaveGroupEmbed.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Diagnostics.CodeAnalysis;
22
using System.Linq;
33
using Content.Client.Guidebook.Richtext;
4+
using Content.Shared.Chemistry.Reaction;
45
using Content.Shared.Kitchen;
56
using JetBrains.Annotations;
67
using Robust.Client.UserInterface.Controls;
@@ -59,5 +60,16 @@ private void CreateEntries(string group)
5960
var embed = new GuideMicrowaveEmbed(recipe);
6061
AddChild(embed);
6162
}
62-
}
63+
//startlight start
64+
65+
var reactions = _prototype.EnumeratePrototypes<ReactionPrototype>()
66+
.Where(r => r.InGuidebookGroup(group))
67+
.OrderBy(r => r.ID);
68+
69+
foreach (var reaction in reactions)
70+
{
71+
AddChild(new GuideMicrowaveEmbed(reaction));
72+
}
73+
// starlight end
74+
}
6375
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Robust.Shared.Serialization;
2+
3+
// ReSharper disable once CheckNamespace
4+
namespace Content.Shared.Chemistry.Reaction;
5+
6+
public sealed partial class ReactionPrototype
7+
{
8+
[DataField]
9+
public string? GuidebookGroup;
10+
11+
[DataField]
12+
public List<string> GuidebookGroups = [];
13+
14+
public bool InGuidebookGroup(string group)
15+
{
16+
if (string.Equals(GuidebookGroup, group, StringComparison.OrdinalIgnoreCase))
17+
return true;
18+
19+
foreach (var guidebookGroup in GuidebookGroups)
20+
{
21+
if (string.Equals(guidebookGroup, group, StringComparison.OrdinalIgnoreCase))
22+
return true;
23+
}
24+
25+
return false;
26+
}
27+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
guidebook-microwave-reagent-catalyst-label = (catalyst)

Resources/Locale/en-US/_Starlight/guidebook/guides.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ guide-entry-terror-spiders = Terror Spiders
169169
guide-entry-devil = Devil
170170
171171
guide-entry-sl-deepfried-recipes = Deep Fried
172+
guide-entry-sl-dough-recipes = Dough
172173
guide-entry-sl-ice-cream-recipes = Ice Cream Maker
173174
174175
# Plumbing guides

Resources/Prototypes/Guidebook/references.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- PizzaRecipes
2626
- SavoryRecipes
2727
- BreadRecipes
28+
- DoughRecipes # Starlight-edit
2829
- BreakfastRecipes
2930
- MothRecipes
3031
- PastaRecipes

Resources/Prototypes/Recipes/Reactions/food.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
- type: reaction
3232
id: CreateDough
33+
guidebookGroups: # Starlight-edit
34+
- Dough
3335
impact: Low
3436
quantized: true
3537
conserveEnergy: false
@@ -44,6 +46,8 @@
4446

4547
- type: reaction
4648
id: CreateCornmealDough
49+
guidebookGroups: # Starlight-edit
50+
- Dough
4751
impact: Low
4852
quantized: true
4953
conserveEnergy: false
@@ -60,6 +64,8 @@
6064

6165
- type: reaction
6266
id: CreateTortillaDough
67+
guidebookGroups: # Starlight-edit
68+
- Dough
6369
impact: Low
6470
quantized: true
6571
conserveEnergy: false
@@ -74,6 +80,9 @@
7480

7581
- type: reaction
7682
id: CreateDoughCotton
83+
guidebookGroups: # Starlight-edit
84+
- Dough
85+
- Moth
7786
impact: Low
7887
quantized: true
7988
conserveEnergy: false
@@ -90,6 +99,9 @@
9099

91100
- type: reaction
92101
id: CreateCakeBatter
102+
guidebookGroups: # Starlight-edit
103+
- Dough
104+
- Cake
93105
impact: Low
94106
quantized: true
95107
conserveEnergy: false
@@ -123,6 +135,9 @@
123135

124136
- type: reaction
125137
id: CreatePieDough
138+
guidebookGroups: # Starlight-edit
139+
- Dough
140+
- Pie
126141
impact: Low
127142
quantized: true
128143
conserveEnergy: false

Resources/Prototypes/_Starlight/Guidebook/references.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@
99
name: guide-entry-sl-ice-cream-recipes
1010
text: "/ServerInfo/_Starlight/Guidebook/Service/IceCreamMakerRecipes.xml"
1111
filterEnabled: True
12+
13+
- type: guideEntry
14+
id: DoughRecipes # Starlight-add
15+
name: guide-entry-sl-dough-recipes
16+
text: "/ServerInfo/_Starlight/Guidebook/Service/DoughRecipes.xml"
17+
filterEnabled: True

Resources/Prototypes/_Starlight/Recipes/reactions.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
- type: reaction
22
id: CreateMothBatter
3+
# Starlight-start
4+
guidebookGroups:
5+
- Dough
6+
- Moth
7+
- Cake
8+
# Starlight-end
39
impact: Low
410
quantized: true
511
conserveEnergy: false

Resources/ServerInfo/Guidebook/Service/FoodRecipes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ This is the latest published version of NanoTrasen Central Command Kitchen de Cu
4141
<GuideMicrowaveGroupEmbed Group="Salad"/>
4242

4343
<!-- Starlight start -->
44+
## Dough
45+
<GuideMicrowaveGroupEmbed Group="Dough"/>
46+
4447
## Deep Fried
4548
<GuideDeepFryerGroupEmbed Group="TP14-Deep-Fry"/>
4649

0 commit comments

Comments
 (0)