mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-06-09 13:26:34 +02:00
d42adbf05d
* Pass 1. * i'm FREE * Prevent hangups. * okay fine here's an attribute for settings, will polish later and prolly remove the overridable thing. * sigh. * fix singular trigger bug so LatheTest doesn't flake. * Remove SystemAttribute usage. * Poke * I used the shotgun. You know why? Cause the shot gun doesn’t miss, and unlike the shitty hybrid taser it stops a criminal in their tracks in two hits. Bang, bang, and they’re fucking done. I use four shots just to make damn sure. Because, once again, I’m not there to coddle a buncha criminal scum sucking f------, I’m there to 1) Survive the fucking round. 2) Guard the armory. So you can absolutely get fucked. If I get unbanned, which I won’t, you can guarantee I will continue to use the shotgun to apprehend criminals. Because it’s quick, clean and effective as fuck. Why in the seven hells would I fuck around with the disabler shots, which take half a clip just to bring someone down, or with the tazer bolts which are slow as balls, impossible to aim and do about next to jack shit, fuck all. The shotgun is the superior law enforcement weapon. Because it stops crime. And it stops crime by reducing the number of criminals roaming the fucking halls. * Change the faulty store test into two tests, one of which is ignored for failing.
154 lines
4.9 KiB
C#
154 lines
4.9 KiB
C#
using Content.IntegrationTests.Fixtures;
|
|
using Content.Shared.Inventory;
|
|
using Robust.Shared.GameObjects;
|
|
|
|
namespace Content.IntegrationTests.Tests
|
|
{
|
|
// Tests the behavior of InventoryComponent.
|
|
// i.e. the interaction between uniforms and the pocket/ID slots.
|
|
// and also how big items don't fit in pockets.
|
|
[TestFixture]
|
|
public sealed class HumanInventoryUniformSlotsTest : GameTest
|
|
{
|
|
[TestPrototypes]
|
|
private const string Prototypes = @"
|
|
- type: entity
|
|
name: HumanUniformDummy
|
|
id: HumanUniformDummy
|
|
components:
|
|
- type: Inventory
|
|
- type: ContainerContainer
|
|
|
|
- type: entity
|
|
name: UniformDummy
|
|
id: UniformDummy
|
|
components:
|
|
- type: Clothing
|
|
slots: [innerclothing]
|
|
- type: Item
|
|
size: Tiny
|
|
|
|
- type: entity
|
|
name: IDCardDummy
|
|
id: IDCardDummy
|
|
components:
|
|
- type: Clothing
|
|
slots:
|
|
- idcard
|
|
- type: Item
|
|
size: Tiny
|
|
- type: IdCard
|
|
|
|
- type: entity
|
|
name: FlashlightDummy
|
|
id: FlashlightDummy
|
|
components:
|
|
- type: Item
|
|
size: Tiny
|
|
|
|
- type: entity
|
|
name: ToolboxDummy
|
|
id: ToolboxDummy
|
|
components:
|
|
- type: Item
|
|
size: Huge
|
|
";
|
|
[Test]
|
|
public async Task Test()
|
|
{
|
|
var pair = Pair;
|
|
var server = pair.Server;
|
|
var testMap = await pair.CreateTestMap();
|
|
var coordinates = testMap.GridCoords;
|
|
|
|
EntityUid human = default;
|
|
EntityUid uniform = default;
|
|
EntityUid idCard = default;
|
|
EntityUid pocketItem = default;
|
|
|
|
InventorySystem invSystem = default!;
|
|
var mapSystem = server.System<SharedMapSystem>();
|
|
var entityMan = server.ResolveDependency<IEntityManager>();
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
invSystem = entityMan.System<InventorySystem>();
|
|
|
|
human = entityMan.SpawnEntity("HumanUniformDummy", coordinates);
|
|
uniform = entityMan.SpawnEntity("UniformDummy", coordinates);
|
|
idCard = entityMan.SpawnEntity("IDCardDummy", coordinates);
|
|
pocketItem = entityMan.SpawnEntity("FlashlightDummy", coordinates);
|
|
var tooBigItem = entityMan.SpawnEntity("ToolboxDummy", coordinates);
|
|
|
|
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(invSystem.CanEquip(human, uniform, "jumpsuit", out _));
|
|
|
|
// Can't equip any of these since no uniform!
|
|
Assert.That(invSystem.CanEquip(human, idCard, "id", out _), Is.False);
|
|
Assert.That(invSystem.CanEquip(human, pocketItem, "pocket1", out _), Is.False);
|
|
Assert.That(invSystem.CanEquip(human, tooBigItem, "pocket2", out _), Is.False); // This one fails either way.
|
|
});
|
|
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(invSystem.TryEquip(human, uniform, "jumpsuit"));
|
|
Assert.That(invSystem.TryEquip(human, idCard, "id"));
|
|
});
|
|
|
|
#pragma warning disable NUnit2045
|
|
Assert.That(invSystem.CanEquip(human, tooBigItem, "pocket1", out _), Is.False); // Still failing!
|
|
Assert.That(invSystem.TryEquip(human, pocketItem, "pocket1"));
|
|
#pragma warning restore NUnit2045
|
|
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(IsDescendant(idCard, human, entityMan));
|
|
Assert.That(IsDescendant(pocketItem, human, entityMan));
|
|
});
|
|
|
|
// Now drop the jumpsuit.
|
|
Assert.That(invSystem.TryUnequip(human, "jumpsuit"));
|
|
});
|
|
|
|
await server.WaitRunTicks(2);
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
Assert.Multiple(() =>
|
|
{
|
|
// Items have been dropped!
|
|
Assert.That(IsDescendant(uniform, human, entityMan), Is.False);
|
|
Assert.That(IsDescendant(idCard, human, entityMan), Is.False);
|
|
Assert.That(IsDescendant(pocketItem, human, entityMan), Is.False);
|
|
|
|
// Ensure everything null here.
|
|
Assert.That(!invSystem.TryGetSlotEntity(human, "jumpsuit", out _));
|
|
Assert.That(!invSystem.TryGetSlotEntity(human, "id", out _));
|
|
Assert.That(!invSystem.TryGetSlotEntity(human, "pocket1", out _));
|
|
});
|
|
|
|
mapSystem.DeleteMap(testMap.MapId);
|
|
});
|
|
}
|
|
|
|
private static bool IsDescendant(EntityUid descendant, EntityUid parent, IEntityManager entManager)
|
|
{
|
|
var xforms = entManager.GetEntityQuery<TransformComponent>();
|
|
var tmpParent = xforms.GetComponent(descendant).ParentUid;
|
|
while (tmpParent.IsValid())
|
|
{
|
|
if (tmpParent == parent)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
tmpParent = xforms.GetComponent(tmpParent).ParentUid;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|