Files
crystall-punk-14/Content.IntegrationTests/Tests/_CP14/CP14Cooking.cs
Red 8721f736e1 Cooking simulator 3: Pies (#1540)
* enum -> prototype

* move sprites

* more dirt sprites

* some food data stucking fixing

* pumpkin fix

* pie move sprites

* refactor components

* pie refactor

* remove outdated proto

* new pie types

* Update SliceableFoodSystem.cs

* Refactor food cooking system and add fat flavor

Added 'Fat' to the flavor profile. Refactored food cooking logic to use CreateFoodData and UpdateFoodDataVisuals instead of CookFood and ApplyFoodVisuals. Introduced RenameCooker property to CP14FoodCookerComponent to control entity renaming during cooking. Improved separation of food data creation and visual updates.

* Update migration.yml

* Refactor food visual and sliceable logic in cooking system

Moved sliceable food logic from OnCookFinished to UpdateFoodDataVisuals for better encapsulation. Made UpdateFoodDataVisuals overridable and updated its usage in random food initialization. Added Rename field to CP14RandomFoodDataComponent and cleaned up unused BecomeSliceable field in CP14FoodCookerComponent. Updated pie_pan.yml to add SliceableFood and a new random food entity.

* Update pie_pan.yml

* fill levels
2025-07-20 15:45:59 +03:00

78 lines
2.9 KiB
C#

/*
* This file is sublicensed under MIT License
* https://github.com/space-wizards/space-station-14/blob/master/LICENSE.TXT
*/
using System.Collections.Generic;
using System.Linq;
using Content.Shared._CP14.Cooking;
using Content.Shared._CP14.Cooking.Prototypes;
using Content.Shared._CP14.Cooking.Requirements;
using Content.Shared.Chemistry.Components;
using Content.Shared.Tag;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.IntegrationTests.Tests._CP14;
#nullable enable
[TestFixture]
public sealed class CP14Cooking
{
[Test]
public async Task TestAllCookingRecipeIsCookable()
{
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;
var entManager = server.ResolveDependency<IEntityManager>();
var protoMan = server.ResolveDependency<IPrototypeManager>();
var cookSys = entManager.System<CP14SharedCookingSystem>();
await server.WaitAssertion(() =>
{
Assert.Multiple(() =>
{
foreach (var recipe in protoMan.EnumeratePrototypes<CP14CookingRecipePrototype>())
{
var solution = new Solution();
var allTags = new List<ProtoId<TagPrototype>>();
foreach (var req in recipe.Requirements)
{
switch (req)
{
case AlwaysMet:
continue;
case TagRequired tagReq:
allTags.AddRange(tagReq.Tags);
break;
case ReagentRequired reagentReq:
if (reagentReq.Reagents.Count == 0)
continue; // No reagents required, skip this requirement.
solution.AddReagent(reagentReq.Reagents.First(),
reagentReq.Amount);
break;
}
}
var selectedRecipe = cookSys.GetRecipe(recipe.FoodType, solution, allTags);
var complexity = recipe.Requirements.Sum(req => req.GetComplexity());
var selectedRecipeComplexity = selectedRecipe?.Requirements.Sum(req => req.GetComplexity()) ?? 0;
if (selectedRecipe != recipe)
{
Assert.Fail($"The {recipe.ID} recipe is impossible to cook! " +
$"Instead, the following dish was prepared: ${selectedRecipe?.ID ?? "NULL"} " +
$"\nRecipe complexity: {complexity}, selected recipe complexity: {selectedRecipeComplexity}.");
}
}
});
});
await pair.CleanReturnAsync();
}
}