Remove IItemStatus (#11055)

This commit is contained in:
Alex Evgrashin
2022-09-11 08:53:17 +02:00
committed by GitHub
parent 61655c18b2
commit 385a52c390
18 changed files with 357 additions and 355 deletions

View File

@@ -1,35 +0,0 @@
using Robust.Client.UserInterface;
namespace Content.Client.Items.Components
{
/// <summary>
/// Allows a component to provide status tooltips next to the hands interface.
/// </summary>
public interface IItemStatus
{
/// <summary>
/// Called to get a control that represents the status for this component.
/// </summary>
/// <returns>
/// The control to render as status.
/// </returns>
[Obsolete("Use ItemStatusCollectMessage")]
public Control MakeControl();
/// <summary>
/// Called when the item no longer needs this status (say, dropped from hand)
/// </summary>
/// <remarks>
/// <para>
/// Useful to allow you to drop the control for the GC, if you need to.
/// </para>
/// <para>
/// Note that this may be called after a second invocation of <see cref="MakeControl"/> (for example if the user switches the item between two hands).
/// </para>
/// </remarks>
[Obsolete("Use ItemStatusCollectMessage")]
public void DestroyControl(Control control)
{
}
}
}

View File

@@ -1,4 +1,3 @@
using Content.Client.Items.Components;
using Content.Client.Resources;
using Content.Client.Stylesheets;
using Content.Shared.Hands.Components;
@@ -17,9 +16,6 @@ namespace Content.Client.Items.UI
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[ViewVariables]
private readonly List<(IItemStatus, Control)> _activeStatusComponents = new();
[ViewVariables]
private readonly Label _itemNameLabel;
[ViewVariables]
@@ -166,13 +162,6 @@ namespace Content.Client.Items.UI
private void ClearOldStatus()
{
_statusContents.RemoveAllChildren();
foreach (var (itemStatus, control) in _activeStatusComponents)
{
itemStatus.DestroyControl(control);
}
_activeStatusComponents.Clear();
}
private void BuildNewEntityStatus()
@@ -181,14 +170,6 @@ namespace Content.Client.Items.UI
ClearOldStatus();
foreach (var statusComponent in _entityManager.GetComponents<IItemStatus>(_entity!.Value))
{
var control = statusComponent.MakeControl();
_statusContents.AddChild(control);
_activeStatusComponents.Add((statusComponent, control));
}
var collectMsg = new ItemStatusCollectMessage();
_entityManager.EventBus.RaiseLocalEvent(_entity!.Value, collectMsg, true);