Add prediction to hand labeler labels (#25869)
Added prediction to labels
This commit is contained in:
7
Content.Client/Labels/EntitySystems/LabelSystem.cs
Normal file
7
Content.Client/Labels/EntitySystems/LabelSystem.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
using Content.Shared.Labels.EntitySystems;
|
||||||
|
|
||||||
|
namespace Content.Client.Labels;
|
||||||
|
|
||||||
|
public sealed partial class LabelSystem : SharedLabelSystem
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -1,17 +1,11 @@
|
|||||||
using Content.Server.Administration.Logs;
|
using Content.Server.Administration.Logs;
|
||||||
using Content.Server.Chemistry.Components;
|
using Content.Server.Chemistry.Components;
|
||||||
using Content.Server.Chemistry.Containers.EntitySystems;
|
using Content.Server.Chemistry.Containers.EntitySystems;
|
||||||
using Content.Server.Nutrition.Components;
|
|
||||||
using Content.Server.Nutrition.EntitySystems;
|
using Content.Server.Nutrition.EntitySystems;
|
||||||
using Content.Server.Labels.Components;
|
|
||||||
using Content.Server.Chemistry;
|
|
||||||
using Content.Shared.Chemistry;
|
using Content.Shared.Chemistry;
|
||||||
using Content.Shared.Chemistry.Components.SolutionManager;
|
|
||||||
using Content.Shared.Chemistry.Dispenser;
|
using Content.Shared.Chemistry.Dispenser;
|
||||||
using Content.Shared.Chemistry.EntitySystems;
|
using Content.Shared.Chemistry.EntitySystems;
|
||||||
using Content.Shared.Chemistry.Reagent;
|
|
||||||
using Content.Shared.Containers.ItemSlots;
|
using Content.Shared.Containers.ItemSlots;
|
||||||
using Content.Shared.Database;
|
|
||||||
using Content.Shared.FixedPoint;
|
using Content.Shared.FixedPoint;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.Audio;
|
using Robust.Server.Audio;
|
||||||
@@ -19,7 +13,7 @@ using Robust.Server.GameObjects;
|
|||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using System.Linq;
|
using Content.Shared.Labels.Components;
|
||||||
|
|
||||||
namespace Content.Server.Chemistry.EntitySystems
|
namespace Content.Server.Chemistry.EntitySystems
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
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; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,10 +3,10 @@ using Content.Server.Paper;
|
|||||||
using Content.Shared.Containers.ItemSlots;
|
using Content.Shared.Containers.ItemSlots;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.Labels;
|
using Content.Shared.Labels;
|
||||||
|
using Content.Shared.Labels.Components;
|
||||||
|
using Content.Shared.Labels.EntitySystems;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.GameObjects;
|
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.Utility;
|
|
||||||
|
|
||||||
namespace Content.Server.Labels
|
namespace Content.Server.Labels
|
||||||
{
|
{
|
||||||
@@ -14,7 +14,7 @@ namespace Content.Server.Labels
|
|||||||
/// A system that lets players see the contents of a label on an object.
|
/// A system that lets players see the contents of a label on an object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class LabelSystem : EntitySystem
|
public sealed class LabelSystem : SharedLabelSystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!;
|
[Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!;
|
||||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||||
@@ -26,7 +26,6 @@ namespace Content.Server.Labels
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<LabelComponent, ExaminedEvent>(OnExamine);
|
|
||||||
SubscribeLocalEvent<LabelComponent, MapInitEvent>(OnLabelCompMapInit);
|
SubscribeLocalEvent<LabelComponent, MapInitEvent>(OnLabelCompMapInit);
|
||||||
SubscribeLocalEvent<PaperLabelComponent, ComponentInit>(OnComponentInit);
|
SubscribeLocalEvent<PaperLabelComponent, ComponentInit>(OnComponentInit);
|
||||||
SubscribeLocalEvent<PaperLabelComponent, ComponentRemove>(OnComponentRemove);
|
SubscribeLocalEvent<PaperLabelComponent, ComponentRemove>(OnComponentRemove);
|
||||||
@@ -38,7 +37,10 @@ namespace Content.Server.Labels
|
|||||||
private void OnLabelCompMapInit(EntityUid uid, LabelComponent component, MapInitEvent args)
|
private void OnLabelCompMapInit(EntityUid uid, LabelComponent component, MapInitEvent args)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(component.CurrentLabel))
|
if (!string.IsNullOrEmpty(component.CurrentLabel))
|
||||||
|
{
|
||||||
component.CurrentLabel = Loc.GetString(component.CurrentLabel);
|
component.CurrentLabel = Loc.GetString(component.CurrentLabel);
|
||||||
|
Dirty(uid, component);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -65,6 +67,8 @@ namespace Content.Server.Labels
|
|||||||
label.CurrentLabel = null;
|
label.CurrentLabel = null;
|
||||||
label.OriginalName = null;
|
label.OriginalName = null;
|
||||||
|
|
||||||
|
Dirty(uid, label);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,6 +76,8 @@ namespace Content.Server.Labels
|
|||||||
label.OriginalName ??= metadata.EntityName;
|
label.OriginalName ??= metadata.EntityName;
|
||||||
label.CurrentLabel = text;
|
label.CurrentLabel = text;
|
||||||
_metaData.SetEntityName(uid, $"{label.OriginalName} ({text})", metadata);
|
_metaData.SetEntityName(uid, $"{label.OriginalName} ({text})", metadata);
|
||||||
|
|
||||||
|
Dirty(uid, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnComponentInit(EntityUid uid, PaperLabelComponent component, ComponentInit args)
|
private void OnComponentInit(EntityUid uid, PaperLabelComponent component, ComponentInit args)
|
||||||
@@ -89,19 +95,6 @@ namespace Content.Server.Labels
|
|||||||
_itemSlotsSystem.RemoveItemSlot(uid, component.LabelSlot);
|
_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)
|
private void OnExamined(EntityUid uid, PaperLabelComponent comp, ExaminedEvent args)
|
||||||
{
|
{
|
||||||
if (comp.LabelSlot.Item is not {Valid: true} item)
|
if (comp.LabelSlot.Item is not {Valid: true} item)
|
||||||
|
|||||||
24
Content.Shared/Labels/Components/LabelComponent.cs
Normal file
24
Content.Shared/Labels/Components/LabelComponent.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
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; }
|
||||||
|
}
|
||||||
28
Content.Shared/Labels/EntitySystems/SharedLabelSystem.cs
Normal file
28
Content.Shared/Labels/EntitySystems/SharedLabelSystem.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user