Add description of tool qualities to entity (#32436)
* Add description of tool qualities to entity * LMAO I FORGOT FUCKING FTL FILE * minor cleanup --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
parent
6969906f6c
commit
a968a32e21
|
|
@ -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;
|
||||
|
|
@ -41,6 +42,7 @@ public abstract partial class SharedToolSystem : EntitySystem
|
|||
InitializeTile();
|
||||
InitializeWelder();
|
||||
SubscribeLocalEvent<ToolComponent, ToolDoAfterEvent>(OnDoAfter);
|
||||
SubscribeLocalEvent<ToolComponent, ExaminedEvent>(OnExamine);
|
||||
}
|
||||
|
||||
private void OnDoAfter(EntityUid uid, ToolComponent tool, ToolDoAfterEvent args)
|
||||
|
|
@ -57,6 +59,34 @@ public abstract partial class SharedToolSystem : EntitySystem
|
|||
RaiseLocalEvent((object) ev);
|
||||
}
|
||||
|
||||
private void OnExamine(Entity<ToolComponent> 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<string>();
|
||||
|
||||
// Loop through tool qualities and add localized names to the list
|
||||
foreach (var toolQuality in ent.Comp.Qualities)
|
||||
{
|
||||
if (_protoMan.TryIndex<ToolQualityPrototype>(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)
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
tool-component-qualities = This item can be used for [color=yellow]{ $qualities }[/color].
|
||||
Loading…
Reference in New Issue