From 641b4903135a107f0cb1c1cb78bab8c1843dab67 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Mon, 20 Nov 2023 20:27:37 -0800 Subject: [PATCH] Replace usages of MobObserver and AdminObserver with GameTicker consts (#21814) --- Content.IntegrationTests/Tests/FollowerSystemTest.cs | 5 +++-- .../Tests/Minds/MindTests.EntityDeletion.cs | 8 ++++---- Content.IntegrationTests/Tests/Minds/MindTests.Helpers.cs | 4 ++-- Content.Server/Administration/Commands/AGhost.cs | 2 +- Content.Server/GameTicking/GameTicker.GamePreset.cs | 2 +- Content.Server/GameTicking/GameTicker.Spawning.cs | 3 +++ Content.Server/Mapping/MappingCommand.cs | 3 ++- Content.Server/Mind/MindSystem.cs | 2 +- 8 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Content.IntegrationTests/Tests/FollowerSystemTest.cs b/Content.IntegrationTests/Tests/FollowerSystemTest.cs index ddd5c7a3f0..4d308c6d91 100644 --- a/Content.IntegrationTests/Tests/FollowerSystemTest.cs +++ b/Content.IntegrationTests/Tests/FollowerSystemTest.cs @@ -1,3 +1,4 @@ +using Content.Server.GameTicking; using Content.Shared.Follower; using Robust.Shared.GameObjects; using Robust.Shared.Log; @@ -31,11 +32,11 @@ public sealed class FollowerSystemTest var map = mapMan.CreateMap(); // Spawn an observer to be followed. - var followed = entMan.SpawnEntity("MobObserver", new MapCoordinates(0, 0, map)); + var followed = entMan.SpawnEntity(GameTicker.ObserverPrototypeName, new MapCoordinates(0, 0, map)); logger.Info($"Spawned followed observer: {entMan.ToPrettyString(followed)}"); // Spawn an observer to follow another observer. - var follower = entMan.SpawnEntity("MobObserver", new MapCoordinates(0, 0, map)); + var follower = entMan.SpawnEntity(GameTicker.ObserverPrototypeName, new MapCoordinates(0, 0, map)); logger.Info($"Spawned follower observer: {entMan.ToPrettyString(follower)}"); followerSystem.StartFollowingEntity(follower, followed); diff --git a/Content.IntegrationTests/Tests/Minds/MindTests.EntityDeletion.cs b/Content.IntegrationTests/Tests/Minds/MindTests.EntityDeletion.cs index a67a45ecb4..2ebe750f98 100644 --- a/Content.IntegrationTests/Tests/Minds/MindTests.EntityDeletion.cs +++ b/Content.IntegrationTests/Tests/Minds/MindTests.EntityDeletion.cs @@ -1,5 +1,5 @@ using System.Linq; -using Content.Server.Players; +using Content.Server.GameTicking; using Content.Shared.Ghost; using Content.Shared.Mind; using Content.Shared.Players; @@ -173,7 +173,7 @@ public sealed partial class MindTests EntityUid ghost = default!; await server.WaitAssertion(() => { - ghost = entMan.SpawnEntity("MobObserver", MapCoordinates.Nullspace); + ghost = entMan.SpawnEntity(GameTicker.ObserverPrototypeName, MapCoordinates.Nullspace); mindSystem.Visit(mind.Id, ghost); }); @@ -224,7 +224,7 @@ public sealed partial class MindTests var ghost = await BecomeGhost(pair); // Player is a normal ghost (not admin ghost). - Assert.That(entMan.GetComponent(player.AttachedEntity!.Value).EntityPrototype?.ID, Is.Not.EqualTo("AdminObserver")); + Assert.That(entMan.GetComponent(player.AttachedEntity!.Value).EntityPrototype?.ID, Is.Not.EqualTo(GameTicker.AdminObserverPrototypeName)); // Try to become an admin ghost await server.WaitAssertion(() => serverConsole.ExecuteCommand(player, "aghost")); @@ -235,7 +235,7 @@ public sealed partial class MindTests { Assert.That(player.AttachedEntity, Is.Not.EqualTo(ghost), "Player is still attached to the old ghost"); Assert.That(entMan.HasComponent(player.AttachedEntity), "Player did not become a new ghost"); - Assert.That(entMan.GetComponent(player.AttachedEntity!.Value).EntityPrototype?.ID, Is.EqualTo("AdminObserver")); + Assert.That(entMan.GetComponent(player.AttachedEntity!.Value).EntityPrototype?.ID, Is.EqualTo(GameTicker.AdminObserverPrototypeName)); }); var mindId = player.ContentData()?.Mind; diff --git a/Content.IntegrationTests/Tests/Minds/MindTests.Helpers.cs b/Content.IntegrationTests/Tests/Minds/MindTests.Helpers.cs index d6b30d60a0..428380631d 100644 --- a/Content.IntegrationTests/Tests/Minds/MindTests.Helpers.cs +++ b/Content.IntegrationTests/Tests/Minds/MindTests.Helpers.cs @@ -1,7 +1,7 @@ using System.Linq; using Content.IntegrationTests.Pair; +using Content.Server.GameTicking; using Content.Server.Mind; -using Content.Server.Players; using Content.Shared.Ghost; using Content.Shared.Mind; using Content.Shared.Players; @@ -78,7 +78,7 @@ public sealed partial class MindTests await pair.Server.WaitAssertion(() => { var oldUid = player.AttachedEntity; - ghostUid = entMan.SpawnEntity("MobObserver", MapCoordinates.Nullspace); + ghostUid = entMan.SpawnEntity(GameTicker.ObserverPrototypeName, MapCoordinates.Nullspace); mindId = mindSys.GetMind(player.UserId)!.Value; Assert.That(mindId, Is.Not.EqualTo(default(EntityUid))); mind = entMan.GetComponent(mindId); diff --git a/Content.Server/Administration/Commands/AGhost.cs b/Content.Server/Administration/Commands/AGhost.cs index 2d1a15a0be..d541b1c884 100644 --- a/Content.Server/Administration/Commands/AGhost.cs +++ b/Content.Server/Administration/Commands/AGhost.cs @@ -46,7 +46,7 @@ namespace Content.Server.Administration.Commands var coordinates = player.AttachedEntity != null ? _entities.GetComponent(player.AttachedEntity.Value).Coordinates : EntitySystem.Get().GetObserverSpawnPoint(); - var ghost = _entities.SpawnEntity("AdminObserver", coordinates); + var ghost = _entities.SpawnEntity(GameTicker.AdminObserverPrototypeName, coordinates); _entities.GetComponent(ghost).AttachToGridOrMap(); if (canReturn) diff --git a/Content.Server/GameTicking/GameTicker.GamePreset.cs b/Content.Server/GameTicking/GameTicker.GamePreset.cs index 2d7539bd0f..4ede91babc 100644 --- a/Content.Server/GameTicking/GameTicker.GamePreset.cs +++ b/Content.Server/GameTicking/GameTicker.GamePreset.cs @@ -262,7 +262,7 @@ namespace Content.Server.GameTicking var xformQuery = GetEntityQuery(); var coords = _transform.GetMoverCoordinates(position, xformQuery); - var ghost = Spawn("MobObserver", coords); + var ghost = Spawn(ObserverPrototypeName, coords); // Try setting the ghost entity name to either the character name or the player name. // If all else fails, it'll default to the default entity prototype name, "observer". diff --git a/Content.Server/GameTicking/GameTicker.Spawning.cs b/Content.Server/GameTicking/GameTicker.Spawning.cs index 81b8c6e5f6..1a86d9fef4 100644 --- a/Content.Server/GameTicking/GameTicker.Spawning.cs +++ b/Content.Server/GameTicking/GameTicker.Spawning.cs @@ -31,6 +31,9 @@ namespace Content.Server.GameTicking [ValidatePrototypeId] public const string ObserverPrototypeName = "MobObserver"; + [ValidatePrototypeId] + public const string AdminObserverPrototypeName = "AdminObserver"; + /// /// How many players have joined the round through normal methods. /// Useful for game rules to look at. Doesn't count observers, people in lobby, etc. diff --git a/Content.Server/Mapping/MappingCommand.cs b/Content.Server/Mapping/MappingCommand.cs index d72a5c4178..08ba0de833 100644 --- a/Content.Server/Mapping/MappingCommand.cs +++ b/Content.Server/Mapping/MappingCommand.cs @@ -3,6 +3,7 @@ using System.Linq; using Content.Server.Administration; +using Content.Server.GameTicking; using Content.Shared.Administration; using Content.Shared.CCVar; using Robust.Server.Player; @@ -111,7 +112,7 @@ namespace Content.Server.Mapping // map successfully created. run misc helpful mapping commands if (player.AttachedEntity is { Valid: true } playerEntity && - _entities.GetComponent(playerEntity).EntityPrototype?.ID != "AdminObserver") + _entities.GetComponent(playerEntity).EntityPrototype?.ID != GameTicker.AdminObserverPrototypeName) { shell.ExecuteCommand("aghost"); } diff --git a/Content.Server/Mind/MindSystem.cs b/Content.Server/Mind/MindSystem.cs index 23ef89dd86..4623c07052 100644 --- a/Content.Server/Mind/MindSystem.cs +++ b/Content.Server/Mind/MindSystem.cs @@ -250,7 +250,7 @@ public sealed class MindSystem : SharedMindSystem ? _gameTicker.GetObserverSpawnPoint().ToMap(EntityManager, _transform) : Transform(mind.OwnedEntity.Value).MapPosition; - entity = Spawn("MobObserver", position); + entity = Spawn(GameTicker.ObserverPrototypeName, position); component = EnsureComp(entity.Value); var ghostComponent = Comp(entity.Value); _ghosts.SetCanReturnToBody(ghostComponent, false); -- 2.51.2