Refactoring body system to use containers and general body cleanup (#20202)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Systems;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
@@ -31,6 +32,7 @@ public sealed class SaveLoadReparentTest
|
||||
var maps = server.ResolveDependency<IMapManager>();
|
||||
var mapLoader = entities.System<MapLoaderSystem>();
|
||||
var bodySystem = entities.System<SharedBodySystem>();
|
||||
var containerSystem = entities.System<SharedContainerSystem>();
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
@@ -40,7 +42,7 @@ public sealed class SaveLoadReparentTest
|
||||
|
||||
Assert.That(entities.HasComponent<BodyComponent>(human), Is.True);
|
||||
|
||||
var parts = bodySystem.GetBodyChildren(human).ToArray();
|
||||
var parts = bodySystem.GetBodyChildren(human).Skip(1).ToArray();
|
||||
var organs = bodySystem.GetBodyOrgans(human).ToArray();
|
||||
|
||||
Assert.Multiple(() =>
|
||||
@@ -54,9 +56,17 @@ public sealed class SaveLoadReparentTest
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(component.Body, Is.EqualTo(human));
|
||||
Assert.That(component.ParentSlot, Is.Not.Null);
|
||||
Assert.That(component.ParentSlot.Parent, Is.Not.EqualTo(default(EntityUid)));
|
||||
Assert.That(component.ParentSlot.Child, Is.EqualTo(id));
|
||||
Assert.That(component.Body, Is.Not.Null);
|
||||
var parent = bodySystem.GetParentPartOrNull(id);
|
||||
Assert.That(parent, Is.Not.EqualTo(default(EntityUid)));
|
||||
if (!bodySystem.IsPartRoot(component.Body.Value, id, null, component))
|
||||
{
|
||||
Assert.That(parent, Is.Not.Null);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.That(parent, Is.Null);
|
||||
}
|
||||
});
|
||||
|
||||
foreach (var (slotId, slot) in component.Children)
|
||||
@@ -64,19 +74,22 @@ public sealed class SaveLoadReparentTest
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(slot.Id, Is.EqualTo(slotId));
|
||||
Assert.That(slot.Parent, Is.Not.EqualTo(default(EntityUid)));
|
||||
var container =
|
||||
containerSystem.GetContainer(id, SharedBodySystem.GetPartSlotContainerId(slotId));
|
||||
Assert.That(container.ContainedEntities, Is.Not.Empty);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var (id, component) in organs)
|
||||
{
|
||||
var parent = bodySystem.GetParentPartOrNull(id);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(component.Body, Is.EqualTo(human));
|
||||
Assert.That(component.ParentSlot, Is.Not.Null);
|
||||
Assert.That(component.ParentSlot.Parent, Is.Not.EqualTo(default(EntityUid)));
|
||||
Assert.That(component.ParentSlot.Child, Is.EqualTo(id));
|
||||
Assert.That(parent, Is.Not.Null);
|
||||
Assert.That(parent.Value, Is.Not.EqualTo(default(EntityUid)));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -115,7 +128,7 @@ public sealed class SaveLoadReparentTest
|
||||
foreach (var (uid, body) in query)
|
||||
{
|
||||
human = uid;
|
||||
parts = bodySystem.GetBodyChildren(human).ToArray();
|
||||
parts = bodySystem.GetBodyChildren(human).Skip(1).ToArray();
|
||||
organs = bodySystem.GetBodyOrgans(human).ToArray();
|
||||
|
||||
Assert.Multiple(() =>
|
||||
@@ -126,12 +139,13 @@ public sealed class SaveLoadReparentTest
|
||||
|
||||
foreach (var (id, component) in parts)
|
||||
{
|
||||
var parent = bodySystem.GetParentPartOrNull(id);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(component.Body, Is.EqualTo(human));
|
||||
Assert.That(component.ParentSlot, Is.Not.Null);
|
||||
Assert.That(component.ParentSlot.Parent, Is.Not.EqualTo(default(EntityUid)));
|
||||
Assert.That(component.ParentSlot.Child, Is.EqualTo(id));
|
||||
Assert.That(parent, Is.Not.Null);
|
||||
Assert.That(parent.Value, Is.Not.EqualTo(default(EntityUid)));
|
||||
});
|
||||
|
||||
foreach (var (slotId, slot) in component.Children)
|
||||
@@ -139,19 +153,22 @@ public sealed class SaveLoadReparentTest
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(slot.Id, Is.EqualTo(slotId));
|
||||
Assert.That(slot.Parent, Is.Not.EqualTo(default(EntityUid)));
|
||||
var container =
|
||||
containerSystem.GetContainer(id, SharedBodySystem.GetPartSlotContainerId(slotId));
|
||||
Assert.That(container.ContainedEntities, Is.Not.Empty);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var (id, component) in organs)
|
||||
{
|
||||
var parent = bodySystem.GetParentPartOrNull(id);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(component.Body, Is.EqualTo(human));
|
||||
Assert.That(component.ParentSlot, Is.Not.Null);
|
||||
Assert.That(component.ParentSlot.Parent, Is.Not.EqualTo(default(EntityUid)));
|
||||
Assert.That(component.ParentSlot.Child, Is.EqualTo(id));
|
||||
Assert.That(parent, Is.Not.Null);
|
||||
Assert.That(parent.Value, Is.Not.EqualTo(default(EntityUid)));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user