diff --git a/Content.Shared/Tools/Systems/SharedToolSystem.cs b/Content.Shared/Tools/Systems/SharedToolSystem.cs index 86b91dcda467..57ed2fc66090 100644 --- a/Content.Shared/Tools/Systems/SharedToolSystem.cs +++ b/Content.Shared/Tools/Systems/SharedToolSystem.cs @@ -1,6 +1,7 @@ using Content.Shared.Administration.Logs; using Content.Shared.Chemistry.EntitySystems; using Content.Shared.DoAfter; +using Content.Shared.Examine; using Content.Shared.Interaction; using Content.Shared.Item.ItemToggle; using Content.Shared.Maps; @@ -42,6 +43,7 @@ public override void Initialize() InitializeTile(); InitializeWelder(); SubscribeLocalEvent(OnDoAfter); + SubscribeLocalEvent(OnExamine); } private void OnDoAfter(EntityUid uid, ToolComponent tool, ToolDoAfterEvent args) @@ -58,6 +60,34 @@ private void OnDoAfter(EntityUid uid, ToolComponent tool, ToolDoAfterEvent args) RaiseLocalEvent((object) ev); } + private void OnExamine(Entity ent, ref ExaminedEvent args) + { + // If the tool has no qualities, exit early + if (ent.Comp.Qualities.Count == 0) + return; + + var message = new FormattedMessage(); + + // Create a list to store tool quality names + var toolQualities = new List(); + + // Loop through tool qualities and add localized names to the list + foreach (var toolQuality in ent.Comp.Qualities) + { + if (_protoMan.TryIndex(toolQuality ?? string.Empty, out var protoToolQuality)) + { + toolQualities.Add(Loc.GetString(protoToolQuality.Name)); + } + } + + // Combine the qualities into a single string and localize the final message + var qualitiesString = string.Join(", ", toolQualities); + + // Add the localized message to the FormattedMessage object + message.AddMarkupPermissive(Loc.GetString("tool-component-qualities", ("qualities", qualitiesString))); + args.PushMessage(message); + } + public void PlayToolSound(EntityUid uid, ToolComponent tool, EntityUid? user) { if (tool.UseSound == null) diff --git a/Resources/Locale/en-US/tools/components/tool-component.ftl b/Resources/Locale/en-US/tools/components/tool-component.ftl new file mode 100644 index 000000000000..0c9e60cdc638 --- /dev/null +++ b/Resources/Locale/en-US/tools/components/tool-component.ftl @@ -0,0 +1 @@ +tool-component-qualities = This item can be used for [color=yellow]{ $qualities }[/color].