Files
tbd-station-14/Content.Client/Items/ItemStatusMessages.cs
metalgearsloth fb943a61dc Gun refactor (#8301)
Co-authored-by: Kara <lunarautomaton6@gmail.com>
Co-authored-by: T-Stalker <le0nel_1van@hotmail.com>
Co-authored-by: T-Stalker <43253663+DogZeroX@users.noreply.github.com>
Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
2022-06-01 19:59:58 +10:00

30 lines
1.0 KiB
C#

using Robust.Client.UserInterface;
namespace Content.Client.Items
{
public sealed class ItemStatusCollectMessage : EntityEventArgs
{
public List<Control> Controls = new();
}
public static class ItemStatusRegisterExt
{
/// <summary>
/// Register an item status control for a component.
/// </summary>
/// <param name="subs">The <see cref="EntitySystem.Subs"/> handle from within entity system initialize.</param>
/// <param name="createControl">A delegate to create the actual control.</param>
/// <typeparam name="TComp">The type of component for which this control should be made.</typeparam>
public static void ItemStatus<TComp>(
this EntitySystem.Subscriptions subs,
Func<EntityUid, Control> createControl)
where TComp : IComponent
{
subs.SubscribeLocalEvent<TComp, ItemStatusCollectMessage>((uid, _, args) =>
{
args.Controls.Add(createControl(uid));
});
}
}
}