| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using Content.Shared.Examine;
- using Content.Shared.Labels.Components;
- using Content.Shared.NameModifier.EntitySystems;
- using Robust.Shared.Utility;
- namespace Content.Shared.Labels.EntitySystems;
- public abstract partial class SharedLabelSystem : EntitySystem
- {
- [Dependency] protected readonly NameModifierSystem NameMod = default!;
- public override void Initialize()
- {
- base.Initialize();
- SubscribeLocalEvent<LabelComponent, MapInitEvent>(OnLabelCompMapInit);
- SubscribeLocalEvent<LabelComponent, ExaminedEvent>(OnExamine);
- SubscribeLocalEvent<LabelComponent, RefreshNameModifiersEvent>(OnRefreshNameModifiers);
- }
- private void OnLabelCompMapInit(EntityUid uid, LabelComponent component, MapInitEvent args)
- {
- if (!string.IsNullOrEmpty(component.CurrentLabel))
- {
- component.CurrentLabel = Loc.GetString(component.CurrentLabel);
- Dirty(uid, component);
- }
- NameMod.RefreshNameModifiers(uid);
- }
- public virtual void Label(EntityUid uid, string? text, MetaDataComponent? metadata = null, LabelComponent? label = null){}
- private void OnExamine(EntityUid uid, LabelComponent? label, ExaminedEvent args)
- {
- if (!Resolve(uid, ref label))
- return;
- if (!label.Examinable)
- return;
- if (label.CurrentLabel == null)
- return;
- var message = new FormattedMessage();
- 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));
- }
- }
|