Hyposprays Draw from Jugs (#25544)

* Hyposprays Draw from Jugs

* Fix last onlyMobs usage in yml

* Some Suggested Changes

* Remove unnecessary datafield name declarations

* Remove unnecessary dirtying of component

* Same line parentheses

* Added client-side HypospraySystem

* Cache UI values and only updates if values change

* empty line

* Update label

* Label change

* Reimplement ReactionMixerSystem

* Remove DataField from Hypospray Toggle Mode

* Change ToggleMode from enum to Bool OnlyAffectsMobs

* Add DataField required back since it's required for replays...?

* update EligibleEntity and uses of it

* Add user argument back

* Adds newline

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* Guard for dirty entity

* Adds summary tag

---------

Co-authored-by: Plykiya <plykiya@protonmail.com>
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Plykiya
2024-03-29 20:59:16 -07:00
committed by GitHub
parent 3fc02edd4e
commit f192d7901f
16 changed files with 369 additions and 299 deletions

View File

@@ -1,6 +1,8 @@
using Content.Client.Chemistry.Components;
using Content.Client.Message;
using Content.Client.Stylesheets;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.FixedPoint;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing;
@@ -9,34 +11,48 @@ namespace Content.Client.Chemistry.UI;
public sealed class HyposprayStatusControl : Control
{
private readonly HyposprayComponent _parent;
private readonly Entity<HyposprayComponent> _parent;
private readonly RichTextLabel _label;
private readonly SharedSolutionContainerSystem _solutionContainers;
public HyposprayStatusControl(HyposprayComponent parent)
private FixedPoint2 PrevVolume;
private FixedPoint2 PrevMaxVolume;
private bool PrevOnlyAffectsMobs;
public HyposprayStatusControl(Entity<HyposprayComponent> parent, SharedSolutionContainerSystem solutionContainers)
{
_parent = parent;
_label = new RichTextLabel {StyleClasses = {StyleNano.StyleClassItemStatus}};
_solutionContainers = solutionContainers;
_label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } };
AddChild(_label);
Update();
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
if (!_parent.UiUpdateNeeded)
if (!_solutionContainers.TryGetSolution(_parent.Owner, _parent.Comp.SolutionName, out _, out var solution))
return;
Update();
}
public void Update()
{
// only updates the UI if any of the details are different than they previously were
if (PrevVolume == solution.Volume
&& PrevMaxVolume == solution.MaxVolume
&& PrevOnlyAffectsMobs == _parent.Comp.OnlyAffectsMobs)
return;
_parent.UiUpdateNeeded = false;
PrevVolume = solution.Volume;
PrevMaxVolume = solution.MaxVolume;
PrevOnlyAffectsMobs = _parent.Comp.OnlyAffectsMobs;
_label.SetMarkup(Loc.GetString(
"hypospray-volume-text",
("currentVolume", _parent.CurrentVolume),
("totalVolume", _parent.TotalVolume)));
var modeStringLocalized = Loc.GetString(_parent.Comp.OnlyAffectsMobs switch
{
false => "hypospray-all-mode-text",
true => "hypospray-mobs-only-mode-text",
});
_label.SetMarkup(Loc.GetString("hypospray-volume-label",
("currentVolume", solution.Volume),
("totalVolume", solution.MaxVolume),
("modeString", modeStringLocalized)));
}
}