Skip to content

Commit

Permalink
Update ReagentDispenserSystem.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Vonsant authored Dec 19, 2024
1 parent c3d6401 commit 5e9ac91
Showing 1 changed file with 46 additions and 46 deletions.
92 changes: 46 additions & 46 deletions Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,59 +66,59 @@ private void SubscribeUpdateUiState<T>(Entity<ReagentDispenserComponent> ent, re
}

// Corvax-Next-Labeler-Start
private void OnEntInserted(Entity<ReagentDispenserComponent> ent, ref EntInsertedIntoContainerMessage ev)
private void OnEntInserted(Entity<ReagentDispenserComponent> 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<ReagentPrototype>(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<ReagentPrototype>(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<ReagentDispenserComponent> ent, ref GetVerbsEvent<AlternativeVerb> 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<ReagentDispenserComponent> ent, bool autoLabel)
{
if (!ent.Comp.CanAutoLabel)
return;
private void OnAlternateVerb(Entity<ReagentDispenserComponent> ent, ref GetVerbsEvent<AlternativeVerb> 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<ReagentDispenserComponent> ent, ref ExaminedEvent args)
{
if (!args.IsInDetailsRange || !ent.Comp.CanAutoLabel)
return;
private void SetAutoLabel(Entity<ReagentDispenserComponent> 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<ReagentDispenserComponent> 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<ReagentDispenserComponent> reagentDispenser)
{
Expand Down

0 comments on commit 5e9ac91

Please sign in to comment.