Make item size scale with stack size (#17623)
* Make stack count affect item size * and the test, too * readd this check * vwoom * huh * if you ever read this commit message ping me on discord in #contributors * changerinos
This commit is contained in:
42
Content.IntegrationTests/Tests/StackTest.cs
Normal file
42
Content.IntegrationTests/Tests/StackTest.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Stacks;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.IntegrationTests.Tests;
|
||||
|
||||
[TestFixture]
|
||||
public sealed class StackTest
|
||||
{
|
||||
[Test]
|
||||
public async Task StackCorrectItemSize()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
var protoManager = server.ResolveDependency<IPrototypeManager>();
|
||||
var compFact = server.ResolveDependency<IComponentFactory>();
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
foreach (var entity in PoolManager.GetEntityPrototypes<StackComponent>(server))
|
||||
{
|
||||
if (!entity.TryGetComponent<StackComponent>(out var stackComponent, compFact) ||
|
||||
!entity.TryGetComponent<ItemComponent>(out var itemComponent, compFact))
|
||||
continue;
|
||||
|
||||
if (!protoManager.TryIndex<StackPrototype>(stackComponent.StackTypeId, out var stackProto) ||
|
||||
stackProto.ItemSize == null)
|
||||
continue;
|
||||
|
||||
var expectedSize = stackProto.ItemSize * stackComponent.Count;
|
||||
Assert.That(itemComponent.Size, Is.EqualTo(expectedSize), $"Prototype id: {entity.ID} has an item size of {itemComponent.Size} but expected size of {expectedSize}.");
|
||||
}
|
||||
});
|
||||
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user