2022-09-26 16:18:31 -04:00
|
|
|
using Content.Shared.Construction.Prototypes;
|
2021-02-25 06:18:29 +01:00
|
|
|
using Content.Shared.Stacks;
|
2023-01-16 11:53:23 -05:00
|
|
|
using Robust.Shared.GameStates;
|
2021-02-25 06:18:29 +01:00
|
|
|
using Robust.Shared.Prototypes;
|
2022-09-26 16:18:31 -04:00
|
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
|
2020-12-03 22:49:00 +01:00
|
|
|
|
2023-01-16 11:53:23 -05:00
|
|
|
namespace Content.Shared.Construction.Components
|
2020-12-03 22:49:00 +01:00
|
|
|
{
|
2023-01-16 11:53:23 -05:00
|
|
|
[RegisterComponent, NetworkedComponent]
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class MachineBoardComponent : Component
|
2020-12-03 22:49:00 +01:00
|
|
|
{
|
2021-02-25 06:18:29 +01:00
|
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
|
|
|
|
2022-09-26 16:18:31 -04:00
|
|
|
[DataField("requirements", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<int, MachinePartPrototype>))]
|
2023-08-22 18:14:33 -07:00
|
|
|
public Dictionary<string, int> Requirements = new();
|
2020-12-03 22:49:00 +01:00
|
|
|
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("materialRequirements")]
|
2023-08-22 18:14:33 -07:00
|
|
|
public Dictionary<string, int> MaterialIdRequirements = new();
|
2020-12-03 22:49:00 +01:00
|
|
|
|
2021-03-08 05:09:30 +01:00
|
|
|
[DataField("tagRequirements")]
|
2023-08-22 18:14:33 -07:00
|
|
|
public Dictionary<string, GenericPartInfo> TagRequirements = new();
|
2021-03-08 05:09:30 +01:00
|
|
|
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("componentRequirements")]
|
2023-08-22 18:14:33 -07:00
|
|
|
public Dictionary<string, GenericPartInfo> ComponentRequirements = new();
|
2020-12-03 22:49:00 +01:00
|
|
|
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("prototype")]
|
2021-03-16 15:50:20 +01:00
|
|
|
public string? Prototype { get; private set; }
|
2021-02-25 06:18:29 +01:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-03 22:49:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable]
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataDefinition]
|
2023-08-22 18:14:33 -07:00
|
|
|
public partial struct GenericPartInfo
|
2020-12-03 22:49:00 +01:00
|
|
|
{
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("Amount")]
|
2020-12-03 22:49:00 +01:00
|
|
|
public int Amount;
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("ExamineName")]
|
2020-12-03 22:49:00 +01:00
|
|
|
public string ExamineName;
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("DefaultPrototype")]
|
2020-12-03 22:49:00 +01:00
|
|
|
public string DefaultPrototype;
|
|
|
|
|
}
|
|
|
|
|
}
|