Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
77 changes: 0 additions & 77 deletions Content.Client/Backmen/Body/LooseOrganVisualSystem.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using Content.IntegrationTests.Fixtures;
using Content.Shared.Backmen.Body.OrganRelations;
using Content.Shared.Backmen.Body.Systems;
using Content.Shared.Body;
using Content.Shared.Body.Organ;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;

namespace Content.IntegrationTests.Tests.Backmen.Body;

/// <summary>
/// Reattaching a leg from a detached limb bundle must not delete the paired foot.
/// </summary>
[TestFixture]
public sealed class DetachedLegFootReattachTest : GameTest
{
public override PoolSettings PoolSettings => new() { Connected = false, Dirty = true };

[Test]
public async Task ReattachingLegFromDetachedBundle_PreservesFoot()
{
var map = await Pair.CreateTestMap();
NetEntity netPatient = default;
NetEntity netFoot = default;

await Server.WaitAssertion(() =>
{
var bodySys = Server.EntMan.System<BkmBodySharedSystem>();
var organRelations = Server.EntMan.System<OrganRelationInitializerSystem>();

var patient = Server.EntMan.SpawnEntity("MobHuman", map.MapCoords);
var bundle = Server.EntMan.SpawnEntity("BackmenDetachedBody", map.MapCoords);
var leg = Server.EntMan.SpawnEntity("OrganHumanLegLeft", MapCoordinates.Nullspace);
var foot = Server.EntMan.SpawnEntity("OrganHumanFootLeft", MapCoordinates.Nullspace);

Assert.That(bodySys.InsertOrganIntoBody(bundle, leg), Is.True);
Assert.That(bodySys.InsertOrganIntoBody(bundle, foot), Is.True);

organRelations.WireRelationships((bundle, Server.EntMan.GetComponent<BodyComponent>(bundle)));

Assert.That(bodySys.InsertOrganIntoBody(patient, leg), Is.True,
"Leg should transfer from detached bundle to patient.");

Assert.That(Server.EntMan.EntityExists(foot) && !Server.EntMan.IsQueuedForDeletion(foot), Is.True,
"Foot must survive leg removal from detached bundle.");

Assert.That(bodySys.InsertOrganIntoBody(patient, foot), Is.True,
"Foot should transfer from detached bundle to patient.");

netPatient = Server.EntMan.GetNetEntity(patient);
netFoot = Server.EntMan.GetNetEntity(foot);
});

await Server.WaitIdleAsync();

await Server.WaitAssertion(() =>
{
var patient = Server.EntMan.GetEntity(netPatient);
var foot = Server.EntMan.GetEntity(netFoot);
var bodySys = Server.EntMan.System<BodySystem>();

Assert.That(Server.EntMan.EntityExists(foot), Is.True);
Assert.That(bodySys.TryGetOrganByCategory(patient, "FootLeft", out _), Is.True);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Content.IntegrationTests.Fixtures;
using Content.Server.Backmen.Body.Systems;
using Content.Shared.Backmen.Body.OrganRelations;
using Content.Shared.Backmen.Body.Systems;
using Content.Shared.Body;
using Robust.Shared.GameObjects;

namespace Content.IntegrationTests.Tests.Backmen.Body;

/// <summary>
/// Full-body gib must scatter external parts into separate <see cref="BkmDetachedBodyComponent"/> bundles.
/// </summary>
[TestFixture]
public sealed class GibDetachedBodyTest : GameTest
{
public override PoolSettings PoolSettings => new() { Connected = false, Dirty = true };

[Test]
public async Task GibBody_CreatesMultipleDetachedBundles()
{
var map = await Pair.CreateTestMap();

await Server.WaitAssertion(() =>
{
var patient = Server.EntMan.SpawnEntity("MobHuman", map.MapCoords);
var bodySys = Server.EntMan.System<BkmBodySystem>();
bodySys.GibBody(patient, gibOrgans: true);
});

await Server.WaitIdleAsync();

await Server.WaitAssertion(() =>
{
var bundleCount = 0;
var enumerator = Server.EntMan.EntityQueryEnumerator<BkmDetachedBodyComponent>();
while (enumerator.MoveNext(out var bundle))
{
bundleCount++;
Assert.That(Server.EntMan.TryGetComponent(bundle.Owner, out BodyComponent? body) && body!.Organs?.Count > 0,
Is.True,
"Each detached bundle should still contain at least one organ.");
}

Assert.That(bundleCount, Is.GreaterThan(3),
"Human gib should produce a detached bundle per external part, not a single pile.");
});
}
}
Loading
Loading