From 1540880eb20957c4a5a0e12ca6906ca14aed041e Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Fri, 11 Apr 2025 01:19:48 -0400 Subject: [PATCH] Predict Labels (#36406) * Predict Labels * nitpicks --- .../Labels/EntitySystems/LabelSystem.cs | 7 - .../Botany/Systems/PlantHolderSystem.cs | 5 +- .../Cargo/Systems/CargoSystem.Bounty.cs | 2 +- .../Cargo/Systems/CargoSystem.Orders.cs | 2 +- .../Cartridges/LogProbeCartridgeSystem.cs | 2 +- .../EntitySystems/ChemMasterSystem.cs | 2 +- .../Cloning/CloningSystem.Subscriptions.cs | 2 +- Content.Server/Delivery/DeliverySystem.cs | 2 +- Content.Server/Fax/FaxSystem.cs | 2 +- .../Forensics/Systems/ForensicPadSystem.cs | 2 +- .../Label/Components/PaperLabelComponent.cs | 14 -- Content.Server/Labels/Label/LabelSystem.cs | 115 -------------- Content.Server/Salvage/SalvageSystem.cs | 2 +- .../Shuttles/Commands/FTLDiskCommand.cs | 2 +- .../Labels/Components/LabelComponent.cs | 2 + .../Labels/Components/PaperLabelComponent.cs | 19 +++ .../Components/PaperLabelTypeComponent.cs | 12 +- .../Labels/EntitySystems/LabelSystem.cs | 144 ++++++++++++++++++ .../EntitySystems/SharedHandLabelerSystem.cs | 2 +- .../Labels/EntitySystems/SharedLabelSystem.cs | 54 ------- 20 files changed, 185 insertions(+), 209 deletions(-) delete mode 100644 Content.Client/Labels/EntitySystems/LabelSystem.cs delete mode 100644 Content.Server/Labels/Label/Components/PaperLabelComponent.cs delete mode 100644 Content.Server/Labels/Label/LabelSystem.cs create mode 100644 Content.Shared/Labels/Components/PaperLabelComponent.cs create mode 100644 Content.Shared/Labels/EntitySystems/LabelSystem.cs delete mode 100644 Content.Shared/Labels/EntitySystems/SharedLabelSystem.cs diff --git a/Content.Client/Labels/EntitySystems/LabelSystem.cs b/Content.Client/Labels/EntitySystems/LabelSystem.cs deleted file mode 100644 index baa9f7fee7..0000000000 --- a/Content.Client/Labels/EntitySystems/LabelSystem.cs +++ /dev/null @@ -1,7 +0,0 @@ -using Content.Shared.Labels.EntitySystems; - -namespace Content.Client.Labels; - -public sealed partial class LabelSystem : SharedLabelSystem -{ -} diff --git a/Content.Server/Botany/Systems/PlantHolderSystem.cs b/Content.Server/Botany/Systems/PlantHolderSystem.cs index 5dbafae5af..2661ed479c 100644 --- a/Content.Server/Botany/Systems/PlantHolderSystem.cs +++ b/Content.Server/Botany/Systems/PlantHolderSystem.cs @@ -22,10 +22,10 @@ using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Random; using Robust.Shared.Timing; -using Content.Server.Labels.Components; using Content.Shared.Administration.Logs; using Content.Shared.Containers.ItemSlots; using Content.Shared.Database; +using Content.Shared.Labels.Components; namespace Content.Server.Botany.Systems; @@ -45,8 +45,7 @@ public sealed class PlantHolderSystem : EntitySystem [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly ItemSlotsSystem _itemSlots = default!; [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; - - + public const float HydroponicsSpeedMultiplier = 1f; public const float HydroponicsConsumptionMultiplier = 2f; diff --git a/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs b/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs index 7f74fe269d..c938c6fa50 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs @@ -1,7 +1,6 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using Content.Server.Cargo.Components; -using Content.Server.Labels; using Content.Server.NameIdentifier; using Content.Shared.Access.Components; using Content.Shared.Cargo; @@ -9,6 +8,7 @@ using Content.Shared.Cargo.Components; using Content.Shared.Cargo.Prototypes; using Content.Shared.Database; using Content.Shared.IdentityManagement; +using Content.Shared.Labels.EntitySystems; using Content.Shared.NameIdentifier; using Content.Shared.Paper; using Content.Shared.Stacks; diff --git a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs index 9b6407c689..ee6526c321 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs @@ -1,6 +1,5 @@ using System.Diagnostics.CodeAnalysis; using Content.Server.Cargo.Components; -using Content.Server.Labels.Components; using Content.Server.Station.Components; using Content.Shared.Cargo; using Content.Shared.Cargo.BUI; @@ -11,6 +10,7 @@ using Content.Shared.Database; using Content.Shared.Emag.Systems; using Content.Shared.IdentityManagement; using Content.Shared.Interaction; +using Content.Shared.Labels.Components; using Content.Shared.Paper; using Robust.Shared.Map; using Robust.Shared.Prototypes; diff --git a/Content.Server/CartridgeLoader/Cartridges/LogProbeCartridgeSystem.cs b/Content.Server/CartridgeLoader/Cartridges/LogProbeCartridgeSystem.cs index ac5c0baa54..75b6b44636 100644 --- a/Content.Server/CartridgeLoader/Cartridges/LogProbeCartridgeSystem.cs +++ b/Content.Server/CartridgeLoader/Cartridges/LogProbeCartridgeSystem.cs @@ -23,7 +23,7 @@ public sealed class LogProbeCartridgeSystem : EntitySystem [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedHandsSystem _hands = default!; - [Dependency] private readonly SharedLabelSystem _label = default!; + [Dependency] private readonly LabelSystem _label = default!; [Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly PaperSystem _paper = default!; diff --git a/Content.Server/Chemistry/EntitySystems/ChemMasterSystem.cs b/Content.Server/Chemistry/EntitySystems/ChemMasterSystem.cs index dd97bfa8f6..6e2e2a91bc 100644 --- a/Content.Server/Chemistry/EntitySystems/ChemMasterSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ChemMasterSystem.cs @@ -1,5 +1,4 @@ using Content.Server.Chemistry.Components; -using Content.Server.Labels; using Content.Server.Popups; using Content.Server.Storage.EntitySystems; using Content.Shared.Administration.Logs; @@ -10,6 +9,7 @@ using Content.Shared.Chemistry.Reagent; using Content.Shared.Containers.ItemSlots; using Content.Shared.Database; using Content.Shared.FixedPoint; +using Content.Shared.Labels.EntitySystems; using Content.Shared.Storage; using JetBrains.Annotations; using Robust.Server.Audio; diff --git a/Content.Server/Cloning/CloningSystem.Subscriptions.cs b/Content.Server/Cloning/CloningSystem.Subscriptions.cs index 659d9a1ea1..eba806ceb8 100644 --- a/Content.Server/Cloning/CloningSystem.Subscriptions.cs +++ b/Content.Server/Cloning/CloningSystem.Subscriptions.cs @@ -25,7 +25,7 @@ namespace Content.Server.Cloning; public sealed partial class CloningSystem : EntitySystem { [Dependency] private readonly SharedStackSystem _stack = default!; - [Dependency] private readonly SharedLabelSystem _label = default!; + [Dependency] private readonly LabelSystem _label = default!; [Dependency] private readonly ForensicsSystem _forensics = default!; [Dependency] private readonly PaperSystem _paper = default!; diff --git a/Content.Server/Delivery/DeliverySystem.cs b/Content.Server/Delivery/DeliverySystem.cs index 8ac8722821..8d2052733e 100644 --- a/Content.Server/Delivery/DeliverySystem.cs +++ b/Content.Server/Delivery/DeliverySystem.cs @@ -23,7 +23,7 @@ public sealed partial class DeliverySystem : SharedDeliverySystem [Dependency] private readonly StationRecordsSystem _records = default!; [Dependency] private readonly StationSystem _station = default!; [Dependency] private readonly FingerprintReaderSystem _fingerprintReader = default!; - [Dependency] private readonly SharedLabelSystem _label = default!; + [Dependency] private readonly LabelSystem _label = default!; [Dependency] private readonly SharedContainerSystem _container = default!; public override void Initialize() diff --git a/Content.Server/Fax/FaxSystem.cs b/Content.Server/Fax/FaxSystem.cs index 180689f892..1ac7bd23ca 100644 --- a/Content.Server/Fax/FaxSystem.cs +++ b/Content.Server/Fax/FaxSystem.cs @@ -4,7 +4,6 @@ using Content.Server.Chat.Managers; using Content.Server.DeviceNetwork; using Content.Server.DeviceNetwork.Components; using Content.Server.DeviceNetwork.Systems; -using Content.Server.Labels; using Content.Server.Popups; using Content.Server.Power.Components; using Content.Server.Tools; @@ -20,6 +19,7 @@ using Content.Shared.Fax.Systems; using Content.Shared.Fax.Components; using Content.Shared.Interaction; using Content.Shared.Labels.Components; +using Content.Shared.Labels.EntitySystems; using Content.Shared.Mobs.Components; using Content.Shared.Paper; using Robust.Server.GameObjects; diff --git a/Content.Server/Forensics/Systems/ForensicPadSystem.cs b/Content.Server/Forensics/Systems/ForensicPadSystem.cs index 846d72a9fa..2841f36b00 100644 --- a/Content.Server/Forensics/Systems/ForensicPadSystem.cs +++ b/Content.Server/Forensics/Systems/ForensicPadSystem.cs @@ -1,4 +1,3 @@ -using Content.Server.Labels; using Content.Server.Popups; using Content.Shared.DoAfter; using Content.Shared.Examine; @@ -7,6 +6,7 @@ using Content.Shared.Forensics.Components; using Content.Shared.IdentityManagement; using Content.Shared.Interaction; using Content.Shared.Inventory; +using Content.Shared.Labels.EntitySystems; namespace Content.Server.Forensics { diff --git a/Content.Server/Labels/Label/Components/PaperLabelComponent.cs b/Content.Server/Labels/Label/Components/PaperLabelComponent.cs deleted file mode 100644 index 5dead98084..0000000000 --- a/Content.Server/Labels/Label/Components/PaperLabelComponent.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Content.Shared.Containers.ItemSlots; - -namespace Content.Server.Labels.Components -{ - /// - /// This component allows you to attach and remove a piece of paper to an entity. - /// - [RegisterComponent] - public sealed partial class PaperLabelComponent : Component - { - [DataField("labelSlot")] - public ItemSlot LabelSlot = new(); - } -} diff --git a/Content.Server/Labels/Label/LabelSystem.cs b/Content.Server/Labels/Label/LabelSystem.cs deleted file mode 100644 index b70c004123..0000000000 --- a/Content.Server/Labels/Label/LabelSystem.cs +++ /dev/null @@ -1,115 +0,0 @@ -using Content.Server.Labels.Components; -using Content.Shared.Containers.ItemSlots; -using Content.Shared.Examine; -using Content.Shared.Labels; -using Content.Shared.Labels.Components; -using Content.Shared.Labels.EntitySystems; -using Content.Shared.Paper; -using JetBrains.Annotations; -using Robust.Shared.Containers; - -namespace Content.Server.Labels -{ - /// - /// A system that lets players see the contents of a label on an object. - /// - [UsedImplicitly] - public sealed class LabelSystem : SharedLabelSystem - { - [Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!; - [Dependency] private readonly SharedAppearanceSystem _appearance = default!; - - public const string ContainerName = "paper_label"; - - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(OnComponentInit); - SubscribeLocalEvent(OnComponentRemove); - SubscribeLocalEvent(OnContainerModified); - SubscribeLocalEvent(OnContainerModified); - SubscribeLocalEvent(OnExamined); - } - - /// - /// Apply or remove a label on an entity. - /// - /// EntityUid to change label on - /// intended label text (null to remove) - /// label component for resolve - /// metadata component for resolve - public override void Label(EntityUid uid, string? text, MetaDataComponent? metadata = null, LabelComponent? label = null) - { - if (!Resolve(uid, ref label, false)) - label = EnsureComp(uid); - - label.CurrentLabel = text; - NameMod.RefreshNameModifiers(uid); - - Dirty(uid, label); - } - - private void OnComponentInit(EntityUid uid, PaperLabelComponent component, ComponentInit args) - { - _itemSlotsSystem.AddItemSlot(uid, ContainerName, component.LabelSlot); - - UpdateAppearance((uid, component)); - } - - private void OnComponentRemove(EntityUid uid, PaperLabelComponent component, ComponentRemove args) - { - _itemSlotsSystem.RemoveItemSlot(uid, component.LabelSlot); - } - - private void OnExamined(EntityUid uid, PaperLabelComponent comp, ExaminedEvent args) - { - if (comp.LabelSlot.Item is not {Valid: true} item) - return; - - using (args.PushGroup(nameof(PaperLabelComponent))) - { - if (!args.IsInDetailsRange) - { - args.PushMarkup(Loc.GetString("comp-paper-label-has-label-cant-read")); - return; - } - - if (!EntityManager.TryGetComponent(item, out PaperComponent? paper)) - // Assuming yaml has the correct entity whitelist, this should not happen. - return; - - if (string.IsNullOrWhiteSpace(paper.Content)) - { - args.PushMarkup(Loc.GetString("comp-paper-label-has-label-blank")); - return; - } - - args.PushMarkup(Loc.GetString("comp-paper-label-has-label")); - var text = paper.Content; - args.PushMarkup(text.TrimEnd()); - } - } - - private void OnContainerModified(EntityUid uid, PaperLabelComponent label, ContainerModifiedMessage args) - { - if (!label.Initialized) return; - - if (args.Container.ID != label.LabelSlot.ID) - return; - - UpdateAppearance((uid, label)); - } - - private void UpdateAppearance(Entity ent) - { - if (!Resolve(ent, ref ent.Comp2, false)) - return; - - var slot = ent.Comp1.LabelSlot; - _appearance.SetData(ent, PaperLabelVisuals.HasLabel, slot.HasItem, ent.Comp2); - if (TryComp(slot.Item, out var type)) - _appearance.SetData(ent, PaperLabelVisuals.LabelType, type.PaperType, ent.Comp2); - } - } -} diff --git a/Content.Server/Salvage/SalvageSystem.cs b/Content.Server/Salvage/SalvageSystem.cs index 9115c60536..53bb0c06b3 100644 --- a/Content.Server/Salvage/SalvageSystem.cs +++ b/Content.Server/Salvage/SalvageSystem.cs @@ -16,7 +16,7 @@ using Content.Shared.Construction.EntitySystems; using Robust.Shared.Audio.Systems; using Robust.Shared.Map.Components; using Robust.Shared.Timing; -using Content.Server.Labels; +using Content.Shared.Labels.EntitySystems; using Robust.Shared.EntitySerialization.Systems; namespace Content.Server.Salvage diff --git a/Content.Server/Shuttles/Commands/FTLDiskCommand.cs b/Content.Server/Shuttles/Commands/FTLDiskCommand.cs index b17c7c11a7..014dbe6d99 100644 --- a/Content.Server/Shuttles/Commands/FTLDiskCommand.cs +++ b/Content.Server/Shuttles/Commands/FTLDiskCommand.cs @@ -1,8 +1,8 @@ using Content.Server.Administration; -using Content.Server.Labels; using Content.Shared.Administration; using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; +using Content.Shared.Labels.EntitySystems; using Content.Shared.Shuttles.Components; using Content.Shared.Storage; using Content.Shared.Storage.EntitySystems; diff --git a/Content.Shared/Labels/Components/LabelComponent.cs b/Content.Shared/Labels/Components/LabelComponent.cs index ee508797ad..d126e3bd3a 100644 --- a/Content.Shared/Labels/Components/LabelComponent.cs +++ b/Content.Shared/Labels/Components/LabelComponent.cs @@ -1,3 +1,4 @@ +using Content.Shared.Labels.EntitySystems; using Robust.Shared.GameStates; namespace Content.Shared.Labels.Components; @@ -6,6 +7,7 @@ namespace Content.Shared.Labels.Components; /// Makes entities have a label in their name. Labels are normally given by /// [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +[Access(typeof(LabelSystem))] public sealed partial class LabelComponent : Component { /// diff --git a/Content.Shared/Labels/Components/PaperLabelComponent.cs b/Content.Shared/Labels/Components/PaperLabelComponent.cs new file mode 100644 index 0000000000..e8dad61b87 --- /dev/null +++ b/Content.Shared/Labels/Components/PaperLabelComponent.cs @@ -0,0 +1,19 @@ +using Content.Shared.Containers.ItemSlots; +using Content.Shared.Labels.EntitySystems; +using Robust.Shared.GameStates; + +namespace Content.Shared.Labels.Components; + +/// +/// This component allows you to attach and remove a piece of paper to an entity. +/// +[RegisterComponent, NetworkedComponent] +[Access(typeof(LabelSystem))] +public sealed partial class PaperLabelComponent : Component +{ + /// + /// The slot where the label is stored. + /// + [DataField] + public ItemSlot LabelSlot = new(); +} diff --git a/Content.Shared/Labels/Components/PaperLabelTypeComponent.cs b/Content.Shared/Labels/Components/PaperLabelTypeComponent.cs index b045a6af3b..12cddad80f 100644 --- a/Content.Shared/Labels/Components/PaperLabelTypeComponent.cs +++ b/Content.Shared/Labels/Components/PaperLabelTypeComponent.cs @@ -1,15 +1,17 @@ +using Content.Shared.Labels.EntitySystems; using Robust.Shared.GameStates; namespace Content.Shared.Labels.Components; -/// -/// Specifies the paper type (see textures/storage/crates/labels.rsi to see currently supported paper types) to show on crates this label is attached to. -/// +/// +/// Specifies the paper type (see textures/storage/crates/labels.rsi to see currently supported paper types) to show on crates this label is attached to. +/// [RegisterComponent, NetworkedComponent] +[Access(typeof(LabelSystem))] public sealed partial class PaperLabelTypeComponent : Component { - /// - /// The type of label to show. + /// + /// The type of label to show. /// [DataField] public string PaperType = "Paper"; diff --git a/Content.Shared/Labels/EntitySystems/LabelSystem.cs b/Content.Shared/Labels/EntitySystems/LabelSystem.cs new file mode 100644 index 0000000000..569acc7bca --- /dev/null +++ b/Content.Shared/Labels/EntitySystems/LabelSystem.cs @@ -0,0 +1,144 @@ +using Content.Shared.Containers.ItemSlots; +using Content.Shared.Examine; +using Content.Shared.Labels.Components; +using Content.Shared.NameModifier.EntitySystems; +using Content.Shared.Paper; +using Robust.Shared.Containers; +using Robust.Shared.Utility; + +namespace Content.Shared.Labels.EntitySystems; + +public sealed partial class LabelSystem : EntitySystem +{ + [Dependency] private readonly NameModifierSystem _nameModifier = default!; + [Dependency] private readonly ItemSlotsSystem _itemSlots = default!; + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + + public const string ContainerName = "paper_label"; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnLabelCompMapInit); + SubscribeLocalEvent(OnExamine); + SubscribeLocalEvent(OnRefreshNameModifiers); + + SubscribeLocalEvent(OnComponentInit); + SubscribeLocalEvent(OnComponentRemove); + SubscribeLocalEvent(OnContainerModified); + SubscribeLocalEvent(OnContainerModified); + SubscribeLocalEvent(OnExamined); + } + + private void OnLabelCompMapInit(Entity ent, ref MapInitEvent args) + { + if (!string.IsNullOrEmpty(ent.Comp.CurrentLabel)) + { + ent.Comp.CurrentLabel = Loc.GetString(ent.Comp.CurrentLabel); + Dirty(ent); + } + + _nameModifier.RefreshNameModifiers(ent.Owner); + } + + /// + /// Apply or remove a label on an entity. + /// + /// EntityUid to change label on + /// intended label text (null to remove) + /// label component for resolve + /// metadata component for resolve + public void Label(EntityUid uid, string? text, MetaDataComponent? metadata = null, LabelComponent? label = null) + { + label ??= EnsureComp(uid); + + label.CurrentLabel = text; + _nameModifier.RefreshNameModifiers(uid); + + Dirty(uid, label); + } + + private void OnExamine(Entity ent, ref ExaminedEvent args) + { + if (!ent.Comp.Examinable) + return; + + if (ent.Comp.CurrentLabel == null) + return; + + var message = new FormattedMessage(); + message.AddText(Loc.GetString("hand-labeler-has-label", ("label", ent.Comp.CurrentLabel))); + args.PushMessage(message); + } + + private void OnRefreshNameModifiers(Entity entity, ref RefreshNameModifiersEvent args) + { + if (!string.IsNullOrEmpty(entity.Comp.CurrentLabel)) + args.AddModifier("comp-label-format", extraArgs: ("label", entity.Comp.CurrentLabel)); + } + + private void OnComponentInit(Entity ent, ref ComponentInit args) + { + _itemSlots.AddItemSlot(ent, ContainerName, ent.Comp.LabelSlot); + + UpdateAppearance(ent); + } + + private void OnComponentRemove(Entity ent, ref ComponentRemove args) + { + _itemSlots.RemoveItemSlot(ent, ent.Comp.LabelSlot); + } + + private void OnExamined(Entity ent, ref ExaminedEvent args) + { + if (ent.Comp.LabelSlot.Item is not {Valid: true} item) + return; + + using (args.PushGroup(nameof(PaperLabelComponent))) + { + if (!args.IsInDetailsRange) + { + args.PushMarkup(Loc.GetString("comp-paper-label-has-label-cant-read")); + return; + } + + // Assuming yaml has the correct entity whitelist, this should not happen. + if (!TryComp(item, out var paper)) + return; + + if (string.IsNullOrWhiteSpace(paper.Content)) + { + args.PushMarkup(Loc.GetString("comp-paper-label-has-label-blank")); + return; + } + + args.PushMarkup(Loc.GetString("comp-paper-label-has-label")); + var text = paper.Content; + args.PushMarkup(text.TrimEnd()); + } + } + + // Not ref-sub due to being used for multiple subscriptions. + private void OnContainerModified(EntityUid uid, PaperLabelComponent label, ContainerModifiedMessage args) + { + if (!label.Initialized) + return; + + if (args.Container.ID != label.LabelSlot.ID) + return; + + UpdateAppearance((uid, label)); + } + + private void UpdateAppearance(Entity ent) + { + if (!Resolve(ent, ref ent.Comp2, false)) + return; + + var slot = ent.Comp1.LabelSlot; + _appearance.SetData(ent, PaperLabelVisuals.HasLabel, slot.HasItem, ent.Comp2); + if (TryComp(slot.Item, out var type)) + _appearance.SetData(ent, PaperLabelVisuals.LabelType, type.PaperType, ent.Comp2); + } +} diff --git a/Content.Shared/Labels/EntitySystems/SharedHandLabelerSystem.cs b/Content.Shared/Labels/EntitySystems/SharedHandLabelerSystem.cs index 0763bb101c..14abae70bb 100644 --- a/Content.Shared/Labels/EntitySystems/SharedHandLabelerSystem.cs +++ b/Content.Shared/Labels/EntitySystems/SharedHandLabelerSystem.cs @@ -14,7 +14,7 @@ public abstract class SharedHandLabelerSystem : EntitySystem { [Dependency] protected readonly SharedUserInterfaceSystem UserInterfaceSystem = default!; [Dependency] private readonly SharedPopupSystem _popupSystem = default!; - [Dependency] private readonly SharedLabelSystem _labelSystem = default!; + [Dependency] private readonly LabelSystem _labelSystem = default!; [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; [Dependency] private readonly INetManager _netManager = default!; [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!; diff --git a/Content.Shared/Labels/EntitySystems/SharedLabelSystem.cs b/Content.Shared/Labels/EntitySystems/SharedLabelSystem.cs deleted file mode 100644 index 8d54871563..0000000000 --- a/Content.Shared/Labels/EntitySystems/SharedLabelSystem.cs +++ /dev/null @@ -1,54 +0,0 @@ -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(OnLabelCompMapInit); - SubscribeLocalEvent(OnExamine); - SubscribeLocalEvent(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 entity, ref RefreshNameModifiersEvent args) - { - if (!string.IsNullOrEmpty(entity.Comp.CurrentLabel)) - args.AddModifier("comp-label-format", extraArgs: ("label", entity.Comp.CurrentLabel)); - } -}