Allow solutions to store extra reagent data (#19323)

This commit is contained in:
Leon Friedrich
2023-09-05 09:55:10 +12:00
committed by GitHub
parent a6b81058d0
commit e4ca6f4fb9
52 changed files with 932 additions and 538 deletions

View File

@@ -3,6 +3,7 @@ using Content.Server.Administration.Logs;
using Content.Server.Chemistry.Components;
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Dispenser;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Database;
using Content.Shared.Emag.Components;
@@ -63,28 +64,30 @@ namespace Content.Server.Chemistry.EntitySystems
if (_solutionContainerSystem.TryGetFitsInDispenser(container.Value, out var solution))
{
var reagents = solution.Contents.Select(reagent => (reagent.ReagentId, reagent.Quantity)).ToList();
return new ContainerInfo(Name(container.Value), true, solution.Volume, solution.MaxVolume, reagents);
return new ContainerInfo(Name(container.Value), solution.Volume, solution.MaxVolume)
{
Reagents = solution.Contents
};
}
return null;
}
private List<string> GetInventory(ReagentDispenserComponent reagentDispenser)
private List<ReagentId> GetInventory(ReagentDispenserComponent reagentDispenser)
{
var inventory = new List<string>();
var inventory = new List<ReagentId>();
if (reagentDispenser.PackPrototypeId is not null
&& _prototypeManager.TryIndex(reagentDispenser.PackPrototypeId, out ReagentDispenserInventoryPrototype? packPrototype))
{
inventory.AddRange(packPrototype.Inventory);
inventory.AddRange(packPrototype.Inventory.Select(x => new ReagentId(x, null)));
}
if (HasComp<EmaggedComponent>(reagentDispenser.Owner)
&& reagentDispenser.EmagPackPrototypeId is not null
&& _prototypeManager.TryIndex(reagentDispenser.EmagPackPrototypeId, out ReagentDispenserInventoryPrototype? emagPackPrototype))
{
inventory.AddRange(emagPackPrototype.Inventory);
inventory.AddRange(emagPackPrototype.Inventory.Select(x => new ReagentId(x, null)));
}
return inventory;