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.
137 lines
4.9 KiB
C#
137 lines
4.9 KiB
C#
using System.Linq;
|
|
using Content.IntegrationTests.Fixtures;
|
|
using Content.Server.Storage.EntitySystems;
|
|
using Content.Shared.Hands.Components;
|
|
using Content.Shared.Hands.EntitySystems;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Server.Player;
|
|
using Robust.Shared.Containers;
|
|
using Robust.Shared.GameObjects;
|
|
|
|
namespace Content.IntegrationTests.Tests.Hands;
|
|
|
|
[TestFixture]
|
|
public sealed class HandTests : GameTest
|
|
{
|
|
[TestPrototypes]
|
|
private const string Prototypes = @"
|
|
- type: entity
|
|
id: TestPickUpThenDropInContainerTestBox
|
|
name: box
|
|
components:
|
|
- type: EntityStorage
|
|
- type: ContainerContainer
|
|
containers:
|
|
entity_storage: !type:Container
|
|
";
|
|
|
|
|
|
public override PoolSettings PoolSettings => new()
|
|
{
|
|
Connected = true,
|
|
DummyTicker = false
|
|
};
|
|
|
|
[Test]
|
|
public async Task TestPickupDrop()
|
|
{
|
|
var pair = Pair;
|
|
var server = pair.Server;
|
|
|
|
var entMan = server.ResolveDependency<IEntityManager>();
|
|
var playerMan = server.ResolveDependency<IPlayerManager>();
|
|
var mapSystem = server.System<SharedMapSystem>();
|
|
var sys = entMan.System<SharedHandsSystem>();
|
|
var tSys = entMan.System<TransformSystem>();
|
|
|
|
var data = await pair.CreateTestMap();
|
|
await pair.RunTicksSync(5);
|
|
|
|
EntityUid item = default;
|
|
EntityUid player = default;
|
|
HandsComponent hands = default!;
|
|
await server.WaitPost(() =>
|
|
{
|
|
player = playerMan.Sessions.First().AttachedEntity!.Value;
|
|
var xform = entMan.GetComponent<TransformComponent>(player);
|
|
item = entMan.SpawnEntity("Crowbar", tSys.GetMapCoordinates(player, xform: xform));
|
|
hands = entMan.GetComponent<HandsComponent>(player);
|
|
sys.TryPickup(player, item, hands.ActiveHandId!);
|
|
});
|
|
|
|
// run ticks here is important, as errors may happen within the container system's frame update methods.
|
|
await pair.RunTicksSync(5);
|
|
Assert.That(sys.GetActiveItem((player, hands)), Is.EqualTo(item));
|
|
|
|
await server.WaitPost(() =>
|
|
{
|
|
sys.TryDrop(player, item);
|
|
});
|
|
|
|
await pair.RunTicksSync(5);
|
|
Assert.That(sys.GetActiveItem((player, hands)), Is.Null);
|
|
|
|
await server.WaitPost(() => mapSystem.DeleteMap(data.MapId));
|
|
}
|
|
|
|
[Test]
|
|
public async Task TestPickUpThenDropInContainer()
|
|
{
|
|
var pair = Pair;
|
|
var server = pair.Server;
|
|
var map = await pair.CreateTestMap();
|
|
await pair.RunTicksSync(5);
|
|
|
|
var entMan = server.ResolveDependency<IEntityManager>();
|
|
var playerMan = server.ResolveDependency<IPlayerManager>();
|
|
var mapSystem = server.System<SharedMapSystem>();
|
|
var sys = entMan.System<SharedHandsSystem>();
|
|
var tSys = entMan.System<TransformSystem>();
|
|
var containerSystem = server.System<SharedContainerSystem>();
|
|
|
|
EntityUid item = default;
|
|
EntityUid box = default;
|
|
EntityUid player = default;
|
|
HandsComponent hands = default!;
|
|
|
|
// spawn the elusive box and crowbar at the coordinates
|
|
await server.WaitPost(() => box = server.EntMan.SpawnEntity("TestPickUpThenDropInContainerTestBox", map.GridCoords));
|
|
await server.WaitPost(() => item = server.EntMan.SpawnEntity("Crowbar", map.GridCoords));
|
|
// place the player at the exact same coordinates and have them grab the crowbar
|
|
await server.WaitPost(() =>
|
|
{
|
|
player = playerMan.Sessions.First().AttachedEntity!.Value;
|
|
tSys.PlaceNextTo(player, item);
|
|
hands = entMan.GetComponent<HandsComponent>(player);
|
|
sys.TryPickup(player, item, hands.ActiveHandId!);
|
|
});
|
|
await pair.RunTicksSync(5);
|
|
Assert.That(sys.GetActiveItem((player, hands)), Is.EqualTo(item));
|
|
|
|
// Open then close the box to place the player, who is holding the crowbar, inside of it
|
|
var storage = server.System<EntityStorageSystem>();
|
|
await server.WaitPost(() =>
|
|
{
|
|
storage.OpenStorage(box);
|
|
storage.CloseStorage(box);
|
|
});
|
|
await pair.RunTicksSync(5);
|
|
Assert.That(containerSystem.IsEntityInContainer(player), Is.True);
|
|
|
|
// Dropping the item while the player is inside the box should cause the item
|
|
// to also be inside the same container the player is in now,
|
|
// with the item not being in the player's hands
|
|
await server.WaitPost(() =>
|
|
{
|
|
sys.TryDrop(player, item);
|
|
});
|
|
await pair.RunTicksSync(5);
|
|
var xform = entMan.GetComponent<TransformComponent>(player);
|
|
var itemXform = entMan.GetComponent<TransformComponent>(item);
|
|
Assert.That(sys.GetActiveItem((player, hands)), Is.Not.EqualTo(item));
|
|
Assert.That(containerSystem.IsInSameOrNoContainer((player, xform), (item, itemXform)));
|
|
|
|
await server.WaitPost(() => mapSystem.DeleteMap(map.MapId));
|
|
}
|
|
}
|