Puddles & spreader refactor (#15191)
This commit is contained in:
@@ -1,16 +1,20 @@
|
||||
using Content.Shared.Fluids;
|
||||
using System.Linq;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Shared.Fluids;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.Fluids.UI
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class AbsorbentItemStatus : Control
|
||||
public sealed partial class AbsorbentItemStatus : SplitBar
|
||||
{
|
||||
private readonly IEntityManager _entManager;
|
||||
private readonly EntityUid _uid;
|
||||
private Dictionary<Color, float> _progress = new();
|
||||
|
||||
public AbsorbentItemStatus(EntityUid uid, IEntityManager entManager)
|
||||
{
|
||||
@@ -25,7 +29,23 @@ namespace Content.Client.Fluids.UI
|
||||
if (!_entManager.TryGetComponent<AbsorbentComponent>(_uid, out var absorbent))
|
||||
return;
|
||||
|
||||
PercentBar.Value = absorbent.Progress;
|
||||
var oldProgress = _progress.ShallowClone();
|
||||
_progress.Clear();
|
||||
|
||||
foreach (var item in absorbent.Progress)
|
||||
{
|
||||
_progress[item.Key] = item.Value;
|
||||
}
|
||||
|
||||
if (oldProgress.OrderBy(x => x.Key.ToArgb()).SequenceEqual(_progress))
|
||||
return;
|
||||
|
||||
Bar.Clear();
|
||||
|
||||
foreach (var (key, value) in absorbent.Progress)
|
||||
{
|
||||
Bar.AddEntry(value, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user