public async Task BuckledDyingDropItemsTest() { var options = new ServerContentIntegrationOption { ExtraPrototypes = Prototypes }; var server = StartServer(options); EntityUid human = default; BuckleComponent buckle = null; HandsComponent hands = null; SharedBodyComponent body = null; await server.WaitIdleAsync(); await server.WaitAssertion(() => { var mapManager = IoCManager.Resolve <IMapManager>(); var entityManager = IoCManager.Resolve <IEntityManager>(); var grid = GetMainGrid(mapManager); var coordinates = new EntityCoordinates(grid.GridEntityId, 0, 0); human = entityManager.SpawnEntity(BuckleDummyId, coordinates); var chair = entityManager.SpawnEntity(StrapDummyId, coordinates); // Component sanity check Assert.True(entityManager.TryGetComponent(human, out buckle)); Assert.True(entityManager.HasComponent <StrapComponent>(chair)); Assert.True(entityManager.TryGetComponent(human, out hands)); Assert.True(entityManager.TryGetComponent(human, out body)); // Buckle Assert.True(buckle.TryBuckle(human, chair)); Assert.NotNull(buckle.BuckledTo); Assert.True(buckle.Buckled); // Put an item into every hand for (var i = 0; i < hands.Count; i++) { var akms = entityManager.SpawnEntity(ItemDummyId, coordinates); Assert.True(EntitySystem.Get <SharedHandsSystem>().TryPickupAnyHand(human, akms)); } }); await server.WaitRunTicks(10); await server.WaitAssertion(() => { // Still buckled Assert.True(buckle.Buckled); // With items in all hands foreach (var hand in hands.Hands.Values) { Assert.NotNull(hands.ActiveHandEntity); } var legs = body.GetPartsOfType(BodyPartType.Leg); // Break our guy's kneecaps foreach (var leg in legs) { body.RemovePart(leg); } }); await server.WaitRunTicks(10); await server.WaitAssertion(() => { // Still buckled Assert.True(buckle.Buckled); // Now with no item in any hand foreach (var hand in hands.Hands.Values) { Assert.Null(hands.ActiveHandEntity); } buckle.TryUnbuckle(human, true); }); }
public async Task BuckledDyingDropItemsTest() { var options = new ServerContentIntegrationOption { ExtraPrototypes = Prototypes }; var server = StartServer(options); IEntity human = null; BuckleComponent buckle = null; HandsComponent hands = null; SharedBodyComponent body = null; await server.WaitIdleAsync(); await server.WaitAssertion(() => { var mapManager = IoCManager.Resolve <IMapManager>(); var entityManager = IoCManager.Resolve <IEntityManager>(); var gridId = new GridId(1); var grid = mapManager.GetGrid(gridId); var coordinates = grid.GridEntityId.ToCoordinates(); human = entityManager.SpawnEntity(BuckleDummyId, coordinates); IEntity chair = entityManager.SpawnEntity(StrapDummyId, coordinates); // Component sanity check Assert.True(human.TryGetComponent(out buckle)); Assert.True(chair.HasComponent <StrapComponent>()); Assert.True(human.TryGetComponent(out hands)); Assert.True(human.TryGetComponent(out body)); // Buckle Assert.True(buckle.TryBuckle(human, chair)); Assert.NotNull(buckle.BuckledTo); Assert.True(buckle.Buckled); // Put an item into every hand for (var i = 0; i < hands.Count; i++) { var akms = entityManager.SpawnEntity(ItemDummyId, coordinates); // Equip items Assert.True(akms.TryGetComponent(out ItemComponent item)); Assert.True(hands.PutInHand(item)); } }); await server.WaitRunTicks(10); await server.WaitAssertion(() => { // Still buckled Assert.True(buckle.Buckled); // With items in all hands foreach (var slot in hands.HandNames) { Assert.NotNull(hands.GetItem(slot)); } var legs = body.GetPartsOfType(BodyPartType.Leg); // Break our guy's kneecaps foreach (var leg in legs) { body.RemovePart(leg); } }); await server.WaitRunTicks(10); await server.WaitAssertion(() => { // Still buckled Assert.True(buckle.Buckled); // Now with no item in any hand foreach (var slot in hands.HandNames) { Assert.Null(hands.GetItem(slot)); } buckle.TryUnbuckle(human, true); }); }