var pricing = entManager.System<PricingSystem>();
var stackSys = entManager.System<StackSystem>();
var mapSystem = server.System<SharedMapSystem>();
+ var latheSys = server.System<SharedLatheSystem>();
var compFact = server.ResolveDependency<IComponentFactory>();
Assert.That(mapSystem.IsInitialized(testMap.MapId));
var materialName = compFact.GetComponentName(typeof(MaterialComponent));
var destructibleName = compFact.GetComponentName(typeof(DestructibleComponent));
- // construct inverted lathe recipe dictionary
- Dictionary<string, List<LatheRecipePrototype>> latheRecipes = new();
- foreach (var proto in protoManager.EnumeratePrototypes<LatheRecipePrototype>())
- {
- latheRecipes.GetOrNew(proto.Result).Add(proto);
- }
+ // get the inverted lathe recipe dictionary
+ var latheRecipes = latheSys.InverseRecipes;
// Lets assume the possible lathe for resource multipliers:
// TODO: each recipe can technically have its own cost multiplier associated with it, so this test needs redone to factor that in.
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly SharedMaterialStorageSystem _materialStorage = default!;
- private readonly Dictionary<string, List<LatheRecipePrototype>> _inverseRecipeDictionary = new();
+ public readonly Dictionary<string, List<LatheRecipePrototype>> InverseRecipes = new();
public override void Initialize()
{
private void BuildInverseRecipeDictionary()
{
- _inverseRecipeDictionary.Clear();
+ InverseRecipes.Clear();
foreach (var latheRecipe in _proto.EnumeratePrototypes<LatheRecipePrototype>())
{
- if (latheRecipe.Result == null)
+ if (latheRecipe.Result is not {} result)
continue;
- _inverseRecipeDictionary.GetOrNew(latheRecipe.Result).Add(latheRecipe);
+ InverseRecipes.GetOrNew(result).Add(latheRecipe);
}
}
public bool TryGetRecipesFromEntity(string prototype, [NotNullWhen(true)] out List<LatheRecipePrototype>? recipes)
{
recipes = new();
- if (_inverseRecipeDictionary.TryGetValue(prototype, out var r))
+ if (InverseRecipes.TryGetValue(prototype, out var r))
recipes.AddRange(r);
return recipes.Count != 0;
}
if (!string.IsNullOrWhiteSpace(proto.Name))
return Loc.GetString(proto.Name);
- if (proto.Result is { } result)
+ if (proto.Result is {} result)
{
return _proto.Index(result).Name;
}
if (!string.IsNullOrWhiteSpace(proto.Description))
return Loc.GetString(proto.Description);
- if (proto.Result is { } result)
+ if (proto.Result is {} result)
{
return _proto.Index(result).Description;
}
using Content.Shared.Materials;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
+using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array;
using Robust.Shared.Utility;
namespace Content.Shared.Research.Prototypes
{
[NetSerializable, Serializable, Prototype]
- public sealed partial class LatheRecipePrototype : IPrototype
+ public sealed partial class LatheRecipePrototype : IPrototype, IInheritingPrototype
{
[ViewVariables]
[IdDataField]
public string ID { get; private set; } = default!;
+ /// <inheritdoc/>
+ [ParentDataField(typeof(AbstractPrototypeIdArraySerializer<LatheRecipePrototype>))]
+ public string[]? Parents { get; }
+
+ /// <inheritdoc />
+ [NeverPushInheritance]
+ [AbstractDataField]
+ public bool Abstract { get; }
+
/// <summary>
/// Name displayed in the lathe GUI.
/// </summary>
- PortableGeneratorPacmanMachineCircuitboard
- PortableGeneratorSuperPacmanMachineCircuitboard
- PortableGeneratorJrPacmanMachineCircuitboard
- - WallmountGeneratorElectronics
- - WallmountGeneratorAPUElectronics
- WallmountSubstationElectronics
- PowerCageRechargerCircuitboard
- EmitterCircuitboard
+# Non-stackable part that can have a use outside of machines
- type: latheRecipe
- id: CapacitorStockPart
- result: CapacitorStockPart
+ abstract: true
+ id: BasePartRecipe
category: Parts
+ completetime: 2
+ materials:
+ Steel: 300
+ Plastic: 200
+
+# Stackable part with no function
+- type: latheRecipe
+ abstract: true
+ parent: BasePartRecipe
+ id: BaseStockPartRecipe
completetime: 1
materials:
Steel: 50
Plastic: 50
- type: latheRecipe
+ parent: BaseStockPartRecipe
+ id: CapacitorStockPart
+ result: CapacitorStockPart
+
+- type: latheRecipe
+ parent: BaseStockPartRecipe
id: MatterBinStockPart
result: MatterBinStockPart
- category: Parts
- completetime: 1
- materials:
- Steel: 50
- Plastic: 50
- type: latheRecipe
+ parent: BaseStockPartRecipe
id: MicroManipulatorStockPart
result: MicroManipulatorStockPart
- category: Parts
- completetime: 1
- materials:
- Steel: 50
- Plastic: 50