Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix internals not auto-activating for entities spawned in space #29213

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions Content.IntegrationTests/Tests/Internals/AutoInternalsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using Content.Server.Atmos.EntitySystems;
using Content.Server.Body.Systems;
using Content.Server.Station.Systems;
using Content.Shared.Preferences;
using Content.Shared.Roles.Jobs;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;

namespace Content.IntegrationTests.Tests.Internals;

[TestFixture]
[TestOf(typeof(InternalsSystem))]
public sealed class AutoInternalsTests
{
[Test]
public async Task TestInternalsAutoActivateInSpaceForStationSpawn()
{
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;

var testMap = await pair.CreateTestMap();

var mapMan = server.ResolveDependency<IMapManager>();
var entMan = server.ResolveDependency<IEntityManager>();
var stationSpawning = server.System<StationSpawningSystem>();
var atmos = server.System<AtmosphereSystem>();
var internals = server.System<InternalsSystem>();

await server.WaitAssertion(() =>
{
var profile = new HumanoidCharacterProfile();
var dummy = stationSpawning.SpawnPlayerMob(testMap.GridCoords, new JobComponent()
{
Prototype = "TestInternalsDummy"
}, profile, station: null);

Assert.That(atmos.HasAtmosphere(testMap.Grid), Is.False, "Test map has atmosphere - test needs adjustment!");
Assert.That(internals.AreInternalsWorking(dummy), "Internals did not automatically connect!");

entMan.DeleteEntity(dummy);
});

await pair.CleanReturnAsync();
}

[Test]
public async Task TestInternalsAutoActivateInSpaceForEntitySpawn()
{
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;

var testMap = await pair.CreateTestMap();

var mapMan = server.ResolveDependency<IMapManager>();
var entMan = server.ResolveDependency<IEntityManager>();
var atmos = server.System<AtmosphereSystem>();
var internals = server.System<InternalsSystem>();

await server.WaitAssertion(() =>
{
var dummy = entMan.Spawn("TestInternalsDummyEntity", testMap.MapCoords);

Assert.That(atmos.HasAtmosphere(testMap.Grid), Is.False, "Test map has atmosphere - test needs adjustment!");
Assert.That(internals.AreInternalsWorking(dummy), "Internals did not automatically connect!");

entMan.DeleteEntity(dummy);
});

await pair.CleanReturnAsync();
}

[TestPrototypes]
private const string Prototypes = @"
- type: playTimeTracker
id: PlayTimeInternalsDummy

- type: startingGear
id: InternalsDummyGear
equipment:
mask: ClothingMaskBreath
suitstorage: OxygenTankFilled

- type: job
id: TestInternalsDummy
playTimeTracker: PlayTimeInternalsDummy
startingGear: InternalsDummyGear

- type: entity
id: TestInternalsDummyEntity
parent: MobHuman
components:
- type: Loadout
prototypes: [InternalsDummyGear]
";
}
4 changes: 3 additions & 1 deletion Content.Shared/Clothing/LoadoutSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using Content.Shared.Body.Systems;
using Content.Shared.Clothing.Components;
using Content.Shared.Humanoid;
using Content.Shared.Preferences;
Expand Down Expand Up @@ -27,7 +28,8 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<LoadoutComponent, MapInitEvent>(OnMapInit);
// Wait until the character has all their organs before we give them their loadout
SubscribeLocalEvent<LoadoutComponent, MapInitEvent>(OnMapInit, after: [typeof(SharedBodySystem)]);
}

public static string GetJobPrototype(string? loadout)
Expand Down
Loading