From fb5c9d689e7fe1be890976a03f4ebd4b63aa38f7 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Thu, 18 Feb 2021 20:58:43 +1100 Subject: [PATCH] Sort reagent dispenser entries (#3272) * Sort reagent dispenser entries Saves manually doing it. * zumzum's suggestion Co-authored-by: Metal Gear Sloth --- .../Chemistry/ReagentDispenserComponent.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs b/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs index 9f78867b43..1a01f740ab 100644 --- a/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs +++ b/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs @@ -1,5 +1,6 @@ #nullable enable using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Content.Server.GameObjects.Components.GUI; @@ -37,6 +38,8 @@ namespace Content.Server.GameObjects.Components.Chemistry [ComponentReference(typeof(IInteractUsing))] public class ReagentDispenserComponent : SharedReagentDispenserComponent, IActivate, IInteractUsing, ISolutionChange { + private static ReagentInventoryComparer _comparer = new(); + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [ViewVariables] private ContainerSlot _beakerContainer = default!; @@ -109,6 +112,8 @@ namespace Content.Server.GameObjects.Components.Chemistry { Inventory.Add(new ReagentDispenserInventoryEntry(entry)); } + + Inventory.Sort(_comparer); } private void OnPowerChanged(PowerChangedMessage e) @@ -375,5 +380,13 @@ namespace Content.Server.GameObjects.Components.Chemistry component.TryEject(user); } } + + private class ReagentInventoryComparer : Comparer + { + public override int Compare(ReagentDispenserInventoryEntry x, ReagentDispenserInventoryEntry y) + { + return string.Compare(x.ID, y.ID, StringComparison.InvariantCultureIgnoreCase); + } + } } }