Forbid string literals for SharedToolSystem methods (#38250)
* Forbid string literals for ToolSystem methods * Cleanup violations * Sort usings
This commit is contained in:
@@ -10,6 +10,7 @@ using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.Tools;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Content.Shared.Wires;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -29,6 +30,9 @@ public sealed class WiresSystem : SharedWiresSystem
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly ConstructionSystem _construction = default!;
|
||||
|
||||
private static readonly ProtoId<ToolQualityPrototype> CuttingQuality = "Cutting";
|
||||
private static readonly ProtoId<ToolQualityPrototype> PulsingQuality = "Pulsing";
|
||||
|
||||
// This is where all the wire layouts are stored.
|
||||
[ViewVariables] private readonly Dictionary<string, WireLayout> _layouts = new();
|
||||
|
||||
@@ -443,8 +447,8 @@ public sealed class WiresSystem : SharedWiresSystem
|
||||
if (!IsPanelOpen(uid))
|
||||
return;
|
||||
|
||||
if (Tool.HasQuality(args.Used, "Cutting", tool) ||
|
||||
Tool.HasQuality(args.Used, "Pulsing", tool))
|
||||
if (Tool.HasQuality(args.Used, CuttingQuality, tool) ||
|
||||
Tool.HasQuality(args.Used, PulsingQuality, tool))
|
||||
{
|
||||
if (TryComp(args.User, out ActorComponent? actor))
|
||||
{
|
||||
@@ -623,7 +627,7 @@ public sealed class WiresSystem : SharedWiresSystem
|
||||
switch (action)
|
||||
{
|
||||
case WiresAction.Cut:
|
||||
if (!Tool.HasQuality(toolEntity, "Cutting", tool))
|
||||
if (!Tool.HasQuality(toolEntity, CuttingQuality, tool))
|
||||
{
|
||||
_popupSystem.PopupCursor(Loc.GetString("wires-component-ui-on-receive-message-need-wirecutters"), user);
|
||||
return;
|
||||
@@ -637,7 +641,7 @@ public sealed class WiresSystem : SharedWiresSystem
|
||||
|
||||
break;
|
||||
case WiresAction.Mend:
|
||||
if (!Tool.HasQuality(toolEntity, "Cutting", tool))
|
||||
if (!Tool.HasQuality(toolEntity, CuttingQuality, tool))
|
||||
{
|
||||
_popupSystem.PopupCursor(Loc.GetString("wires-component-ui-on-receive-message-need-wirecutters"), user);
|
||||
return;
|
||||
@@ -651,7 +655,7 @@ public sealed class WiresSystem : SharedWiresSystem
|
||||
|
||||
break;
|
||||
case WiresAction.Pulse:
|
||||
if (!Tool.HasQuality(toolEntity, "Pulsing", tool))
|
||||
if (!Tool.HasQuality(toolEntity, PulsingQuality, tool))
|
||||
{
|
||||
_popupSystem.PopupCursor(Loc.GetString("wires-component-ui-on-receive-message-need-multitool"), user);
|
||||
return;
|
||||
@@ -710,7 +714,7 @@ public sealed class WiresSystem : SharedWiresSystem
|
||||
switch (action)
|
||||
{
|
||||
case WiresAction.Cut:
|
||||
if (!Tool.HasQuality(toolEntity, "Cutting", tool))
|
||||
if (!Tool.HasQuality(toolEntity, CuttingQuality, tool))
|
||||
{
|
||||
_popupSystem.PopupCursor(Loc.GetString("wires-component-ui-on-receive-message-need-wirecutters"), user);
|
||||
break;
|
||||
@@ -731,7 +735,7 @@ public sealed class WiresSystem : SharedWiresSystem
|
||||
UpdateUserInterface(used);
|
||||
break;
|
||||
case WiresAction.Mend:
|
||||
if (!Tool.HasQuality(toolEntity, "Cutting", tool))
|
||||
if (!Tool.HasQuality(toolEntity, CuttingQuality, tool))
|
||||
{
|
||||
_popupSystem.PopupCursor(Loc.GetString("wires-component-ui-on-receive-message-need-wirecutters"), user);
|
||||
break;
|
||||
@@ -752,7 +756,7 @@ public sealed class WiresSystem : SharedWiresSystem
|
||||
UpdateUserInterface(used);
|
||||
break;
|
||||
case WiresAction.Pulse:
|
||||
if (!Tool.HasQuality(toolEntity, "Pulsing", tool))
|
||||
if (!Tool.HasQuality(toolEntity, PulsingQuality, tool))
|
||||
{
|
||||
_popupSystem.PopupCursor(Loc.GetString("wires-component-ui-on-receive-message-need-multitool"), user);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user