Machine-code cleanup (#28489)

This commit is contained in:
Nemanja
2024-06-05 16:23:23 -04:00
committed by GitHub
parent 8a7b0f675e
commit 729e67af7f
31 changed files with 350 additions and 979 deletions

View File

@@ -1,54 +1,47 @@
using Content.Shared.Construction.Prototypes;
using Content.Shared.Stacks;
using Content.Shared.Tag;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
namespace Content.Shared.Construction.Components
namespace Content.Shared.Construction.Components;
[RegisterComponent, NetworkedComponent]
public sealed partial class MachineBoardComponent : Component
{
[RegisterComponent, NetworkedComponent]
public sealed partial class MachineBoardComponent : Component
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
/// <summary>
/// The stacks needed to construct this machine
/// </summary>
[DataField]
public Dictionary<ProtoId<StackPrototype>, int> StackRequirements = new();
[DataField("requirements", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<int, MachinePartPrototype>))]
public Dictionary<string, int> Requirements = new();
/// <summary>
/// Entities needed to construct this machine, discriminated by tag.
/// </summary>
[DataField]
public Dictionary<ProtoId<TagPrototype>, GenericPartInfo> TagRequirements = new();
[DataField("materialRequirements")]
public Dictionary<string, int> MaterialIdRequirements = new();
/// <summary>
/// Entities needed to construct this machine, discriminated by component.
/// </summary>
[DataField]
public Dictionary<string, GenericPartInfo> ComponentRequirements = new();
[DataField("tagRequirements")]
public Dictionary<string, GenericPartInfo> TagRequirements = new();
[DataField("componentRequirements")]
public Dictionary<string, GenericPartInfo> ComponentRequirements = new();
[ViewVariables(VVAccess.ReadWrite)]
[DataField("prototype")]
public string? Prototype { get; private set; }
public IEnumerable<KeyValuePair<StackPrototype, int>> MaterialRequirements
{
get
{
foreach (var (materialId, amount) in MaterialIdRequirements)
{
var material = _prototypeManager.Index<StackPrototype>(materialId);
yield return new KeyValuePair<StackPrototype, int>(material, amount);
}
}
}
}
[Serializable]
[DataDefinition]
public partial struct GenericPartInfo
{
[DataField("Amount")]
public int Amount;
[DataField("ExamineName")]
public string ExamineName;
[DataField("DefaultPrototype")]
public string DefaultPrototype;
}
/// <summary>
/// The machine that's constructed when this machine board is completed.
/// </summary>
[DataField(required: true)]
public EntProtoId Prototype;
}
[DataDefinition, Serializable]
public partial struct GenericPartInfo
{
[DataField(required: true)]
public int Amount;
[DataField(required: true)]
public EntProtoId DefaultPrototype;
[DataField]
public LocId? ExamineName;
}