modular tool inspection (#683)

* modular tool inspection

* update
This commit is contained in:
A.Ne.
2025-01-05 00:43:51 +04:00
committed by GitHub
parent 945e74b690
commit 9a8f66727f
3 changed files with 41 additions and 0 deletions

View File

@@ -3,9 +3,12 @@ using Content.Shared._CP14.ModularCraft;
using Content.Shared._CP14.ModularCraft.Components;
using Content.Shared._CP14.ModularCraft.Prototypes;
using Content.Shared.Throwing;
using Content.Shared.Examine;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
namespace Content.Server._CP14.ModularCraft;
@@ -17,12 +20,46 @@ public sealed class CP14ModularCraftSystem : CP14SharedModularCraftSystem
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly ItemSystem _item = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CP14ModularCraftStartPointComponent, MapInitEvent>(OnStartPointMapInit);
SubscribeLocalEvent<CP14ModularCraftStartPointComponent, CP14ModularCraftAddPartDoAfter>(OnAddedPart);
SubscribeLocalEvent<CP14ModularCraftStartPointComponent, GetVerbsEvent<ExamineVerb>>(OnVerbExamine);
}
private void OnVerbExamine(Entity<CP14ModularCraftStartPointComponent> ent, ref GetVerbsEvent<ExamineVerb> args)
{
if (!args.CanInteract || !args.CanAccess)
return;
var markup = GetExamine(ent.Comp);
_examine.AddDetailedExamineVerb(
args,
ent.Comp,
markup,
Loc.GetString("cp14-modular-craft-examine"),
"/Textures/Interface/VerbIcons/settings.svg.192dpi.png");
}
private FormattedMessage GetExamine(CP14ModularCraftStartPointComponent comp)
{
var msg = new FormattedMessage();
msg.AddMarkupOrThrow(Loc.GetString("cp14-modular-craft-examine-freeslots"));
foreach (var slot in comp.FreeSlots)
{
if (!_proto.TryIndex(slot, out var slotProto))
continue;
msg.AddMarkupOrThrow("\n - " + Loc.GetString(slotProto.Name));
}
return msg;
}
private void OnAddedPart(Entity<CP14ModularCraftStartPointComponent> ent, ref CP14ModularCraftAddPartDoAfter args)

View File

@@ -0,0 +1,2 @@
cp14-modular-craft-examine = Modular parts
cp14-modular-craft-examine-freeslots = Here you can attach:

View File

@@ -0,0 +1,2 @@
cp14-modular-craft-examine = Модульные части
cp14-modular-craft-examine-freeslots = Сюда можно прикрепить: