Add a system for modifying entity names without causing conflicts (#27863)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Labels.Components;
|
||||
using Content.Shared.NameModifier.EntitySystems;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Labels.EntitySystems;
|
||||
@@ -11,6 +12,7 @@ public abstract partial class SharedLabelSystem : EntitySystem
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<LabelComponent, ExaminedEvent>(OnExamine);
|
||||
SubscribeLocalEvent<LabelComponent, RefreshNameModifiersEvent>(OnRefreshNameModifiers);
|
||||
}
|
||||
|
||||
public virtual void Label(EntityUid uid, string? text, MetaDataComponent? metadata = null, LabelComponent? label = null){}
|
||||
@@ -27,4 +29,10 @@ public abstract partial class SharedLabelSystem : EntitySystem
|
||||
message.AddText(Loc.GetString("hand-labeler-has-label", ("label", label.CurrentLabel)));
|
||||
args.PushMessage(message);
|
||||
}
|
||||
|
||||
private void OnRefreshNameModifiers(Entity<LabelComponent> entity, ref RefreshNameModifiersEvent args)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(entity.Comp.CurrentLabel))
|
||||
args.AddModifier("comp-label-format", extraArgs: ("label", entity.Comp.CurrentLabel));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user