diff --git a/Content.Client/Verbs/VerbSystem.cs b/Content.Client/Verbs/VerbSystem.cs index d6513c0a78..92596f9dc0 100644 --- a/Content.Client/Verbs/VerbSystem.cs +++ b/Content.Client/Verbs/VerbSystem.cs @@ -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 HideContextMenuTag = "HideContextMenu"; + /// /// These flags determine what entities the user can see on the context menu. /// @@ -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); } diff --git a/Content.IntegrationTests/Tests/Commands/SuicideCommandTests.cs b/Content.IntegrationTests/Tests/Commands/SuicideCommandTests.cs index cf88f3aacd..94dd98425b 100644 --- a/Content.IntegrationTests/Tests/Commands/SuicideCommandTests.cs +++ b/Content.IntegrationTests/Tests/Commands/SuicideCommandTests.cs @@ -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 CannotSuicideTag = "CannotSuicide"; /// /// 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(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 diff --git a/Content.Server/Botany/Systems/PlantHolderSystem.cs b/Content.Server/Botany/Systems/PlantHolderSystem.cs index 15cb82ef00..5dbafae5af 100644 --- a/Content.Server/Botany/Systems/PlantHolderSystem.cs +++ b/Content.Server/Botany/Systems/PlantHolderSystem.cs @@ -50,6 +50,9 @@ public sealed class PlantHolderSystem : EntitySystem public const float HydroponicsSpeedMultiplier = 1f; public const float HydroponicsConsumptionMultiplier = 2f; + private static readonly ProtoId HoeTag = "Hoe"; + private static readonly ProtoId 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) diff --git a/Content.Server/Chat/SuicideSystem.cs b/Content.Server/Chat/SuicideSystem.cs index 497c9a1fe4..b9a3ede2bd 100644 --- a/Content.Server/Chat/SuicideSystem.cs +++ b/Content.Server/Chat/SuicideSystem.cs @@ -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 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)) diff --git a/Content.Server/Chemistry/EntitySystems/SolutionInjectOnEventSystem.cs b/Content.Server/Chemistry/EntitySystems/SolutionInjectOnEventSystem.cs index f15edcf067..503a0ebde6 100644 --- a/Content.Server/Chemistry/EntitySystems/SolutionInjectOnEventSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/SolutionInjectOnEventSystem.cs @@ -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 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) diff --git a/Content.Server/Construction/Commands/FixRotationsCommand.cs b/Content.Server/Construction/Commands/FixRotationsCommand.cs index 3232f12ed8..807f81b498 100644 --- a/Content.Server/Construction/Commands/FixRotationsCommand.cs +++ b/Content.Server/Construction/Commands/FixRotationsCommand.cs @@ -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 ForceFixRotationsTag = "ForceFixRotations"; + private static readonly ProtoId ForceNoFixRotationsTag = "ForceNoFixRotations"; + private static readonly ProtoId 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(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; diff --git a/Content.Server/Electrocution/ElectrocutionSystem.cs b/Content.Server/Electrocution/ElectrocutionSystem.cs index eb10f8d280..c7adb311d3 100644 --- a/Content.Server/Electrocution/ElectrocutionSystem.cs +++ b/Content.Server/Electrocution/ElectrocutionSystem.cs @@ -62,6 +62,8 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem [ValidatePrototypeId] private const string DamageType = "Shock"; + private static readonly ProtoId 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; } } diff --git a/Content.Server/Flash/FlashSystem.cs b/Content.Server/Flash/FlashSystem.cs index fb449a372c..60c09efaea 100644 --- a/Content.Server/Flash/FlashSystem.cs +++ b/Content.Server/Flash/FlashSystem.cs @@ -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 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); } diff --git a/Content.Server/Forensics/Systems/ForensicScannerSystem.cs b/Content.Server/Forensics/Systems/ForensicScannerSystem.cs index 984334ee8e..f0eb12c34d 100644 --- a/Content.Server/Forensics/Systems/ForensicScannerSystem.cs +++ b/Content.Server/Forensics/Systems/ForensicScannerSystem.cs @@ -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 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 diff --git a/Content.Server/GameTicking/Rules/SurvivorRuleSystem.cs b/Content.Server/GameTicking/Rules/SurvivorRuleSystem.cs index 81ad2b1be7..4990b98b91 100644 --- a/Content.Server/GameTicking/Rules/SurvivorRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/SurvivorRuleSystem.cs @@ -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 [Dependency] private readonly TagSystem _tag = default!; [Dependency] private readonly MobStateSystem _mobState = default!; + private static readonly ProtoId InvalidForSurvivorAntagTag = "InvalidForSurvivorAntag"; + public override void Initialize() { base.Initialize(); @@ -44,7 +47,7 @@ public sealed class SurvivorRuleSystem : GameRuleSystem var mind = humanMind.Owner; var ent = humanMind.Comp.OwnedEntity.Value; - if (HasComp(mind) || _tag.HasTag(mind, "InvalidForSurvivorAntag")) + if (HasComp(mind) || _tag.HasTag(mind, InvalidForSurvivorAntagTag)) continue; EnsureComp(mind); diff --git a/Content.Server/Ghost/GhostSystem.cs b/Content.Server/Ghost/GhostSystem.cs index e7125ee4f2..435584e908 100644 --- a/Content.Server/Ghost/GhostSystem.cs +++ b/Content.Server/Ghost/GhostSystem.cs @@ -72,6 +72,8 @@ namespace Content.Server.Ghost private EntityQuery _ghostQuery; private EntityQuery _physicsQuery; + private static readonly ProtoId AllowGhostShownByEventTag = "AllowGhostShownByEvent"; + public override void Initialize() { base.Initialize(); @@ -403,7 +405,7 @@ namespace Content.Server.Ghost var entityQuery = EntityQueryEnumerator(); while (entityQuery.MoveNext(out var uid, out var _, out var vis)) { - if (!_tag.HasTag(uid, "AllowGhostShownByEvent")) + if (!_tag.HasTag(uid, AllowGhostShownByEventTag)) continue; if (visible) diff --git a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs index 7f0778cbdd..4f71cc4721 100644 --- a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs @@ -73,6 +73,9 @@ namespace Content.Server.Kitchen.EntitySystems [ValidatePrototypeId] private const string MalfunctionSpark = "Spark"; + private static readonly ProtoId MetalTag = "Metal"; + private static readonly ProtoId 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); diff --git a/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs b/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs index b56da84f03..7aacf3e7ad 100644 --- a/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs +++ b/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs @@ -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 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); diff --git a/Content.Server/Magic/MagicSystem.cs b/Content.Server/Magic/MagicSystem.cs index 34c12954c6..dafd88dd5f 100644 --- a/Content.Server/Magic/MagicSystem.cs +++ b/Content.Server/Magic/MagicSystem.cs @@ -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 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"; diff --git a/Content.Server/MagicMirror/MagicMirrorSystem.cs b/Content.Server/MagicMirror/MagicMirrorSystem.cs index f3be03b4b0..37302999ed 100644 --- a/Content.Server/MagicMirror/MagicMirrorSystem.cs +++ b/Content.Server/MagicMirror/MagicMirrorSystem.cs @@ -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 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; } diff --git a/Content.Server/Nutrition/EntitySystems/TrashOnSolutionEmptySystem.cs b/Content.Server/Nutrition/EntitySystems/TrashOnSolutionEmptySystem.cs index b2e12036f9..ea3a8be9cb 100644 --- a/Content.Server/Nutrition/EntitySystems/TrashOnSolutionEmptySystem.cs +++ b/Content.Server/Nutrition/EntitySystems/TrashOnSolutionEmptySystem.cs @@ -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 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); } } } diff --git a/Content.Server/Payload/EntitySystems/PayloadSystem.cs b/Content.Server/Payload/EntitySystems/PayloadSystem.cs index f5159bf223..bf562f747f 100644 --- a/Content.Server/Payload/EntitySystems/PayloadSystem.cs +++ b/Content.Server/Payload/EntitySystems/PayloadSystem.cs @@ -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 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); } diff --git a/Content.Server/Procedural/DungeonJob/DungeonJob.PostGen.cs b/Content.Server/Procedural/DungeonJob/DungeonJob.PostGen.cs index b1c83346d8..84e7563f33 100644 --- a/Content.Server/Procedural/DungeonJob/DungeonJob.PostGen.cs +++ b/Content.Server/Procedural/DungeonJob/DungeonJob.PostGen.cs @@ -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 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; } diff --git a/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs b/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs index 1eb9aabed6..51cbb6d4d5 100644 --- a/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs +++ b/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs @@ -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 WindowTag = "Window"; + private void InitializeAbilities() { SubscribeLocalEvent(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(); diff --git a/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs b/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs index f02ea945d0..478b002e58 100644 --- a/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs +++ b/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs @@ -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> _consoles = new(); + private static readonly ProtoId 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(uid, out var component) || !this.IsPowered(uid, EntityManager) || !Transform(uid).Anchored || diff --git a/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs b/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs index 729328b8bd..68543cc175 100644 --- a/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs +++ b/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs @@ -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 HighRiskItemTag = "HighRiskItem"; + private EntityQuery _physicsQuery; public override void Initialize() @@ -127,7 +130,7 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem return; if (HasComp(morsel) - || _tagSystem.HasTag(morsel, "HighRiskItem") + || _tagSystem.HasTag(morsel, HighRiskItemTag) || HasComp(morsel)) { _adminLogger.Add(LogType.EntityDelete, LogImpact.High, $"{ToPrettyString(morsel):player} entered the event horizon of {ToPrettyString(hungry)} and was deleted"); diff --git a/Content.Server/Tools/Innate/InnateToolSystem.cs b/Content.Server/Tools/Innate/InnateToolSystem.cs index e7e5be38c4..b8d1dd935c 100644 --- a/Content.Server/Tools/Innate/InnateToolSystem.cs +++ b/Content.Server/Tools/Innate/InnateToolSystem.cs @@ -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 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(tool); } diff --git a/Content.Server/Zombies/ZombieSystem.Transform.cs b/Content.Server/Zombies/ZombieSystem.Transform.cs index 47d94984c0..155796481b 100644 --- a/Content.Server/Zombies/ZombieSystem.Transform.cs +++ b/Content.Server/Zombies/ZombieSystem.Transform.cs @@ -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 InvalidForGlobalSpawnSpellTag = "InvalidForGlobalSpawnSpell"; + /// /// Handles an entity turning into a zombie when they die or go into crit /// @@ -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); } } diff --git a/Content.Shared/Clothing/EntitySystems/SharedChameleonClothingSystem.cs b/Content.Shared/Clothing/EntitySystems/SharedChameleonClothingSystem.cs index 725b034766..f996c65fe8 100644 --- a/Content.Shared/Clothing/EntitySystems/SharedChameleonClothingSystem.cs +++ b/Content.Shared/Clothing/EntitySystems/SharedChameleonClothingSystem.cs @@ -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 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)) diff --git a/Content.Shared/Construction/Conditions/NoWindowsInTile.cs b/Content.Shared/Construction/Conditions/NoWindowsInTile.cs index 3ae3b59362..2d37ecebe6 100644 --- a/Content.Shared/Construction/Conditions/NoWindowsInTile.cs +++ b/Content.Shared/Construction/Conditions/NoWindowsInTile.cs @@ -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 WindowTag = "Window"; + public bool Condition(EntityUid user, EntityCoordinates location, Direction direction) { var entManager = IoCManager.Resolve(); @@ -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; } diff --git a/Content.Shared/Construction/Conditions/WallmountCondition.cs b/Content.Shared/Construction/Conditions/WallmountCondition.cs index f1d056165e..f32cc19eea 100644 --- a/Content.Shared/Construction/Conditions/WallmountCondition.cs +++ b/Content.Shared/Construction/Conditions/WallmountCondition.cs @@ -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 WallTag = "Wall"; + public bool Condition(EntityUid user, EntityCoordinates location, Direction direction) { var entManager = IoCManager.Resolve(); @@ -42,7 +45,7 @@ namespace Content.Shared.Construction.Conditions var tagSystem = entManager.System(); var userToObjRaycastResults = physics.IntersectRayWithPredicate(entManager.GetComponent(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(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(); } diff --git a/Content.Shared/Delivery/SharedDeliverySystem.cs b/Content.Shared/Delivery/SharedDeliverySystem.cs index 52c9db40a1..319bf41fce 100644 --- a/Content.Shared/Delivery/SharedDeliverySystem.cs +++ b/Content.Shared/Delivery/SharedDeliverySystem.cs @@ -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 TrashTag = "Trash"; + private static readonly ProtoId 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(ent); RemComp(ent); // opened mail should not count for the objective diff --git a/Content.Shared/DoAfter/SharedDoAfterSystem.cs b/Content.Shared/DoAfter/SharedDoAfterSystem.cs index c246c2844a..9765bac912 100644 --- a/Content.Shared/DoAfter/SharedDoAfterSystem.cs +++ b/Content.Shared/DoAfter/SharedDoAfterSystem.cs @@ -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 /// private static readonly TimeSpan ExcessTime = TimeSpan.FromSeconds(0.5f); + private static readonly ProtoId 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. diff --git a/Content.Shared/Follower/FollowerSystem.cs b/Content.Shared/Follower/FollowerSystem.cs index 243886dbb7..75310a6737 100644 --- a/Content.Shared/Follower/FollowerSystem.cs +++ b/Content.Shared/Follower/FollowerSystem.cs @@ -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 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; diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs index 223c2d4a37..95773697db 100644 --- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs +++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs @@ -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 BypassDropChecksTag = "BypassDropChecks"; + private void InitializeDrop() { SubscribeLocalEvent(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); } /// diff --git a/Content.Shared/Implants/SharedSubdermalImplantSystem.cs b/Content.Shared/Implants/SharedSubdermalImplantSystem.cs index bb166b3c5c..e23357448f 100644 --- a/Content.Shared/Implants/SharedSubdermalImplantSystem.cs +++ b/Content.Shared/Implants/SharedSubdermalImplantSystem.cs @@ -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 MicroBombTag = "MicroBomb"; + private static readonly ProtoId MacroBombTag = "MacroBomb"; + public override void Initialize() { SubscribeLocalEvent(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); diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index 2f09f3e549..ff9f41e1f9 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -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 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); } /// diff --git a/Content.Shared/Magic/SharedMagicSystem.cs b/Content.Shared/Magic/SharedMagicSystem.cs index b502ff2fbb..9a44407e91 100644 --- a/Content.Shared/Magic/SharedMagicSystem.cs +++ b/Content.Shared/Magic/SharedMagicSystem.cs @@ -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 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); diff --git a/Content.Shared/Movement/Systems/SharedMoverController.cs b/Content.Shared/Movement/Systems/SharedMoverController.cs index 76e2f34368..a5c32b2992 100644 --- a/Content.Shared/Movement/Systems/SharedMoverController.cs +++ b/Content.Shared/Movement/Systems/SharedMoverController.cs @@ -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 FootstepModifierQuery; protected EntityQuery MapGridQuery; + private static readonly ProtoId FootstepSoundTag = "FootstepSound"; + /// /// /// @@ -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; diff --git a/Content.Shared/Paper/PaperSystem.cs b/Content.Shared/Paper/PaperSystem.cs index 712133c0e6..6fda16b1f3 100644 --- a/Content.Shared/Paper/PaperSystem.cs +++ b/Content.Shared/Paper/PaperSystem.cs @@ -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 WriteIgnoreStampsTag = "WriteIgnoreStamps"; + private static readonly ProtoId WriteTag = "Write"; + public override void Initialize() { base.Initialize(); @@ -100,8 +104,8 @@ public sealed class PaperSystem : EntitySystem private void OnInteractUsing(Entity 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) { diff --git a/Content.Shared/RCD/Systems/RCDSystem.cs b/Content.Shared/RCD/Systems/RCDSystem.cs index 62ad2f3be0..9e5096c77c 100644 --- a/Content.Shared/RCD/Systems/RCDSystem.cs +++ b/Content.Shared/RCD/Systems/RCDSystem.cs @@ -51,6 +51,7 @@ public class RCDSystem : EntitySystem private readonly EntProtoId _instantConstructionFx = "EffectRCDConstruct0"; private readonly ProtoId _deconstructTileProto = "DeconstructTile"; private readonly ProtoId _deconstructLatticeProto = "DeconstructLattice"; + private static readonly ProtoId CatwalkTag = "Catwalk"; private HashSet _intersectingEntities = new(); @@ -411,7 +412,7 @@ public class RCDSystem : EntitySystem if (isWindow && HasComp(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);