* Engine namespace changes.
* Automated remove redundant using statements.
* Simplified Graphics namespace.
* Apparently the container system stores full type names in the map file.😞 This updates those names.
* API Changes to LocalizationManager.LoadCulture.
* Update submodule to v0.3.2
99 lines
3.8 KiB
C#
99 lines
3.8 KiB
C#
#nullable enable
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Content.Client.GameObjects.Components.Items;
|
|
using Content.Server.GameObjects.Components.ActionBlocking;
|
|
using Content.Server.Interfaces.GameObjects.Components.Items;
|
|
using Content.Shared.GameObjects.Components.Body;
|
|
using NUnit.Framework;
|
|
using Robust.Server.Console;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Map;
|
|
|
|
namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
|
|
{
|
|
[TestFixture]
|
|
[TestOf(typeof(CuffableComponent))]
|
|
[TestOf(typeof(HandcuffComponent))]
|
|
public class HandCuffTest : ContentIntegrationTest
|
|
{
|
|
private const string Prototypes = @"
|
|
- type: entity
|
|
name: HumanDummy
|
|
id: HumanDummy
|
|
components:
|
|
- type: Cuffable
|
|
- type: Hands
|
|
- type: Body
|
|
template: HumanoidTemplate
|
|
preset: HumanPreset
|
|
centerSlot: torso
|
|
|
|
- type: entity
|
|
name: HandcuffsDummy
|
|
id: HandcuffsDummy
|
|
components:
|
|
- type: Handcuff
|
|
";
|
|
[Test]
|
|
public async Task Test()
|
|
{
|
|
var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes};
|
|
var server = StartServerDummyTicker(options);
|
|
|
|
IEntity human;
|
|
IEntity otherHuman;
|
|
IEntity cuffs;
|
|
IEntity secondCuffs;
|
|
CuffableComponent cuffed;
|
|
IHandsComponent hands;
|
|
|
|
server.Assert(() =>
|
|
{
|
|
var mapManager = IoCManager.Resolve<IMapManager>();
|
|
mapManager.CreateNewMapEntity(MapId.Nullspace);
|
|
|
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
|
|
|
// Spawn the entities
|
|
human = entityManager.SpawnEntity("HumanDummy", MapCoordinates.Nullspace);
|
|
otherHuman = entityManager.SpawnEntity("HumanDummy", MapCoordinates.Nullspace);
|
|
cuffs = entityManager.SpawnEntity("HandcuffsDummy", MapCoordinates.Nullspace);
|
|
secondCuffs = entityManager.SpawnEntity("HandcuffsDummy", MapCoordinates.Nullspace);
|
|
|
|
human.Transform.WorldPosition = otherHuman.Transform.WorldPosition;
|
|
|
|
// Test for components existing
|
|
Assert.True(human.TryGetComponent(out cuffed!), $"Human has no {nameof(CuffableComponent)}");
|
|
Assert.True(human.TryGetComponent(out hands!), $"Human has no {nameof(HandsComponent)}");
|
|
Assert.True(human.TryGetComponent(out IBody _), $"Human has no {nameof(IBody)}");
|
|
Assert.True(cuffs.TryGetComponent(out HandcuffComponent _), $"Handcuff has no {nameof(HandcuffComponent)}");
|
|
Assert.True(secondCuffs.TryGetComponent(out HandcuffComponent _), $"Second handcuffs has no {nameof(HandcuffComponent)}");
|
|
|
|
// Test to ensure cuffed players register the handcuffs
|
|
cuffed.TryAddNewCuffs(human, cuffs);
|
|
Assert.True(cuffed.CuffedHandCount > 0, "Handcuffing a player did not result in their hands being cuffed");
|
|
|
|
// Test to ensure a player with 4 hands will still only have 2 hands cuffed
|
|
AddHand(cuffed.Owner);
|
|
AddHand(cuffed.Owner);
|
|
Assert.True(cuffed.CuffedHandCount == 2 && hands.Hands.Count() == 4, "Player doesn't have correct amount of hands cuffed");
|
|
|
|
// Test to give a player with 4 hands 2 sets of cuffs
|
|
cuffed.TryAddNewCuffs(human, secondCuffs);
|
|
Assert.True(cuffed.CuffedHandCount == 4, "Player doesn't have correct amount of hands cuffed");
|
|
|
|
});
|
|
|
|
await server.WaitIdleAsync();
|
|
}
|
|
|
|
private void AddHand(IEntity to)
|
|
{
|
|
var host = IoCManager.Resolve<IServerConsoleHost>();
|
|
host.ExecuteCommand(null, $"addhand {to.Uid}");
|
|
}
|
|
}
|
|
}
|