Slight mind test cleanup (#17521)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#nullable enable
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Ghost.Roles;
|
||||
using Content.Server.Ghost.Roles.Components;
|
||||
@@ -16,12 +17,7 @@ public sealed class GhostRoleTests
|
||||
{
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
id: GhostRoleTestEntity_Player
|
||||
components:
|
||||
- type: MindContainer
|
||||
|
||||
- type: entity
|
||||
id: GhostRoleTestEntity_Role
|
||||
id: GhostRoleTestEntity
|
||||
components:
|
||||
- type: MindContainer
|
||||
- type: GhostRole
|
||||
@@ -42,36 +38,29 @@ public sealed class GhostRoleTests
|
||||
var entMan = server.ResolveDependency<IEntityManager>();
|
||||
var sPlayerMan = server.ResolveDependency<Robust.Server.Player.IPlayerManager>();
|
||||
var conHost = client.ResolveDependency<IConsoleHost>();
|
||||
var cPlayerMan = client.ResolveDependency<Robust.Client.Player.IPlayerManager>();
|
||||
var mindSystem = entMan.System<MindSystem>();
|
||||
|
||||
// Get player data
|
||||
if (cPlayerMan.LocalPlayer?.Session == null)
|
||||
Assert.Fail("No player");
|
||||
|
||||
var clientSession = cPlayerMan.LocalPlayer!.Session!;
|
||||
var session = sPlayerMan.GetSessionByUserId(clientSession.UserId);
|
||||
var session = sPlayerMan.ServerSessions.Single();
|
||||
|
||||
// Spawn player entity & attach
|
||||
EntityUid originalMob = default;
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
originalMob = entMan.SpawnEntity("GhostRoleTestEntity_Player", MapCoordinates.Nullspace);
|
||||
originalMob = entMan.SpawnEntity(null, MapCoordinates.Nullspace);
|
||||
mindSystem.TransferTo(session.ContentData()!.Mind!, originalMob, true);
|
||||
});
|
||||
|
||||
// Check player got attached.
|
||||
await PoolManager.RunTicksSync(pairTracker.Pair, 10);
|
||||
Assert.That(cPlayerMan.LocalPlayer.ControlledEntity, Is.EqualTo(originalMob));
|
||||
Assert.That(session.AttachedEntity, Is.EqualTo(originalMob));
|
||||
|
||||
// Use the ghost command
|
||||
conHost.ExecuteCommand("ghost");
|
||||
await PoolManager.RunTicksSync(pairTracker.Pair, 10);
|
||||
Assert.That(cPlayerMan.LocalPlayer.ControlledEntity, Is.Not.EqualTo(originalMob));
|
||||
Assert.That(session.AttachedEntity, Is.Not.EqualTo(originalMob));
|
||||
|
||||
// Spawn ghost takeover entity.
|
||||
EntityUid ghostRole = default;
|
||||
await server.WaitPost(() => ghostRole = entMan.SpawnEntity("GhostRoleTestEntity_Role", MapCoordinates.Nullspace));
|
||||
await server.WaitPost(() => ghostRole = entMan.SpawnEntity("GhostRoleTestEntity", MapCoordinates.Nullspace));
|
||||
|
||||
// Take the ghost role
|
||||
await server.WaitPost(() =>
|
||||
@@ -82,13 +71,13 @@ public sealed class GhostRoleTests
|
||||
|
||||
// Check player got attached to ghost role.
|
||||
await PoolManager.RunTicksSync(pairTracker.Pair, 10);
|
||||
Assert.That(cPlayerMan.LocalPlayer.ControlledEntity, Is.EqualTo(ghostRole));
|
||||
Assert.That(session.AttachedEntity, Is.EqualTo(ghostRole));
|
||||
|
||||
// Ghost again.
|
||||
conHost.ExecuteCommand("ghost");
|
||||
await PoolManager.RunTicksSync(pairTracker.Pair, 10);
|
||||
Assert.That(cPlayerMan.LocalPlayer.ControlledEntity, Is.Not.EqualTo(originalMob));
|
||||
Assert.That(cPlayerMan.LocalPlayer.ControlledEntity, Is.Not.EqualTo(ghostRole));
|
||||
Assert.That(session.AttachedEntity, Is.Not.EqualTo(originalMob));
|
||||
Assert.That(session.AttachedEntity, Is.Not.EqualTo(ghostRole));
|
||||
|
||||
// Next, control the original entity again:
|
||||
await server.WaitPost(() =>
|
||||
@@ -96,7 +85,7 @@ public sealed class GhostRoleTests
|
||||
mindSystem.TransferTo(session.ContentData()!.Mind!, originalMob, true);
|
||||
});
|
||||
await PoolManager.RunTicksSync(pairTracker.Pair, 10);
|
||||
Assert.That(cPlayerMan.LocalPlayer.ControlledEntity, Is.EqualTo(originalMob));
|
||||
Assert.That(session.AttachedEntity, Is.EqualTo(originalMob));
|
||||
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user