@@ -1,7 +0,0 @@
|
||||
using Content.Shared.Labels.EntitySystems;
|
||||
|
||||
namespace Content.Client.Labels;
|
||||
|
||||
public sealed partial class LabelSystem : SharedLabelSystem
|
||||
{
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -46,7 +46,6 @@ public sealed class PlantHolderSystem : EntitySystem
|
||||
[Dependency] private readonly ItemSlotsSystem _itemSlots = default!;
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
|
||||
|
||||
public const float HydroponicsSpeedMultiplier = 1f;
|
||||
public const float HydroponicsConsumptionMultiplier = 2f;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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!;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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!;
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
|
||||
namespace Content.Server.Labels.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// This component allows you to attach and remove a piece of paper to an entity.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class PaperLabelComponent : Component
|
||||
{
|
||||
[DataField("labelSlot")]
|
||||
public ItemSlot LabelSlot = new();
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// A system that lets players see the contents of a label on an object.
|
||||
/// </summary>
|
||||
[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<PaperLabelComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<PaperLabelComponent, ComponentRemove>(OnComponentRemove);
|
||||
SubscribeLocalEvent<PaperLabelComponent, EntInsertedIntoContainerMessage>(OnContainerModified);
|
||||
SubscribeLocalEvent<PaperLabelComponent, EntRemovedFromContainerMessage>(OnContainerModified);
|
||||
SubscribeLocalEvent<PaperLabelComponent, ExaminedEvent>(OnExamined);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply or remove a label on an entity.
|
||||
/// </summary>
|
||||
/// <param name="uid">EntityUid to change label on</param>
|
||||
/// <param name="text">intended label text (null to remove)</param>
|
||||
/// <param name="label">label component for resolve</param>
|
||||
/// <param name="metadata">metadata component for resolve</param>
|
||||
public override void Label(EntityUid uid, string? text, MetaDataComponent? metadata = null, LabelComponent? label = null)
|
||||
{
|
||||
if (!Resolve(uid, ref label, false))
|
||||
label = EnsureComp<LabelComponent>(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<PaperLabelComponent, AppearanceComponent?> 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<PaperLabelTypeComponent>(slot.Item, out var type))
|
||||
_appearance.SetData(ent, PaperLabelVisuals.LabelType, type.PaperType, ent.Comp2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 <see cref="HandLabelerComponent"/>
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
[Access(typeof(LabelSystem))]
|
||||
public sealed partial class LabelComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
19
Content.Shared/Labels/Components/PaperLabelComponent.cs
Normal file
19
Content.Shared/Labels/Components/PaperLabelComponent.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.Labels.EntitySystems;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Labels.Components;
|
||||
|
||||
/// <summary>
|
||||
/// This component allows you to attach and remove a piece of paper to an entity.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
[Access(typeof(LabelSystem))]
|
||||
public sealed partial class PaperLabelComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The slot where the label is stored.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public ItemSlot LabelSlot = new();
|
||||
}
|
||||
@@ -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;
|
||||
/// 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.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
[Access(typeof(LabelSystem))]
|
||||
public sealed partial class PaperLabelTypeComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
144
Content.Shared/Labels/EntitySystems/LabelSystem.cs
Normal file
144
Content.Shared/Labels/EntitySystems/LabelSystem.cs
Normal file
@@ -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<LabelComponent, MapInitEvent>(OnLabelCompMapInit);
|
||||
SubscribeLocalEvent<LabelComponent, ExaminedEvent>(OnExamine);
|
||||
SubscribeLocalEvent<LabelComponent, RefreshNameModifiersEvent>(OnRefreshNameModifiers);
|
||||
|
||||
SubscribeLocalEvent<PaperLabelComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<PaperLabelComponent, ComponentRemove>(OnComponentRemove);
|
||||
SubscribeLocalEvent<PaperLabelComponent, EntInsertedIntoContainerMessage>(OnContainerModified);
|
||||
SubscribeLocalEvent<PaperLabelComponent, EntRemovedFromContainerMessage>(OnContainerModified);
|
||||
SubscribeLocalEvent<PaperLabelComponent, ExaminedEvent>(OnExamined);
|
||||
}
|
||||
|
||||
private void OnLabelCompMapInit(Entity<LabelComponent> ent, ref MapInitEvent args)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ent.Comp.CurrentLabel))
|
||||
{
|
||||
ent.Comp.CurrentLabel = Loc.GetString(ent.Comp.CurrentLabel);
|
||||
Dirty(ent);
|
||||
}
|
||||
|
||||
_nameModifier.RefreshNameModifiers(ent.Owner);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply or remove a label on an entity.
|
||||
/// </summary>
|
||||
/// <param name="uid">EntityUid to change label on</param>
|
||||
/// <param name="text">intended label text (null to remove)</param>
|
||||
/// <param name="label">label component for resolve</param>
|
||||
/// <param name="metadata">metadata component for resolve</param>
|
||||
public void Label(EntityUid uid, string? text, MetaDataComponent? metadata = null, LabelComponent? label = null)
|
||||
{
|
||||
label ??= EnsureComp<LabelComponent>(uid);
|
||||
|
||||
label.CurrentLabel = text;
|
||||
_nameModifier.RefreshNameModifiers(uid);
|
||||
|
||||
Dirty(uid, label);
|
||||
}
|
||||
|
||||
private void OnExamine(Entity<LabelComponent> 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<LabelComponent> entity, ref RefreshNameModifiersEvent args)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(entity.Comp.CurrentLabel))
|
||||
args.AddModifier("comp-label-format", extraArgs: ("label", entity.Comp.CurrentLabel));
|
||||
}
|
||||
|
||||
private void OnComponentInit(Entity<PaperLabelComponent> ent, ref ComponentInit args)
|
||||
{
|
||||
_itemSlots.AddItemSlot(ent, ContainerName, ent.Comp.LabelSlot);
|
||||
|
||||
UpdateAppearance(ent);
|
||||
}
|
||||
|
||||
private void OnComponentRemove(Entity<PaperLabelComponent> ent, ref ComponentRemove args)
|
||||
{
|
||||
_itemSlots.RemoveItemSlot(ent, ent.Comp.LabelSlot);
|
||||
}
|
||||
|
||||
private void OnExamined(Entity<PaperLabelComponent> 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<PaperComponent>(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<PaperLabelComponent, AppearanceComponent?> 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<PaperLabelTypeComponent>(slot.Item, out var type))
|
||||
_appearance.SetData(ent, PaperLabelVisuals.LabelType, type.PaperType, ent.Comp2);
|
||||
}
|
||||
}
|
||||
@@ -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!;
|
||||
|
||||
@@ -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<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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user