Add ItemStatus for mopping (#13745)

* Add ItemStatus for mopping

Big QOL feature

* a
This commit is contained in:
metalgearsloth
2023-02-11 12:38:45 +11:00
committed by GitHub
parent 95e35b94b5
commit 2c751d5153
6 changed files with 138 additions and 4 deletions

View File

@@ -0,0 +1,20 @@
using Content.Client.Fluids.UI;
using Content.Client.Items;
using Content.Shared.Fluids;
using Robust.Client.UserInterface;
namespace Content.Client.Fluids;
public sealed class MoppingSystem : SharedMoppingSystem
{
public override void Initialize()
{
base.Initialize();
Subs.ItemStatus<AbsorbentComponent>(GetAbsorbent);
}
private Control GetAbsorbent(EntityUid arg)
{
return new AbsorbentItemStatus(arg, EntityManager);
}
}

View File

@@ -0,0 +1,13 @@
<Control xmlns="https://spacestation14.io">
<BoxContainer Orientation="Horizontal">
<ProgressBar
HorizontalExpand="True"
Name="PercentBar"
MinSize="20 20"
VerticalAlignment="Center"
Margin="2 8 4 2"
MaxValue="1.0"
MinValue="0.0">
</ProgressBar>
</BoxContainer>
</Control>

View File

@@ -0,0 +1,31 @@
using Content.Shared.Fluids;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Timing;
namespace Content.Client.Fluids.UI
{
[GenerateTypedNameReferences]
public sealed partial class AbsorbentItemStatus : Control
{
private readonly IEntityManager _entManager;
private readonly EntityUid _uid;
public AbsorbentItemStatus(EntityUid uid, IEntityManager entManager)
{
RobustXamlLoader.Load(this);
_uid = uid;
_entManager = entManager;
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
if (!_entManager.TryGetComponent<AbsorbentComponent>(_uid, out var absorbent))
return;
PercentBar.Value = absorbent.Progress;
}
}
}