mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
* Reapply "Nubody Merge" (#5807) This reverts commitd62f7cef10. * Revert "Nubody Merge (#5670)" This reverts commitb465cfb3fd. * Revert "IPC fibers (#4968)" This reverts commitc2b42211f0. * Revert "IPC Polymorph fix (#4545)" This reverts commitfa03d8c655. * Revert "fix IPC not having humanoid emotes (#4445)" This reverts commit216fdf999f. * Revert "ipc heat/cold (#4306)" This reverts commitfafd5cf816. * Revert "ipc cables (#4283)" This reverts commit54958039a1. * Revert "feat: ipcs now have dynamic power draw based off movement speed (#3917)" This reverts commit71e8b7e64b. * Revert "fix ipcs not being able to disarm (#3374)" This reverts commit764c4dcf54. * Revert "make steel heal caustic for ipcs (#3206)" This reverts commit450ac82550. * Revert "add missing ipc survival boxes (#3065)" This reverts commit888c9cdb00. * Revert "make borgs use ipc repairing (#3064)" This reverts commitf77a49dd0b. * Revert "Update hud.yml to add ipcs to diagnostic hud (#3019)" This reverts commit7220643531. * Revert "Tweak IPCs (#2979)" This reverts commit98b47476de. * Revert "fix nukies ipc test fail (#2957)" This reverts commit4a1acbf863. * Revert "fix ipc nukies not getting comms (#2884)" This reverts commit8a2254770e. * Revert "fix ipc encryption key mispredict (#2879)" This reverts commitf08726efc1. * Revert "Merge pull request #2800 from Spielern/port-ipc" This reverts commit822fa4312c, reversing changes made tofe4c23c702. * Remove and Fix rest of IPC Hangons causing crashes * Integration test Errors * Expand migration file with removed IPC stuff * IPC Leg was found and migrated to naught * Revert "Merge pull request #2542 from deltanedas/shitmed-ops" This reverts commit83a8002922, reversing changes made tobaa89b0052. * Revert "Set up surgical augments infrastructure & add tool panel augments (#3059)" This reverts commita40f0be6fd. * Revert "Psionic Prosthetics (#4689)" This reverts commit2679bb238a. * Revert "Add surgical cleanliness and sanitation (#2847)" This reverts commit64565ba4f7. * Remove unremoved mentions * Revert "Add autoclave to easily sanitize large amounts of items and faster (#2933)" This reverts commitd0da90fa2e. * Shit Med Removed * Remove _ShitMed Folders and fix Errors in Console * Add OrganAnimalBrain into the mirgraiton file * Heads no Input Mover * Monke * Full migration file I guess * oops * shiv state fix * Restore accidental deleted recipe * Forgot one flt mention * Fix more issues * Comment out Damage Visual for motorkind for now * Motorkind... * Commenting stuff out for now * thought there'd be more of this to gut --------- Co-authored-by: Janet Blackquill <uhhadd@gmail.com>
183 lines
6.6 KiB
C#
183 lines
6.6 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Content.Shared.Body.Components;
|
|
using Content.Shared.Body.Systems;
|
|
using Robust.Shared.Containers;
|
|
using Robust.Shared.EntitySerialization.Systems;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.IntegrationTests.Tests.Body;
|
|
|
|
[TestFixture]
|
|
public sealed class SaveLoadReparentTest
|
|
{
|
|
[TestPrototypes]
|
|
private const string Prototypes = @"
|
|
- type: entity
|
|
name: HumanBodyDummy
|
|
id: HumanBodyDummy
|
|
components:
|
|
- type: Body
|
|
prototype: Human
|
|
";
|
|
|
|
[Test]
|
|
public async Task Test()
|
|
{
|
|
await using var pair = await PoolManager.GetServerClient();
|
|
var server = pair.Server;
|
|
|
|
var entities = server.ResolveDependency<IEntityManager>();
|
|
var maps = server.ResolveDependency<IMapManager>();
|
|
var mapLoader = entities.System<MapLoaderSystem>();
|
|
var bodySystem = entities.System<SharedBodySystem>();
|
|
var containerSystem = entities.System<SharedContainerSystem>();
|
|
var mapSys = entities.System<SharedMapSystem>();
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
mapSys.CreateMap(out var mapId);
|
|
maps.CreateGrid(mapId);
|
|
var human = entities.SpawnEntity("HumanBodyDummy", new MapCoordinates(0, 0, mapId));
|
|
|
|
Assert.That(entities.HasComponent<BodyComponent>(human), Is.True);
|
|
|
|
var parts = bodySystem.GetBodyChildren(human).Skip(1).ToArray();
|
|
var organs = bodySystem.GetBodyOrgans(human).ToArray();
|
|
|
|
// Assert.Multiple(() =>
|
|
// {
|
|
// Assert.That(parts, Is.Not.Empty);
|
|
// Assert.That(organs, Is.Not.Empty);
|
|
// });
|
|
|
|
foreach (var (id, component) in parts)
|
|
{
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(component.Body, Is.EqualTo(human));
|
|
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)
|
|
{
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(slot.Id, Is.EqualTo(slotId));
|
|
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(parent, Is.Not.Null);
|
|
Assert.That(parent.Value, Is.Not.EqualTo(default(EntityUid)));
|
|
});
|
|
}
|
|
|
|
// Converts an entity query enumerator to an enumerable.
|
|
static IEnumerable<(EntityUid Uid, TComp Comp)> EnumerateQueryEnumerator<TComp>(EntityQueryEnumerator<TComp> query)
|
|
where TComp : Component
|
|
{
|
|
while (query.MoveNext(out var uid, out var comp))
|
|
yield return (uid, comp);
|
|
}
|
|
|
|
Assert.That(
|
|
EnumerateQueryEnumerator(
|
|
entities.EntityQueryEnumerator<BodyComponent>()
|
|
).Where((e) =>
|
|
entities.GetComponent<MetaDataComponent>(e.Uid).EntityPrototype!.Name == "HumanBodyDummy"
|
|
),
|
|
Is.Not.Empty
|
|
);
|
|
|
|
var mapPath = new ResPath($"/{nameof(SaveLoadReparentTest)}{nameof(Test)}map.yml");
|
|
|
|
Assert.That(mapLoader.TrySaveMap(mapId, mapPath));
|
|
mapSys.DeleteMap(mapId);
|
|
|
|
Assert.That(mapLoader.TryLoadMap(mapPath, out var map, out _), Is.True);
|
|
|
|
var query = EnumerateQueryEnumerator(
|
|
entities.EntityQueryEnumerator<BodyComponent>()
|
|
).Where((e) =>
|
|
entities.GetComponent<MetaDataComponent>(e.Uid).EntityPrototype!.Name == "HumanBodyDummy"
|
|
).ToArray();
|
|
|
|
Assert.That(query, Is.Not.Empty);
|
|
foreach (var (uid, body) in query)
|
|
{
|
|
human = uid;
|
|
parts = bodySystem.GetBodyChildren(human).Skip(1).ToArray();
|
|
organs = bodySystem.GetBodyOrgans(human).ToArray();
|
|
|
|
// Assert.Multiple(() =>
|
|
// {
|
|
// Assert.That(parts, Is.Not.Empty);
|
|
// Assert.That(organs, Is.Not.Empty);
|
|
// });
|
|
|
|
foreach (var (id, component) in parts)
|
|
{
|
|
var parent = bodySystem.GetParentPartOrNull(id);
|
|
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(component.Body, Is.EqualTo(human));
|
|
Assert.That(parent, Is.Not.Null);
|
|
Assert.That(parent.Value, Is.Not.EqualTo(default(EntityUid)));
|
|
});
|
|
|
|
foreach (var (slotId, slot) in component.Children)
|
|
{
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(slot.Id, Is.EqualTo(slotId));
|
|
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(parent, Is.Not.Null);
|
|
Assert.That(parent.Value, Is.Not.EqualTo(default(EntityUid)));
|
|
});
|
|
}
|
|
|
|
entities.DeleteEntity(map);
|
|
}
|
|
});
|
|
|
|
await pair.CleanReturnAsync();
|
|
}
|
|
}
|