CatStation/Content.Client/Anomaly/Ui/AnomalyStatusControl.cs
Pok e7897d76a4
More item status (#39264)
* more-item-status

* update 1

* update 2

* Update pistol.yml

* update 3

* yml

* oops

* BatteryItemStatus

* fix ChargeItemStatus

* Update item-status.ftl

* review update 1

* review fix 1

* Update BatteryInfoSystem.cs

* Update TimerTriggerItemStatus

* merge fix

* merge fix

* review update 2

* review update 3

* fix marge

* StyleNano

* review update 4

* review update 5

* BatteryItemStatus

* BatteryItemStatus Client

* code cleanup

* merge

* merge and GasTank fix

* Merge

* unnecessary components

* review

* oops

* GasTank

* wawa
2026-07-19 23:41:09 +00:00

57 lines
1.9 KiB
C#

using Content.Client.Items.UI;
using Content.Client.Message;
using Content.Client.Stylesheets;
using Content.Shared.Anomaly.Components;
using Content.Shared.Containers.ItemSlots;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.IoC;
namespace Content.Client.Anomaly.UI;
/// <summary>
/// Displays anomaly core charge information based on <see cref="AnomalyCoreComponent"/> in the slot of.
/// <see cref="CorePoweredThrowerComponent"/>.
/// </summary>
/// <seealso cref="AnomalySystem"/>
public sealed partial class AnomalyStatusControl : PollingItemStatusControl<AnomalyStatusControl.Data>
{
[Dependency] private IEntityManager _entityManager = default!;
private readonly Entity<CorePoweredThrowerComponent> _parent;
private readonly ItemSlotsSystem _itemSlots;
private readonly RichTextLabel _label;
public AnomalyStatusControl(Entity<CorePoweredThrowerComponent> parent)
{
IoCManager.InjectDependencies(this);
_parent = parent;
_itemSlots = _entityManager.System<ItemSlotsSystem>();
_label = new RichTextLabel { StyleClasses = { StyleClass.ItemStatus } };
AddChild(_label);
}
protected override Data PollData()
{
if (_itemSlots.GetItemOrNull(_parent.Owner, _parent.Comp.CoreSlotId) is { } coreEnt
&& _entityManager.TryGetComponent<AnomalyCoreComponent>(coreEnt, out var core))
{
return new Data(true, core.IsDecayed, core.Charge);
}
return new Data(false, false, 0);
}
protected override void Update(in Data data)
{
string markup;
if (!data.IsDecayed)
markup = Loc.GetString("anomaly-status-infinite");
else
markup = Loc.GetString("anomaly-status-charges", ("charges", data.Charges));
_label.SetMarkup(markup);
}
public readonly record struct Data(bool HasCore, bool IsDecayed, int Charges);
}