CatStation/Content.Shared/StatusIcon/StatusIconPrototype.cs
SlamBamActionman 19bc31aef7
Add "new player label" over the head of players joining the game for the first time (#44709)
* Initial commit

* RMC? I 'ardly know 'er

* Sprout

* Rework it to use job icons

* Revert the one change

* Always the one yaml

* Easy review changes

* We do a little salami

* Review changes

* NIGHTMARE NIGHTMARE NIGHTMARE

* Update to use StatusIconPrototype only

* Remove async

* Aaaand remove the comment, bah

* Review fixes

* Update master

* Add the ability for ghosts to see

* Byte backing

* Review fix + comment

* Update to 90 min

* Add todo message
2026-09-24 15:34:37 +00:00

167 lines
4.7 KiB
C#

using Content.Shared.Stealth.Components;
using Content.Shared.Whitelist;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array;
using Robust.Shared.Utility;
namespace Content.Shared.StatusIcon;
/// <summary>
/// A data structure that holds relevant
/// information for status icons.
/// </summary>
[Virtual, DataDefinition]
public partial class StatusIconData : IComparable<StatusIconData>
{
/// <summary>
/// The icon that's displayed on the entity.
/// </summary>
[DataField(required: true)]
public SpriteSpecifier Icon = default!;
/// <summary>
/// A priority for the order in which the icons will be displayed.
/// </summary>
[DataField]
public int Priority = 10;
/// <summary>
/// Whether or not to hide the icon to ghosts
/// </summary>
[DataField]
public bool VisibleToGhosts = true;
/// <summary>
/// Whether or not to hide the icon when we are inside a container like a locker or a crate.
/// </summary>
[DataField]
public bool HideInContainer = true;
/// <summary>
/// Whether or not to hide the icon when the entity has an active <see cref="StealthComponent"/>
/// </summary>
[DataField]
public bool HideOnStealth = true;
/// <summary>
/// Specifies what entities and components/tags this icon can be shown to.
/// </summary>
[DataField]
public EntityWhitelist? ShowTo;
/// <summary>
/// A preference for where the icon will be displayed. None | Left | Right
/// </summary>
[DataField]
public StatusIconLocationPreference LocationPreference = StatusIconLocationPreference.None;
/// <summary>
/// The layer the icon is displayed on. Mod is drawn above Base. Base | Mod
/// </summary>
[DataField]
public StatusIconLayer Layer = StatusIconLayer.Base;
/// <summary>
/// Offset of the status icon, up and down only.
/// </summary>
[DataField]
public int Offset = 0;
/// <summary>
/// Offset of the status icon, left and right only.
/// </summary>
[DataField]
public int OffsetHorizontal = 0;
/// <summary>
/// Sets if the icon should be rendered with or without the effect of lighting.
/// </summary>
[DataField]
public bool IsShaded = false;
/// <inheritdoc/>
public int CompareTo(StatusIconData? other)
{
return Priority.CompareTo(other?.Priority ?? int.MaxValue);
}
}
/// <summary>
/// <see cref="StatusIconData"/> but in new convenient prototype form!
/// </summary>
[Prototype]
public sealed partial class StatusIconPrototype : StatusIconData, IPrototype, IInheritingPrototype
{
/// <inheritdoc/>
[IdDataField]
public string ID { get; private set; } = default!;
/// <inheritdoc />
[ParentDataField(typeof(AbstractPrototypeIdArraySerializer<StatusIconPrototype>))]
public string[]? Parents { get; private set; }
/// <inheritdoc />
[NeverPushInheritance]
[AbstractDataField]
public bool Abstract { get; private set; }
}
/// <summary>
/// StatusIcons for showing jobs icons.
/// </summary>
[Prototype]
public sealed partial class JobIconPrototype : StatusIconData, IPrototype, IInheritingPrototype
{
/// <inheritdoc/>
[IdDataField]
public string ID { get; private set; } = default!;
/// <inheritdoc />
[ParentDataField(typeof(AbstractPrototypeIdArraySerializer<JobIconPrototype>))]
public string[]? Parents { get; private set; }
/// <inheritdoc />
[NeverPushInheritance]
[AbstractDataField]
public bool Abstract { get; private set; }
/// <summary>
/// Name of the icon used for menu tooltips.
/// </summary>
[DataField]
public string JobName { get; private set; } = string.Empty;
/// <summary>
/// Localized job name to use for showing to players.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
public string LocalizedJobName => Loc.GetString(JobName);
/// <summary>
/// Should this job icon be considered a crew job for silicons?
/// </summary>
[DataField]
public bool IsCrewJob = true;
}
/// <summary>
/// The location of the status icon.
/// </summary>
[Serializable, NetSerializable]
public enum StatusIconLocationPreference : byte
{
None, // Aligns on left side, if there's room on either side
Left, // Aligns on left side, provided left side has room
Right, // Aligns on right side, provided right side has room
Fixed, // Gets set independently without considering existing status icons
}
/// <summary>
/// Which layer the status icon should be displayed on.
/// </summary>
public enum StatusIconLayer : byte
{
Base,
Mod,
}