--- /dev/null
+using Content.Shared.Labels.EntitySystems;
+
+namespace Content.Client.Labels;
+
+public sealed partial class LabelSystem : SharedLabelSystem
+{
+}
using Content.Server.Administration.Logs;
using Content.Server.Chemistry.Components;
using Content.Server.Chemistry.Containers.EntitySystems;
-using Content.Server.Nutrition.Components;
using Content.Server.Nutrition.EntitySystems;
-using Content.Server.Labels.Components;
-using Content.Server.Chemistry;
using Content.Shared.Chemistry;
-using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry.Dispenser;
using Content.Shared.Chemistry.EntitySystems;
-using Content.Shared.Chemistry.Reagent;
using Content.Shared.Containers.ItemSlots;
-using Content.Shared.Database;
using Content.Shared.FixedPoint;
using JetBrains.Annotations;
using Robust.Server.Audio;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.Prototypes;
-using System.Linq;
+using Content.Shared.Labels.Components;
namespace Content.Server.Chemistry.EntitySystems
{
+++ /dev/null
-namespace Content.Server.Labels.Components
-{
- /// <summary>
- /// Makes entities have a label in their name. Labels are normally given by <see cref="HandLabelerComponent"/>
- /// </summary>
- [RegisterComponent]
- 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>
- [ViewVariables(VVAccess.ReadWrite)]
- [DataField("currentLabel")]
- 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("originalName")]
- public string? OriginalName { get; set; }
- }
-}
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Examine;
using Content.Shared.Labels;
+using Content.Shared.Labels.Components;
+using Content.Shared.Labels.EntitySystems;
using JetBrains.Annotations;
-using Robust.Server.GameObjects;
using Robust.Shared.Containers;
-using Robust.Shared.Utility;
namespace Content.Server.Labels
{
/// A system that lets players see the contents of a label on an object.
/// </summary>
[UsedImplicitly]
- public sealed class LabelSystem : EntitySystem
+ public sealed class LabelSystem : SharedLabelSystem
{
[Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
{
base.Initialize();
- SubscribeLocalEvent<LabelComponent, ExaminedEvent>(OnExamine);
SubscribeLocalEvent<LabelComponent, MapInitEvent>(OnLabelCompMapInit);
SubscribeLocalEvent<PaperLabelComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<PaperLabelComponent, ComponentRemove>(OnComponentRemove);
private void OnLabelCompMapInit(EntityUid uid, LabelComponent component, MapInitEvent args)
{
if (!string.IsNullOrEmpty(component.CurrentLabel))
+ {
component.CurrentLabel = Loc.GetString(component.CurrentLabel);
+ Dirty(uid, component);
+ }
}
/// <summary>
label.CurrentLabel = null;
label.OriginalName = null;
+ Dirty(uid, label);
+
return;
}
label.OriginalName ??= metadata.EntityName;
label.CurrentLabel = text;
_metaData.SetEntityName(uid, $"{label.OriginalName} ({text})", metadata);
+
+ Dirty(uid, label);
}
private void OnComponentInit(EntityUid uid, PaperLabelComponent component, ComponentInit args)
_itemSlotsSystem.RemoveItemSlot(uid, component.LabelSlot);
}
- 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);
- }
-
private void OnExamined(EntityUid uid, PaperLabelComponent comp, ExaminedEvent args)
{
if (comp.LabelSlot.Item is not {Valid: true} item)
--- /dev/null
+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; }
+}
--- /dev/null
+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);
+ }
+}