Add prediction to hand labeler labels (#25869)
Added prediction to labels
This commit is contained in:
24
Content.Shared/Labels/Components/LabelComponent.cs
Normal file
24
Content.Shared/Labels/Components/LabelComponent.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Labels.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Makes entities have a label in their name. Labels are normally given by <see cref="HandLabelerComponent"/>
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
public sealed partial class LabelComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Current text on the label. If set before map init, during map init this string will be localized.
|
||||
/// This permits localized preset labels with fallback to the text written on the label.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public string? CurrentLabel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The original name of the entity
|
||||
/// Used for reverting the modified entity name when the label is removed
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public string? OriginalName { get; set; }
|
||||
}
|
||||
28
Content.Shared/Labels/EntitySystems/SharedLabelSystem.cs
Normal file
28
Content.Shared/Labels/EntitySystems/SharedLabelSystem.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Labels.Components;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Labels.EntitySystems;
|
||||
|
||||
public abstract partial class SharedLabelSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<LabelComponent, ExaminedEvent>(OnExamine);
|
||||
}
|
||||
|
||||
private void OnExamine(EntityUid uid, LabelComponent? label, ExaminedEvent args)
|
||||
{
|
||||
if (!Resolve(uid, ref label))
|
||||
return;
|
||||
|
||||
if (label.CurrentLabel == null)
|
||||
return;
|
||||
|
||||
var message = new FormattedMessage();
|
||||
message.AddText(Loc.GetString("hand-labeler-has-label", ("label", label.CurrentLabel)));
|
||||
args.PushMessage(message);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user