Replace usages of MobObserver and AdminObserver with GameTicker consts (#21814)

This commit is contained in:
DrSmugleaf
2023-11-20 20:27:37 -08:00
committed by GitHub
parent 019d65add8
commit 641b490313
8 changed files with 17 additions and 12 deletions

View File

@@ -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);

View File

@@ -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<MetaDataComponent>(player.AttachedEntity!.Value).EntityPrototype?.ID, Is.Not.EqualTo("AdminObserver"));
Assert.That(entMan.GetComponent<MetaDataComponent>(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<GhostComponent>(player.AttachedEntity), "Player did not become a new ghost");
Assert.That(entMan.GetComponent<MetaDataComponent>(player.AttachedEntity!.Value).EntityPrototype?.ID, Is.EqualTo("AdminObserver"));
Assert.That(entMan.GetComponent<MetaDataComponent>(player.AttachedEntity!.Value).EntityPrototype?.ID, Is.EqualTo(GameTicker.AdminObserverPrototypeName));
});
var mindId = player.ContentData()?.Mind;

View File

@@ -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<MindComponent>(mindId);

View File

@@ -46,7 +46,7 @@ namespace Content.Server.Administration.Commands
var coordinates = player.AttachedEntity != null
? _entities.GetComponent<TransformComponent>(player.AttachedEntity.Value).Coordinates
: EntitySystem.Get<GameTicker>().GetObserverSpawnPoint();
var ghost = _entities.SpawnEntity("AdminObserver", coordinates);
var ghost = _entities.SpawnEntity(GameTicker.AdminObserverPrototypeName, coordinates);
_entities.GetComponent<TransformComponent>(ghost).AttachToGridOrMap();
if (canReturn)

View File

@@ -262,7 +262,7 @@ namespace Content.Server.GameTicking
var xformQuery = GetEntityQuery<TransformComponent>();
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".

View File

@@ -31,6 +31,9 @@ namespace Content.Server.GameTicking
[ValidatePrototypeId<EntityPrototype>]
public const string ObserverPrototypeName = "MobObserver";
[ValidatePrototypeId<EntityPrototype>]
public const string AdminObserverPrototypeName = "AdminObserver";
/// <summary>
/// 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.

View File

@@ -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<MetaDataComponent>(playerEntity).EntityPrototype?.ID != "AdminObserver")
_entities.GetComponent<MetaDataComponent>(playerEntity).EntityPrototype?.ID != GameTicker.AdminObserverPrototypeName)
{
shell.ExecuteCommand("aghost");
}

View File

@@ -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<MindContainerComponent>(entity.Value);
var ghostComponent = Comp<GhostComponent>(entity.Value);
_ghosts.SetCanReturnToBody(ghostComponent, false);