move lathe recipes into packs (easier for forks and maintaining) (#33095)

* add LatheRecipePackPrototype

* change Lathe and EmagLathe to use packs

* add AddRecipesFromPacks helper to SharedLatheSystem

* update lathe logic to work with packs and clean up some stuff

* migrate individual recipes to recipe packs

* update client

* remove node/artifact scanner from techs

* :trollface:

* fix test and make it include emag recipes

* add test that every dynamic recipe must be researched

* pro

* fix

* fix

* fix all tests, genuinely good test i wonder who made it

* add unused uranium and incendiary drozd mags to tech and lathe

* add recipes

* add incendiary prototype

* undo some changes

* troll

* :trollface:

* true

Co-authored-by: pathetic meowmeow <uhhadd@gmail.com>

* shitmed real

Co-authored-by: pathetic meowmeow <uhhadd@gmail.com>

* update funny test

* :trollface:

* :trollface:

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
Co-authored-by: pathetic meowmeow <uhhadd@gmail.com>
This commit is contained in:
deltanedas
2025-02-07 18:22:49 +00:00
committed by GitHub
parent f37d5c9f0f
commit 1f5fab5761
28 changed files with 1304 additions and 875 deletions

View File

@@ -52,13 +52,16 @@ public sealed class ResearchTest
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;
var entMan = server.ResolveDependency<IEntityManager>();
var protoManager = server.ResolveDependency<IPrototypeManager>();
var compFact = server.ResolveDependency<IComponentFactory>();
var latheSys = entMan.System<SharedLatheSystem>();
await server.WaitAssertion(() =>
{
var allEnts = protoManager.EnumeratePrototypes<EntityPrototype>();
var allLathes = new HashSet<LatheComponent>();
var latheTechs = new HashSet<ProtoId<LatheRecipePrototype>>();
foreach (var proto in allEnts)
{
if (proto.Abstract)
@@ -69,30 +72,31 @@ public sealed class ResearchTest
if (!proto.TryGetComponent<LatheComponent>(out var lathe, compFact))
continue;
allLathes.Add(lathe);
}
var latheTechs = new HashSet<string>();
foreach (var lathe in allLathes)
{
if (lathe.DynamicRecipes == null)
continue;
latheSys.AddRecipesFromPacks(latheTechs, lathe.DynamicPacks);
foreach (var recipe in lathe.DynamicRecipes)
{
latheTechs.Add(recipe);
}
if (proto.TryGetComponent<EmagLatheRecipesComponent>(out var emag, compFact))
latheSys.AddRecipesFromPacks(latheTechs, emag.EmagDynamicPacks);
}
Assert.Multiple(() =>
{
// check that every recipe a tech adds can be made on some lathe
var unlockedTechs = new HashSet<ProtoId<LatheRecipePrototype>>();
foreach (var tech in protoManager.EnumeratePrototypes<TechnologyPrototype>())
{
unlockedTechs.UnionWith(tech.RecipeUnlocks);
foreach (var recipe in tech.RecipeUnlocks)
{
Assert.That(latheTechs, Does.Contain(recipe), $"Recipe \"{recipe}\" cannot be unlocked on any lathes.");
Assert.That(latheTechs, Does.Contain(recipe), $"Recipe '{recipe}' from tech '{tech.ID}' cannot be unlocked on any lathes.");
}
}
// now check that every dynamic recipe a lathe lists can be unlocked
foreach (var recipe in latheTechs)
{
Assert.That(unlockedTechs, Does.Contain(recipe), $"Recipe '{recipe}' is dynamic on a lathe but cannot be unlocked by research.");
}
});
});