diff --git a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs index 0067cb40c4d..858f0b8aa33 100644 --- a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs @@ -66,59 +66,59 @@ private void SubscribeUpdateUiState(Entity ent, re } // Corvax-Next-Labeler-Start - private void OnEntInserted(Entity ent, ref EntInsertedIntoContainerMessage ev) + private void OnEntInserted(Entity ent, ref EntInsertedIntoContainerMessage ev) + { + if (ent.Comp.AutoLabel && _solutionContainerSystem.TryGetDrainableSolution(ev.Entity, out _, out var sol)) + { + ReagentId? reagentId = sol.GetPrimaryReagentId(); + if (reagentId is not null && _prototypeManager.TryIndex(reagentId.Value.Prototype, out var reagent)) { - if (ent.Comp.AutoLabel && _solutionContainerSystem.TryGetDrainableSolution(ev.Entity, out _, out var sol)) - { - ReagentId? reagentId = sol.GetPrimaryReagentId(); - if (reagentId is not null && _prototypeManager.TryIndex(reagentId.Value.Prototype, out var reagent)) - { - var reagentQuantity = sol.GetReagentQuantity(reagentId.Value); - var totalQuantity = sol.Volume; - if (reagentQuantity == totalQuantity) - _label.Label(ev.Entity, reagent.LocalizedName); - else - _label.Label(ev.Entity, Loc.GetString("reagent-dispenser-component-impure-auto-label", ("reagent", reagent.LocalizedName), ("purity", 100.0f * reagentQuantity / totalQuantity))); - } - } - - UpdateUiState(ent); + var reagentQuantity = sol.GetReagentQuantity(reagentId.Value); + var totalQuantity = sol.Volume; + if (reagentQuantity == totalQuantity) + _label.Label(ev.Entity, reagent.LocalizedName); + else + _label.Label(ev.Entity, Loc.GetString("reagent-dispenser-component-impure-auto-label", ("reagent", reagent.LocalizedName), ("purity", 100.0f * reagentQuantity / totalQuantity))); } + } - private void OnAlternateVerb(Entity ent, ref GetVerbsEvent args) - { - if (!ent.Comp.CanAutoLabel) - return; - - args.Verbs.Add(new AlternativeVerb() - { - Act = () => SetAutoLabel(ent, !ent.Comp.AutoLabel), - Text = ent.Comp.AutoLabel ? - Loc.GetString("reagent-dispenser-component-set-auto-label-off-verb") - : Loc.GetString("reagent-dispenser-component-set-auto-label-on-verb"), - Priority = -1, //Not important, low priority. - }); - } + UpdateUiState(ent); + } - private void SetAutoLabel(Entity ent, bool autoLabel) - { - if (!ent.Comp.CanAutoLabel) - return; + private void OnAlternateVerb(Entity ent, ref GetVerbsEvent args) + { + if (!ent.Comp.CanAutoLabel) + return; - ent.Comp.AutoLabel = autoLabel; - } + args.Verbs.Add(new AlternativeVerb() + { + Act = () => SetAutoLabel(ent, !ent.Comp.AutoLabel), + Text = ent.Comp.AutoLabel ? + Loc.GetString("reagent-dispenser-component-set-auto-label-off-verb") + : Loc.GetString("reagent-dispenser-component-set-auto-label-on-verb"), + Priority = -1, // Not important, low priority. + }); + } - private void OnExamined(Entity ent, ref ExaminedEvent args) - { - if (!args.IsInDetailsRange || !ent.Comp.CanAutoLabel) - return; + private void SetAutoLabel(Entity ent, bool autoLabel) + { + if (!ent.Comp.CanAutoLabel) + return; - if (ent.Comp.AutoLabel) - args.PushMarkup(Loc.GetString("reagent-dispenser-component-examine-auto-label-on")); - else - args.PushMarkup(Loc.GetString("reagent-dispenser-component-examine-auto-label-off")); - } - // Corvax-Next-Labeler-End + ent.Comp.AutoLabel = autoLabel; + } + + private void OnExamined(Entity ent, ref ExaminedEvent args) + { + if (!args.IsInDetailsRange || !ent.Comp.CanAutoLabel) + return; + + if (ent.Comp.AutoLabel) + args.PushMarkup(Loc.GetString("reagent-dispenser-component-examine-auto-label-on")); + else + args.PushMarkup(Loc.GetString("reagent-dispenser-component-examine-auto-label-off")); + } + // Corvax-Next-Labeler-End private void UpdateUiState(Entity reagentDispenser) {