Status Icons (#17529)

This commit is contained in:
Nemanja
2023-06-27 20:31:53 -04:00
committed by GitHub
parent 19864b444d
commit 044d5f6853
12 changed files with 276 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
using Robust.Shared.GameStates;
namespace Content.Shared.StatusIcon.Components;
/// <summary>
/// This is used for noting if an entity is able to
/// have StatusIcons displayed on them and inherent icons. (debug purposes)
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(SharedStatusIconSystem))]
public sealed partial class StatusIconComponent : Component
{
/// <summary>
/// Optional bounds for where the icons are laid out.
/// If null, the sprite bounds will be used.
/// </summary>
[AutoNetworkedField]
[DataField("bounds"), ViewVariables(VVAccess.ReadWrite)]
public Box2? Bounds;
}
/// <summary>
/// Event raised directed on an entity CLIENT-SIDE ONLY
/// in order to get what status icons an entity has.
/// </summary>
/// <param name="StatusIcons"></param>
[ByRefEvent]
public record struct GetStatusIconsEvent(List<StatusIconData> StatusIcons);

View File

@@ -0,0 +1,9 @@
namespace Content.Shared.StatusIcon;
public abstract class SharedStatusIconSystem : EntitySystem
{
// If you are trying to add logic for status icons here, you're probably in the wrong place.
// Status icons are gathered and rendered entirely clientside.
// If you wish to use data to render icons, you should replicate that data to the client
// and subscribe to GetStatusIconsEvent in order to add the relevant icon to a given entity.
}

View File

@@ -0,0 +1,40 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Shared.StatusIcon;
/// <summary>
/// A data structure that holds relevant
/// information for status icons.
/// </summary>
[Virtual, DataDefinition]
public class StatusIconData : IComparable<StatusIconData>
{
/// <summary>
/// The icon that's displayed on the entity.
/// </summary>
[DataField("icon", required: true)]
public SpriteSpecifier Icon = default!;
/// <summary>
/// A priority for the order in which the icons will be displayed.
/// </summary>
[DataField("priority")]
public int Priority = 10;
public int CompareTo(StatusIconData? other)
{
return Priority.CompareTo(other?.Priority ?? int.MaxValue);
}
}
/// <summary>
/// <see cref="StatusIconData"/> but in new convenient prototype form!
/// </summary>
[Prototype("statusIcon")]
public sealed class StatusIconPrototype : StatusIconData, IPrototype
{
/// <inheritdoc/>
[IdDataField]
public string ID { get; } = default!;
}