Extracts magic strings from Tag calls (#36305)

* Extracts magic strings from Tag calls

When #36281 gets merged, the `TagSystem` methods will all give warnings. Let's fix those warnings before they even happen!

* Adds missing libraries

* Remove not yet implemented TagSystem changes

* Fix tag spelling error

Genuinely surprised there was only 1!

* Styling and proper type changes

* Styling

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>

---------

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
This commit is contained in:
J
2025-04-05 00:20:19 +00:00
committed by GitHub
parent e58ab56e42
commit af9526197a
36 changed files with 156 additions and 51 deletions

View File

@@ -16,6 +16,7 @@ using Robust.Client.State;
using Robust.Shared.Configuration;
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Client.Verbs
@@ -36,6 +37,8 @@ namespace Content.Client.Verbs
private float _lookupSize;
private static readonly ProtoId<TagPrototype> HideContextMenuTag = "HideContextMenu";
/// <summary>
/// These flags determine what entities the user can see on the context menu.
/// </summary>
@@ -147,7 +150,7 @@ namespace Content.Client.Verbs
for (var i = entities.Count - 1; i >= 0; i--)
{
if (_tagSystem.HasTag(entities[i], "HideContextMenu"))
if (_tagSystem.HasTag(entities[i], HideContextMenuTag))
entities.RemoveSwap(i);
}

View File

@@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Execution;
@@ -52,7 +52,7 @@ public sealed class SuicideCommandTests
name: test version of the material reclaimer
components:
- type: MaterialReclaimer";
private static readonly ProtoId<TagPrototype> CannotSuicideTag = "CannotSuicide";
/// <summary>
/// Run the suicide command in the console
/// Should successfully kill the player and ghost them
@@ -201,7 +201,7 @@ public sealed class SuicideCommandTests
mobStateComp = entManager.GetComponent<MobStateComponent>(player);
});
tagSystem.AddTag(player, "CannotSuicide");
tagSystem.AddTag(player, CannotSuicideTag);
// Check that running the suicide command kills the player
// and properly ghosts them without them being able to return to their body

View File

@@ -50,6 +50,9 @@ public sealed class PlantHolderSystem : EntitySystem
public const float HydroponicsSpeedMultiplier = 1f;
public const float HydroponicsConsumptionMultiplier = 2f;
private static readonly ProtoId<TagPrototype> HoeTag = "Hoe";
private static readonly ProtoId<TagPrototype> PlantSampleTakerTag = "PlantSampleTaker";
public override void Initialize()
{
base.Initialize();
@@ -203,7 +206,7 @@ public sealed class PlantHolderSystem : EntitySystem
return;
}
if (_tagSystem.HasTag(args.Used, "Hoe"))
if (_tagSystem.HasTag(args.Used, HoeTag))
{
args.Handled = true;
if (component.WeedLevel > 0)
@@ -243,7 +246,7 @@ public sealed class PlantHolderSystem : EntitySystem
return;
}
if (_tagSystem.HasTag(args.Used, "PlantSampleTaker"))
if (_tagSystem.HasTag(args.Used, PlantSampleTakerTag))
{
args.Handled = true;
if (component.Seed == null)

View File

@@ -14,6 +14,7 @@ using Content.Shared.Mobs.Systems;
using Content.Shared.Popups;
using Content.Shared.Tag;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
namespace Content.Server.Chat;
@@ -27,6 +28,8 @@ public sealed class SuicideSystem : EntitySystem
[Dependency] private readonly GhostSystem _ghostSystem = default!;
[Dependency] private readonly SharedSuicideSystem _suicide = default!;
private static readonly ProtoId<TagPrototype> CannotSuicideTag = "CannotSuicide";
public override void Initialize()
{
base.Initialize();
@@ -60,7 +63,7 @@ public sealed class SuicideSystem : EntitySystem
// Suicide is considered a fail if the user wasn't able to ghost
// Suiciding with the CannotSuicide tag will ghost the player but not kill the body
if (!suicideGhostEvent.Handled || _tagSystem.HasTag(victim, "CannotSuicide"))
if (!suicideGhostEvent.Handled || _tagSystem.HasTag(victim, CannotSuicideTag))
return false;
var suicideEvent = new SuicideEvent(victim);
@@ -95,7 +98,7 @@ public sealed class SuicideSystem : EntitySystem
// CannotSuicide tag will allow the user to ghost, but also return to their mind
// This is kind of weird, not sure what it applies to?
if (_tagSystem.HasTag(victim, "CannotSuicide"))
if (_tagSystem.HasTag(victim, CannotSuicideTag))
args.CanReturnToBody = true;
if (_ghostSystem.OnGhostAttempt(victim.Comp.Mind.Value, args.CanReturnToBody, mind: mindComponent))

View File

@@ -9,6 +9,7 @@ using Content.Shared.Projectiles;
using Content.Shared.Tag;
using Content.Shared.Weapons.Melee.Events;
using Robust.Shared.Collections;
using Robust.Shared.Prototypes;
namespace Content.Server.Chemistry.EntitySystems;
@@ -24,6 +25,8 @@ public sealed class SolutionInjectOnCollideSystem : EntitySystem
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
[Dependency] private readonly TagSystem _tag = default!;
private static readonly ProtoId<TagPrototype> HardsuitTag = "Hardsuit";
public override void Initialize()
{
base.Initialize();
@@ -93,7 +96,7 @@ public sealed class SolutionInjectOnCollideSystem : EntitySystem
// Yuck, this is way to hardcodey for my tastes
// TODO blocking injection with a hardsuit should probably done with a cancellable event or something
if (!injector.Comp.PierceArmor && _inventory.TryGetSlotEntity(target, "outerClothing", out var suit) && _tag.HasTag(suit.Value, "Hardsuit"))
if (!injector.Comp.PierceArmor && _inventory.TryGetSlotEntity(target, "outerClothing", out var suit) && _tag.HasTag(suit.Value, HardsuitTag))
{
// Only show popup to attacker
if (source != null)

View File

@@ -5,6 +5,7 @@ using Content.Shared.Construction;
using Content.Shared.Tag;
using Robust.Shared.Console;
using Robust.Shared.Map.Components;
using Robust.Shared.Prototypes;
namespace Content.Server.Construction.Commands;
@@ -13,6 +14,10 @@ public sealed class FixRotationsCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entManager = default!;
private static readonly ProtoId<TagPrototype> ForceFixRotationsTag = "ForceFixRotations";
private static readonly ProtoId<TagPrototype> ForceNoFixRotationsTag = "ForceNoFixRotations";
private static readonly ProtoId<TagPrototype> DiagonalTag = "Diagonal";
// ReSharper disable once StringLiteralTypo
public string Command => "fixrotations";
public string Description => "Sets the rotation of all occluders, low walls and windows to south.";
@@ -86,11 +91,11 @@ public sealed class FixRotationsCommand : IConsoleCommand
// cables
valid |= _entManager.HasComponent<CableComponent>(child);
// anything else that might need this forced
valid |= tagSystem.HasTag(child, "ForceFixRotations");
valid |= tagSystem.HasTag(child, ForceFixRotationsTag);
// override
valid &= !tagSystem.HasTag(child, "ForceNoFixRotations");
valid &= !tagSystem.HasTag(child, ForceNoFixRotationsTag);
// remove diagonal entities as well
valid &= !tagSystem.HasTag(child, "Diagonal");
valid &= !tagSystem.HasTag(child, DiagonalTag);
if (!valid)
continue;

View File

@@ -62,6 +62,8 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem
[ValidatePrototypeId<DamageTypePrototype>]
private const string DamageType = "Shock";
private static readonly ProtoId<TagPrototype> WindowTag = "Window";
// Multiply and shift the log scale for shock damage.
private const float RecursiveDamageMultiplier = 0.75f;
private const float RecursiveTimeMultiplier = 0.8f;
@@ -139,7 +141,7 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem
{
foreach (var entity in _entityLookup.GetLocalEntitiesIntersecting(tileRef.Value, flags: LookupFlags.StaticSundries))
{
if (_tag.HasTag(entity, "Window"))
if (_tag.HasTag(entity, WindowTag))
return false;
}
}

View File

@@ -21,6 +21,7 @@ using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Random;
using InventoryComponent = Content.Shared.Inventory.InventoryComponent;
using Robust.Shared.Prototypes;
namespace Content.Server.Flash
{
@@ -39,6 +40,8 @@ namespace Content.Server.Flash
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
private static readonly ProtoId<TagPrototype> TrashTag = "Trash";
public override void Initialize()
{
base.Initialize();
@@ -94,7 +97,7 @@ namespace Content.Server.Flash
if (_charges.IsEmpty(uid, charges))
{
_appearance.SetData(uid, FlashVisuals.Burnt, true);
_tag.AddTag(uid, "Trash");
_tag.AddTag(uid, TrashTag);
_popup.PopupEntity(Loc.GetString("flash-component-becomes-empty"), user);
}

View File

@@ -16,6 +16,7 @@ using Robust.Shared.Audio;
using Robust.Shared.Player;
using Robust.Shared.Timing;
using Content.Server.Chemistry.Containers.EntitySystems;
using Robust.Shared.Prototypes;
// todo: remove this stinky LINQy
namespace Content.Server.Forensics
@@ -33,6 +34,8 @@ namespace Content.Server.Forensics
[Dependency] private readonly ForensicsSystem _forensicsSystem = default!;
[Dependency] private readonly TagSystem _tag = default!;
private static readonly ProtoId<TagPrototype> DNASolutionScannableTag = "DNASolutionScannable";
public override void Initialize()
{
base.Initialize();
@@ -86,7 +89,7 @@ namespace Content.Server.Forensics
scanner.Residues = forensics.Residues.ToList();
}
if (_tag.HasTag(args.Args.Target.Value, "DNASolutionScannable"))
if (_tag.HasTag(args.Args.Target.Value, DNASolutionScannableTag))
{
scanner.SolutionDNAs = _forensicsSystem.GetSolutionsDNA(args.Args.Target.Value);
} else

View File

@@ -9,6 +9,7 @@ using Content.Shared.Mobs.Systems;
using Content.Shared.Survivor.Components;
using Content.Shared.Tag;
using Robust.Server.GameObjects;
using Robust.Shared.Prototypes;
namespace Content.Server.GameTicking.Rules;
@@ -22,6 +23,8 @@ public sealed class SurvivorRuleSystem : GameRuleSystem<SurvivorRuleComponent>
[Dependency] private readonly TagSystem _tag = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
private static readonly ProtoId<TagPrototype> InvalidForSurvivorAntagTag = "InvalidForSurvivorAntag";
public override void Initialize()
{
base.Initialize();
@@ -44,7 +47,7 @@ public sealed class SurvivorRuleSystem : GameRuleSystem<SurvivorRuleComponent>
var mind = humanMind.Owner;
var ent = humanMind.Comp.OwnedEntity.Value;
if (HasComp<SurvivorComponent>(mind) || _tag.HasTag(mind, "InvalidForSurvivorAntag"))
if (HasComp<SurvivorComponent>(mind) || _tag.HasTag(mind, InvalidForSurvivorAntagTag))
continue;
EnsureComp<SurvivorComponent>(mind);

View File

@@ -72,6 +72,8 @@ namespace Content.Server.Ghost
private EntityQuery<GhostComponent> _ghostQuery;
private EntityQuery<PhysicsComponent> _physicsQuery;
private static readonly ProtoId<TagPrototype> AllowGhostShownByEventTag = "AllowGhostShownByEvent";
public override void Initialize()
{
base.Initialize();
@@ -403,7 +405,7 @@ namespace Content.Server.Ghost
var entityQuery = EntityQueryEnumerator<GhostComponent, VisibilityComponent>();
while (entityQuery.MoveNext(out var uid, out var _, out var vis))
{
if (!_tag.HasTag(uid, "AllowGhostShownByEvent"))
if (!_tag.HasTag(uid, AllowGhostShownByEventTag))
continue;
if (visible)

View File

@@ -73,6 +73,9 @@ namespace Content.Server.Kitchen.EntitySystems
[ValidatePrototypeId<EntityPrototype>]
private const string MalfunctionSpark = "Spark";
private static readonly ProtoId<TagPrototype> MetalTag = "Metal";
private static readonly ProtoId<TagPrototype> PlasticTag = "Plastic";
public override void Initialize()
{
base.Initialize();
@@ -550,12 +553,12 @@ namespace Content.Server.Kitchen.EntitySystems
return;
}
if (_tag.HasTag(item, "Metal"))
if (_tag.HasTag(item, MetalTag))
{
malfunctioning = true;
}
if (_tag.HasTag(item, "Plastic"))
if (_tag.HasTag(item, PlasticTag))
{
var junk = Spawn(component.BadRecipeEntityId, Transform(uid).Coordinates);
_container.Insert(junk, component.Storage);

View File

@@ -10,6 +10,7 @@ using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Server.Light.EntitySystems
@@ -24,6 +25,8 @@ namespace Content.Server.Light.EntitySystems
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
private static readonly ProtoId<TagPrototype> TrashTag = "Trash";
public override void Initialize()
{
base.Initialize();
@@ -69,7 +72,7 @@ namespace Content.Server.Light.EntitySystems
_metaData.SetEntityName(ent, Loc.GetString(component.SpentName), meta);
_metaData.SetEntityDescription(ent, Loc.GetString(component.SpentDesc), meta);
_tagSystem.AddTag(ent, "Trash");
_tagSystem.AddTag(ent, TrashTag);
UpdateSounds(ent);
UpdateVisualizer(ent);

View File

@@ -16,6 +16,8 @@ public sealed class MagicSystem : SharedMagicSystem
[Dependency] private readonly TagSystem _tag = default!;
[Dependency] private readonly SharedMindSystem _mind = default!;
private static readonly ProtoId<TagPrototype> InvalidForSurvivorAntagTag = "InvalidForSurvivorAntag";
public override void Initialize()
{
base.Initialize();
@@ -48,8 +50,8 @@ public sealed class MagicSystem : SharedMagicSystem
if (!ev.MakeSurvivorAntagonist)
return;
if (_mind.TryGetMind(ev.Performer, out var mind, out _) && !_tag.HasTag(mind, "InvalidForSurvivorAntag"))
_tag.AddTag(mind, "InvalidForSurvivorAntag");
if (_mind.TryGetMind(ev.Performer, out var mind, out _) && !_tag.HasTag(mind, InvalidForSurvivorAntagTag))
_tag.AddTag(mind, InvalidForSurvivorAntagTag);
EntProtoId survivorRule = "Survivor";

View File

@@ -11,6 +11,7 @@ using Content.Shared.MagicMirror;
using Content.Shared.Popups;
using Content.Shared.Tag;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Prototypes;
namespace Content.Server.MagicMirror;
@@ -27,6 +28,8 @@ public sealed class MagicMirrorSystem : SharedMagicMirrorSystem
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
private static readonly ProtoId<TagPrototype> HidesHairTag = "HidesHair";
public override void Initialize()
{
base.Initialize();
@@ -391,7 +394,7 @@ public sealed class MagicMirrorSystem : SharedMagicMirrorSystem
var slots = _inventory.GetSlotEnumerator((target, inventoryComp), SlotFlags.WITHOUT_POCKET);
while (slots.MoveNext(out var slot))
{
if (slot.ContainedEntity != null && _tagSystem.HasTag(slot.ContainedEntity.Value, "HidesHair"))
if (slot.ContainedEntity != null && _tagSystem.HasTag(slot.ContainedEntity.Value, HidesHairTag))
{
return true;
}

View File

@@ -3,6 +3,7 @@ using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Tag;
using Robust.Shared.Prototypes;
namespace Content.Server.Nutrition.EntitySystems
{
@@ -11,6 +12,8 @@ namespace Content.Server.Nutrition.EntitySystems
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
private static readonly ProtoId<TagPrototype> TrashTag = "Trash";
public override void Initialize()
{
base.Initialize();
@@ -41,11 +44,11 @@ namespace Content.Server.Nutrition.EntitySystems
{
if (solution.Volume <= 0)
{
_tagSystem.AddTag(entity.Owner, "Trash");
_tagSystem.AddTag(entity.Owner, TrashTag);
return;
}
if (_tagSystem.HasTag(entity.Owner, "Trash"))
_tagSystem.RemoveTag(entity.Owner, "Trash");
_tagSystem.RemoveTag(entity.Owner, TrashTag);
}
}
}

View File

@@ -11,6 +11,7 @@ using Robust.Shared.Serialization.Manager;
using Robust.Shared.Utility;
using System.Linq;
using Robust.Server.GameObjects;
using Robust.Shared.Prototypes;
namespace Content.Server.Payload.EntitySystems;
@@ -23,6 +24,8 @@ public sealed class PayloadSystem : EntitySystem
[Dependency] private readonly IComponentFactory _componentFactory = default!;
[Dependency] private readonly ISerializationManager _serializationManager = default!;
private static readonly ProtoId<TagPrototype> PayloadTag = "Payload";
public override void Initialize()
{
base.Initialize();
@@ -44,7 +47,7 @@ public sealed class PayloadSystem : EntitySystem
{
foreach (var entity in container.ContainedEntities)
{
if (_tagSystem.HasTag(entity, "Payload"))
if (_tagSystem.HasTag(entity, PayloadTag))
yield return entity;
}
}
@@ -71,7 +74,7 @@ public sealed class PayloadSystem : EntitySystem
return;
// Ensure we don't enter a trigger-loop
DebugTools.Assert(!_tagSystem.HasTag(uid, "Payload"));
DebugTools.Assert(!_tagSystem.HasTag(uid, PayloadTag));
RaiseLocalEvent(parent, args, false);
}

View File

@@ -1,8 +1,10 @@
using System.Numerics;
using Content.Shared.Procedural;
using Content.Shared.Tag;
using Robust.Shared.Collections;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Components;
using Robust.Shared.Prototypes;
namespace Content.Server.Procedural.DungeonJob;
@@ -12,13 +14,15 @@ public sealed partial class DungeonJob
* Run after the main dungeon generation
*/
private static readonly ProtoId<TagPrototype> WallTag = "Wall";
private bool HasWall(Vector2i tile)
{
var anchored = _maps.GetAnchoredEntitiesEnumerator(_gridUid, _grid, tile);
while (anchored.MoveNext(out var uid))
{
if (_tags.HasTag(uid.Value, "Wall"))
if (_tags.HasTag(uid.Value, WallTag))
return true;
}

View File

@@ -29,6 +29,7 @@ using Robust.Shared.Physics.Components;
using Robust.Shared.Utility;
using Robust.Shared.Map.Components;
using Content.Shared.Whitelist;
using Robust.Shared.Prototypes;
namespace Content.Server.Revenant.EntitySystems;
@@ -44,6 +45,8 @@ public sealed partial class RevenantSystem
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
private static readonly ProtoId<TagPrototype> WindowTag = "Window";
private void InitializeAbilities()
{
SubscribeLocalEvent<RevenantComponent, UserActivateInWorldEvent>(OnInteract);
@@ -253,7 +256,7 @@ public sealed partial class RevenantSystem
foreach (var ent in lookup)
{
//break windows
if (tags.HasComponent(ent) && _tag.HasTag(ent, "Window"))
if (tags.HasComponent(ent) && _tag.HasTag(ent, WindowTag))
{
//hardcoded damage specifiers til i die.
var dspec = new DamageSpecifier();

View File

@@ -21,6 +21,7 @@ using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Utility;
using Content.Shared.UserInterface;
using Robust.Shared.Prototypes;
namespace Content.Server.Shuttles.Systems;
@@ -43,6 +44,8 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
private readonly HashSet<Entity<ShuttleConsoleComponent>> _consoles = new();
private static readonly ProtoId<TagPrototype> CanPilotTag = "CanPilot";
public override void Initialize()
{
base.Initialize();
@@ -168,7 +171,7 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
private bool TryPilot(EntityUid user, EntityUid uid)
{
if (!_tags.HasTag(user, "CanPilot") ||
if (!_tags.HasTag(user, CanPilotTag) ||
!TryComp<ShuttleConsoleComponent>(uid, out var component) ||
!this.IsPowered(uid, EntityManager) ||
!Transform(uid).Anchored ||

View File

@@ -14,6 +14,7 @@ using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Events;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
namespace Content.Server.Singularity.EntitySystems;
@@ -36,6 +37,8 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem
[Dependency] private readonly TagSystem _tagSystem = default!;
#endregion Dependencies
private static readonly ProtoId<TagPrototype> HighRiskItemTag = "HighRiskItem";
private EntityQuery<PhysicsComponent> _physicsQuery;
public override void Initialize()
@@ -127,7 +130,7 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem
return;
if (HasComp<MindContainerComponent>(morsel)
|| _tagSystem.HasTag(morsel, "HighRiskItem")
|| _tagSystem.HasTag(morsel, HighRiskItemTag)
|| HasComp<ContainmentFieldGeneratorComponent>(morsel))
{
_adminLogger.Add(LogType.EntityDelete, LogImpact.High, $"{ToPrettyString(morsel):player} entered the event horizon of {ToPrettyString(hungry)} and was deleted");

View File

@@ -8,6 +8,7 @@ using Content.Shared.Interaction.Components;
using Content.Shared.Storage;
using Content.Shared.Tag;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Server.Tools.Innate;
@@ -22,6 +23,8 @@ public sealed class InnateToolSystem : EntitySystem
[Dependency] private readonly SharedHandsSystem _sharedHandsSystem = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
private static readonly ProtoId<TagPrototype> InnateDontDeleteTag = "InnateDontDelete";
public override void Initialize()
{
base.Initialize();
@@ -76,7 +79,7 @@ public sealed class InnateToolSystem : EntitySystem
{
foreach (var tool in component.ToolUids)
{
if (_tagSystem.HasTag(tool, "InnateDontDelete"))
if (_tagSystem.HasTag(tool, InnateDontDeleteTag))
{
RemComp<UnremoveableComponent>(tool);
}

View File

@@ -36,6 +36,7 @@ using Content.Shared.Traits.Assorted;
using Robust.Shared.Audio.Systems;
using Content.Shared.Ghost.Roles.Components;
using Content.Shared.Tag;
using Robust.Shared.Prototypes;
namespace Content.Server.Zombies;
@@ -61,6 +62,8 @@ public sealed partial class ZombieSystem
[Dependency] private readonly TagSystem _tag = default!;
[Dependency] private readonly NameModifierSystem _nameMod = default!;
private static readonly ProtoId<TagPrototype> InvalidForGlobalSpawnSpellTag = "InvalidForGlobalSpawnSpell";
/// <summary>
/// Handles an entity turning into a zombie when they die or go into crit
/// </summary>
@@ -290,6 +293,6 @@ public sealed partial class ZombieSystem
//Need to prevent them from getting an item, they have no hands.
// Also prevents them from becoming a Survivor. They're undead.
_tag.AddTag(target, "InvalidForGlobalSpawnSpell");
_tag.AddTag(target, InvalidForGlobalSpawnSpellTag);
}
}

View File

@@ -23,6 +23,8 @@ public abstract class SharedChameleonClothingSystem : EntitySystem
[Dependency] private readonly TagSystem _tag = default!;
[Dependency] protected readonly SharedUserInterfaceSystem UI = default!;
private static readonly ProtoId<TagPrototype> WhitelistChameleonTag = "WhitelistChameleon";
public override void Initialize()
{
base.Initialize();
@@ -124,7 +126,7 @@ public abstract class SharedChameleonClothingSystem : EntitySystem
return false;
// check if it is marked as valid chameleon target
if (!proto.TryGetComponent(out TagComponent? tag, _factory) || !_tag.HasTag(tag, "WhitelistChameleon"))
if (!proto.TryGetComponent(out TagComponent? tag, _factory) || !_tag.HasTag(tag, WhitelistChameleonTag))
return false;
if (requiredTag != null && !_tag.HasTag(tag, requiredTag))

View File

@@ -1,7 +1,8 @@
using Content.Shared.Maps;
using Content.Shared.Maps;
using Content.Shared.Tag;
using JetBrains.Annotations;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
namespace Content.Shared.Construction.Conditions
{
@@ -9,6 +10,8 @@ namespace Content.Shared.Construction.Conditions
[DataDefinition]
public sealed partial class NoWindowsInTile : IConstructionCondition
{
private static readonly ProtoId<TagPrototype> WindowTag = "Window";
public bool Condition(EntityUid user, EntityCoordinates location, Direction direction)
{
var entManager = IoCManager.Resolve<IEntityManager>();
@@ -17,7 +20,7 @@ namespace Content.Shared.Construction.Conditions
foreach (var entity in location.GetEntitiesInTile(LookupFlags.Static))
{
if (tagSystem.HasTag(entity, "Window"))
if (tagSystem.HasTag(entity, WindowTag))
return false;
}

View File

@@ -6,6 +6,7 @@ using JetBrains.Annotations;
using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Shared.Construction.Conditions
@@ -14,6 +15,8 @@ namespace Content.Shared.Construction.Conditions
[DataDefinition]
public sealed partial class WallmountCondition : IConstructionCondition
{
private static readonly ProtoId<TagPrototype> WallTag = "Wall";
public bool Condition(EntityUid user, EntityCoordinates location, Direction direction)
{
var entManager = IoCManager.Resolve<IEntityManager>();
@@ -42,7 +45,7 @@ namespace Content.Shared.Construction.Conditions
var tagSystem = entManager.System<TagSystem>();
var userToObjRaycastResults = physics.IntersectRayWithPredicate(entManager.GetComponent<TransformComponent>(user).MapID, rUserToObj, maxLength: length,
predicate: (e) => !tagSystem.HasTag(e, "Wall"));
predicate: (e) => !tagSystem.HasTag(e, WallTag));
var targetWall = userToObjRaycastResults.FirstOrNull();
@@ -53,7 +56,7 @@ namespace Content.Shared.Construction.Conditions
// check that we didn't try to build wallmount that facing another adjacent wall
var rAdjWall = new CollisionRay(objWorldPosition, directionWithOffset.Normalized(), (int) CollisionGroup.Impassable);
var adjWallRaycastResults = physics.IntersectRayWithPredicate(entManager.GetComponent<TransformComponent>(user).MapID, rAdjWall, maxLength: 0.5f,
predicate: e => e == targetWall.Value.HitEntity || !tagSystem.HasTag(e, "Wall"));
predicate: e => e == targetWall.Value.HitEntity || !tagSystem.HasTag(e, WallTag));
return !adjWallRaycastResults.Any();
}

View File

@@ -12,6 +12,7 @@ using Content.Shared.Tag;
using Content.Shared.Verbs;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Robust.Shared.Prototypes;
namespace Content.Shared.Delivery;
@@ -30,6 +31,9 @@ public abstract class SharedDeliverySystem : EntitySystem
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly NameModifierSystem _nameModifier = default!;
private static readonly ProtoId<TagPrototype> TrashTag = "Trash";
private static readonly ProtoId<TagPrototype> RecyclableTag = "Recyclable";
public override void Initialize()
{
base.Initialize();
@@ -129,7 +133,7 @@ public abstract class SharedDeliverySystem : EntitySystem
ent.Comp.IsOpened = true;
_appearance.SetData(ent, DeliveryVisuals.IsTrash, ent.Comp.IsOpened);
_tag.AddTags(ent, "Trash", "Recyclable");
_tag.AddTags(ent, TrashTag, RecyclableTag);
EnsureComp<SpaceGarbageComponent>(ent);
RemComp<StealTargetComponent>(ent); // opened mail should not count for the objective

View File

@@ -5,6 +5,7 @@ using Content.Shared.Damage;
using Content.Shared.Hands.Components;
using Content.Shared.Tag;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
@@ -23,6 +24,8 @@ public abstract partial class SharedDoAfterSystem : EntitySystem
/// </summary>
private static readonly TimeSpan ExcessTime = TimeSpan.FromSeconds(0.5f);
private static readonly ProtoId<TagPrototype> InstantDoAftersTag = "InstantDoAfters";
public override void Initialize()
{
base.Initialize();
@@ -233,7 +236,7 @@ public abstract partial class SharedDoAfterSystem : EntitySystem
// TODO DO AFTER
// Why does this tag exist? Just make this a bool on the component?
if (args.Delay <= TimeSpan.Zero || _tag.HasTag(args.User, "InstantDoAfters"))
if (args.Delay <= TimeSpan.Zero || _tag.HasTag(args.User, InstantDoAftersTag))
{
RaiseDoAfterEvents(doAfter, comp);
// We don't store instant do-afters. This is just a lazy way of hiding them from client-side visuals.

View File

@@ -18,6 +18,7 @@ using Robust.Shared.Network;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Shared.Follower;
@@ -32,6 +33,8 @@ public sealed class FollowerSystem : EntitySystem
[Dependency] private readonly INetManager _netMan = default!;
[Dependency] private readonly ISharedAdminManager _adminManager = default!;
private static readonly ProtoId<TagPrototype> ForceableFollowTag = "ForceableFollow";
public override void Initialize()
{
base.Initialize();
@@ -106,7 +109,7 @@ public sealed class FollowerSystem : EntitySystem
ev.Verbs.Add(verb);
}
if (_tagSystem.HasTag(ev.Target, "ForceableFollow"))
if (_tagSystem.HasTag(ev.Target, ForceableFollowTag))
{
if (!ev.CanAccess || !ev.CanInteract)
return;

View File

@@ -6,12 +6,16 @@ using Content.Shared.Inventory.VirtualItem;
using Content.Shared.Tag;
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
namespace Content.Shared.Hands.EntitySystems;
public abstract partial class SharedHandsSystem
{
[Dependency] private readonly TagSystem _tagSystem = default!;
private static readonly ProtoId<TagPrototype> BypassDropChecksTag = "BypassDropChecks";
private void InitializeDrop()
{
SubscribeLocalEvent<HandsComponent, EntRemovedFromContainerMessage>(HandleEntityRemoved);
@@ -37,7 +41,7 @@ public abstract partial class SharedHandsSystem
private bool ShouldIgnoreRestrictions(EntityUid user)
{
//Checks if the Entity is something that shouldn't care about drop distance or walls ie Aghost
return !_tagSystem.HasTag(user, "BypassDropChecks");
return !_tagSystem.HasTag(user, BypassDropChecksTag);
}
/// <summary>

View File

@@ -7,6 +7,7 @@ using Content.Shared.Tag;
using JetBrains.Annotations;
using Robust.Shared.Containers;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using System.Linq;
namespace Content.Shared.Implants;
@@ -21,6 +22,9 @@ public abstract class SharedSubdermalImplantSystem : EntitySystem
public const string BaseStorageId = "storagebase";
private static readonly ProtoId<TagPrototype> MicroBombTag = "MicroBomb";
private static readonly ProtoId<TagPrototype> MacroBombTag = "MacroBomb";
public override void Initialize()
{
SubscribeLocalEvent<SubdermalImplantComponent, EntGotInsertedIntoContainerMessage>(OnInsert);
@@ -43,11 +47,11 @@ public abstract class SharedSubdermalImplantSystem : EntitySystem
}
//replace micro bomb with macro bomb
if (_container.TryGetContainer(component.ImplantedEntity.Value, ImplanterComponent.ImplantSlotId, out var implantContainer) && _tag.HasTag(uid, "MacroBomb"))
if (_container.TryGetContainer(component.ImplantedEntity.Value, ImplanterComponent.ImplantSlotId, out var implantContainer) && _tag.HasTag(uid, MacroBombTag))
{
foreach (var implant in implantContainer.ContainedEntities)
{
if (_tag.HasTag(implant, "MicroBomb"))
if (_tag.HasTag(implant, MicroBombTag))
{
_container.Remove(implant, implantContainer);
QueueDel(implant);

View File

@@ -37,6 +37,7 @@ using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
@@ -87,6 +88,8 @@ namespace Content.Shared.Interaction
public const float MaxRaycastRange = 100f;
public const string RateLimitKey = "Interaction";
private static readonly ProtoId<TagPrototype> BypassInteractionRangeChecksTag = "BypassInteractionRangeChecks";
public delegate bool Ignored(EntityUid entity);
public override void Initialize()
@@ -318,7 +321,7 @@ namespace Content.Shared.Interaction
{
// This is for Admin/mapping convenience. If ever there are other ghosts that can still interact, this check
// might need to be more selective.
return !_tagSystem.HasTag(user, "BypassInteractionRangeChecks");
return !_tagSystem.HasTag(user, BypassInteractionRangeChecksTag);
}
/// <summary>

View File

@@ -65,6 +65,8 @@ public abstract class SharedMagicSystem : EntitySystem
[Dependency] private readonly SharedMindSystem _mind = default!;
[Dependency] private readonly SharedStunSystem _stun = default!;
private static readonly ProtoId<TagPrototype> InvalidForGlobalSpawnSpellTag = "InvalidForGlobalSpawnSpell";
public override void Initialize()
{
base.Initialize();
@@ -484,7 +486,7 @@ public abstract class SharedMagicSystem : EntitySystem
var ent = human.Comp.OwnedEntity.Value;
if (_tag.HasTag(ent, "InvalidForGlobalSpawnSpell"))
if (_tag.HasTag(ent, InvalidForGlobalSpawnSpellTag))
continue;
var mapCoords = _transform.GetMapCoordinates(ent);

View File

@@ -20,6 +20,7 @@ using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Controllers;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using PullableComponent = Content.Shared.Movement.Pulling.Components.PullableComponent;
@@ -59,6 +60,8 @@ public abstract partial class SharedMoverController : VirtualController
protected EntityQuery<FootstepModifierComponent> FootstepModifierQuery;
protected EntityQuery<MapGridComponent> MapGridQuery;
private static readonly ProtoId<TagPrototype> FootstepSoundTag = "FootstepSound";
/// <summary>
/// <see cref="CCVars.StopSpeed"/>
/// </summary>
@@ -431,7 +434,7 @@ public abstract partial class SharedMoverController : VirtualController
{
sound = null;
if (!CanSound() || !_tags.HasTag(uid, "FootstepSound"))
if (!CanSound() || !_tags.HasTag(uid, FootstepSoundTag))
return false;
var coordinates = xform.Coordinates;

View File

@@ -9,6 +9,7 @@ using Content.Shared.Tag;
using Robust.Shared.Player;
using Robust.Shared.Audio.Systems;
using static Content.Shared.Paper.PaperComponent;
using Robust.Shared.Prototypes;
namespace Content.Shared.Paper;
@@ -23,6 +24,9 @@ public sealed class PaperSystem : EntitySystem
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
private static readonly ProtoId<TagPrototype> WriteIgnoreStampsTag = "WriteIgnoreStamps";
private static readonly ProtoId<TagPrototype> WriteTag = "Write";
public override void Initialize()
{
base.Initialize();
@@ -100,8 +104,8 @@ public sealed class PaperSystem : EntitySystem
private void OnInteractUsing(Entity<PaperComponent> entity, ref InteractUsingEvent args)
{
// only allow editing if there are no stamps or when using a cyberpen
var editable = entity.Comp.StampedBy.Count == 0 || _tagSystem.HasTag(args.Used, "WriteIgnoreStamps");
if (_tagSystem.HasTag(args.Used, "Write"))
var editable = entity.Comp.StampedBy.Count == 0 || _tagSystem.HasTag(args.Used, WriteIgnoreStampsTag);
if (_tagSystem.HasTag(args.Used, WriteTag))
{
if (editable)
{

View File

@@ -51,6 +51,7 @@ public class RCDSystem : EntitySystem
private readonly EntProtoId _instantConstructionFx = "EffectRCDConstruct0";
private readonly ProtoId<RCDPrototype> _deconstructTileProto = "DeconstructTile";
private readonly ProtoId<RCDPrototype> _deconstructLatticeProto = "DeconstructLattice";
private static readonly ProtoId<TagPrototype> CatwalkTag = "Catwalk";
private HashSet<EntityUid> _intersectingEntities = new();
@@ -411,7 +412,7 @@ public class RCDSystem : EntitySystem
if (isWindow && HasComp<SharedCanBuildWindowOnTopComponent>(ent))
continue;
if (isCatwalk && _tags.HasTag(ent, "Catwalk"))
if (isCatwalk && _tags.HasTag(ent, CatwalkTag))
{
if (popMsgs)
_popup.PopupClient(Loc.GetString("rcd-component-cannot-build-on-occupied-tile-message"), uid, user);