Puddles & spreader refactor (#15191)

This commit is contained in:
metalgearsloth
2023-04-10 15:37:03 +10:00
committed by GitHub
parent 3178ab83f6
commit 317a4013eb
141 changed files with 3046 additions and 3201 deletions

View File

@@ -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);
}
}
}
}