Emags (#6738)
This commit is contained in:
@@ -25,6 +25,7 @@ using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Chemistry.Components
|
||||
{
|
||||
@@ -45,7 +46,11 @@ namespace Content.Server.Chemistry.Components
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
[ViewVariables] [DataField("pack")] private string _packPrototypeId = "";
|
||||
[ViewVariables] [DataField("pack", customTypeSerializer:typeof(PrototypeIdSerializer<ReagentDispenserInventoryPrototype>))] private string _packPrototypeId = "";
|
||||
|
||||
[ViewVariables] [DataField("emagPack", customTypeSerializer:typeof(PrototypeIdSerializer<ReagentDispenserInventoryPrototype>))] public string EmagPackPrototypeId = "";
|
||||
|
||||
public bool AlreadyEmagged = false;
|
||||
|
||||
[DataField("clickSound")]
|
||||
private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
|
||||
@@ -119,6 +124,24 @@ namespace Content.Server.Chemistry.Components
|
||||
Inventory.Sort(_comparer);
|
||||
}
|
||||
|
||||
public void AddFromPrototype(string pack)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pack)) return;
|
||||
|
||||
if (!_prototypeManager.TryIndex(pack, out ReagentDispenserInventoryPrototype? packPrototype))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var entry in packPrototype.Inventory)
|
||||
{
|
||||
Inventory.Add(new ReagentDispenserInventoryEntry(entry));
|
||||
}
|
||||
|
||||
Inventory.Sort(_comparer);
|
||||
}
|
||||
|
||||
|
||||
private void OnPowerChanged(PowerChangedMessage e)
|
||||
{
|
||||
UpdateUserInterface();
|
||||
|
||||
Reference in New Issue
Block a user