* eye on the prize * OnStackInteractUsing, TryMergeStacks, TryMergeToHands, TryMergeToContacts * namespace * Use, get count, getMaxCount * component access * add regions, mark TODO * obsolete TryAdd, public TryMergeStacks * GetMaxCount * event handlers * event handlers * SetCount * client server event handlers * move to shared * Revert "move to shared" This reverts commit 45540a2d6b8e1e6d2a8f83a584267776c7edcd73. * misc changes to shared * split * spawn and SpawnNextToOrDrop * SpawnMultipleAtPosition, SpawnMultipleNextToOrDrop, CalculateSpawns, general server cleanup * Rename Use to TryUse. * Small misc changes * Remove obsolete functions * Remove some SetCount calls * Partialize * small misc change * don't nuke the git dif with the namespace block * Comments and reordering * touchup to UpdateLingering * Summary comment for StackStatusControl * Last pass * Actual last pass (for now) * I know myself too well * fixup * goodbye lingering * fixes * review * fix test * second look * fix test * forgot * remove early comp getting --------- Co-authored-by: iaada <iaada@users.noreply.github.com> Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
68 lines
2.5 KiB
C#
68 lines
2.5 KiB
C#
#nullable enable
|
|
using Content.Server.Stack;
|
|
using Content.Shared.Stacks;
|
|
using Content.Shared.Materials;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.IntegrationTests.Tests.Materials
|
|
{
|
|
/// <summary>
|
|
/// Materials and stacks have some odd relationships to entities,
|
|
/// so we need some test coverage for them.
|
|
/// </summary>
|
|
[TestFixture]
|
|
[TestOf(typeof(StackSystem))]
|
|
[TestOf(typeof(MaterialPrototype))]
|
|
public sealed class MaterialPrototypeSpawnsStackMaterialTest
|
|
{
|
|
[Test]
|
|
public async Task MaterialPrototypeSpawnsStackMaterial()
|
|
{
|
|
await using var pair = await PoolManager.GetServerClient();
|
|
var server = pair.Server;
|
|
await server.WaitIdleAsync();
|
|
|
|
var mapSystem = server.System<SharedMapSystem>();
|
|
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
|
|
var entityManager = server.ResolveDependency<IEntityManager>();
|
|
|
|
var testMap = await pair.CreateTestMap();
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
var allMaterialProtos = prototypeManager.EnumeratePrototypes<MaterialPrototype>();
|
|
var coords = testMap.GridCoords;
|
|
|
|
Assert.Multiple(() =>
|
|
{
|
|
foreach (var proto in allMaterialProtos)
|
|
{
|
|
if (proto.StackEntity == null)
|
|
continue;
|
|
|
|
var spawned = entityManager.SpawnEntity(proto.StackEntity, coords);
|
|
|
|
Assert.That(entityManager.TryGetComponent<StackComponent>(spawned, out var stack),
|
|
$"{proto.ID} 'stack entity' {proto.StackEntity} does not have the stack component");
|
|
|
|
Assert.That(entityManager.HasComponent<MaterialComponent>(spawned),
|
|
$"{proto.ID} 'material stack' {proto.StackEntity} does not have the material component");
|
|
|
|
StackPrototype? stackProto = null;
|
|
Assert.That(stack?.StackTypeId != null && prototypeManager.TryIndex(stack.StackTypeId, out stackProto),
|
|
$"{proto.ID} material has no stack prototype");
|
|
|
|
if (stackProto != null)
|
|
Assert.That(proto.StackEntity, Is.EqualTo(stackProto.Spawn.Id));
|
|
}
|
|
});
|
|
|
|
mapSystem.DeleteMap(testMap.MapId);
|
|
});
|
|
|
|
await pair.CleanReturnAsync();
|
|
}
|
|
}
|
|
}
|