Add an integration test for solution fill level sprites. (#28564)
This commit is contained in:
71
Content.IntegrationTests/Tests/FillLevelSpriteTest.cs
Normal file
71
Content.IntegrationTests/Tests/FillLevelSpriteTest.cs
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using Content.Shared.Chemistry.Components;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
|
namespace Content.IntegrationTests.Tests;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests to see if any entity prototypes specify solution fill level sprites that don't exist.
|
||||||
|
/// </summary>
|
||||||
|
[TestFixture]
|
||||||
|
public sealed class FillLevelSpriteTest
|
||||||
|
{
|
||||||
|
private static readonly string[] HandStateNames = ["left", "right"];
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task FillLevelSpritesExist()
|
||||||
|
{
|
||||||
|
await using var pair = await PoolManager.GetServerClient();
|
||||||
|
var client = pair.Client;
|
||||||
|
var protoMan = client.ResolveDependency<IPrototypeManager>();
|
||||||
|
var componentFactory = client.ResolveDependency<IComponentFactory>();
|
||||||
|
|
||||||
|
await client.WaitAssertion(() =>
|
||||||
|
{
|
||||||
|
var protos = protoMan.EnumeratePrototypes<EntityPrototype>()
|
||||||
|
.Where(p => !p.Abstract)
|
||||||
|
.Where(p => !pair.IsTestPrototype(p))
|
||||||
|
.Where(p => p.TryGetComponent<SolutionContainerVisualsComponent>(out _, componentFactory))
|
||||||
|
.OrderBy(p => p.ID)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
foreach (var proto in protos)
|
||||||
|
{
|
||||||
|
Assert.That(proto.TryGetComponent<SolutionContainerVisualsComponent>(out var visuals, componentFactory));
|
||||||
|
Assert.That(proto.TryGetComponent<SpriteComponent>(out var sprite, componentFactory));
|
||||||
|
|
||||||
|
var rsi = sprite.BaseRSI;
|
||||||
|
|
||||||
|
// Test base sprite fills
|
||||||
|
if (!string.IsNullOrEmpty(visuals.FillBaseName))
|
||||||
|
{
|
||||||
|
for (var i = 1; i <= visuals.MaxFillLevels; i++)
|
||||||
|
{
|
||||||
|
var state = $"{visuals.FillBaseName}{i}";
|
||||||
|
Assert.That(rsi.TryGetState(state, out _), @$"{proto.ID} has SolutionContainerVisualsComponent with
|
||||||
|
MaxFillLevels = {visuals.MaxFillLevels}, but {rsi.Path} doesn't have state {state}!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test inhand sprite fills
|
||||||
|
if (!string.IsNullOrEmpty(visuals.InHandsFillBaseName))
|
||||||
|
{
|
||||||
|
for (var i = 1; i <= visuals.InHandsMaxFillLevels; i++)
|
||||||
|
{
|
||||||
|
foreach (var handname in HandStateNames)
|
||||||
|
{
|
||||||
|
var state = $"inhand-{handname}{visuals.InHandsFillBaseName}{i}";
|
||||||
|
Assert.That(rsi.TryGetState(state, out _), @$"{proto.ID} has SolutionContainerVisualsComponent with
|
||||||
|
InHandsMaxFillLevels = {visuals.InHandsMaxFillLevels}, but {rsi.Path} doesn't have state {state}!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await pair.CleanReturnAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -83,10 +83,6 @@
|
|||||||
max: 1
|
max: 1
|
||||||
- !type:DoActsBehavior
|
- !type:DoActsBehavior
|
||||||
acts: [ "Destruction" ]
|
acts: [ "Destruction" ]
|
||||||
- type: Appearance
|
|
||||||
- type: SolutionContainerVisuals
|
|
||||||
maxFillLevels: 1
|
|
||||||
fillBaseName: dart
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: Dart
|
parent: Dart
|
||||||
|
|||||||
@@ -233,6 +233,8 @@
|
|||||||
sprite: Objects/Specific/Chemistry/beaker_cryostasis.rsi
|
sprite: Objects/Specific/Chemistry/beaker_cryostasis.rsi
|
||||||
layers:
|
layers:
|
||||||
- state: beakernoreact
|
- state: beakernoreact
|
||||||
|
- type: SolutionContainerVisuals
|
||||||
|
maxFillLevels: 0
|
||||||
- type: SolutionContainerManager
|
- type: SolutionContainerManager
|
||||||
solutions:
|
solutions:
|
||||||
beaker:
|
beaker:
|
||||||
@@ -251,6 +253,8 @@
|
|||||||
sprite: Objects/Specific/Chemistry/beaker_bluespace.rsi
|
sprite: Objects/Specific/Chemistry/beaker_bluespace.rsi
|
||||||
layers:
|
layers:
|
||||||
- state: beakerbluespace
|
- state: beakerbluespace
|
||||||
|
- type: SolutionContainerVisuals
|
||||||
|
maxFillLevels: 0
|
||||||
- type: SolutionContainerManager
|
- type: SolutionContainerManager
|
||||||
solutions:
|
solutions:
|
||||||
beaker:
|
beaker:
|
||||||
|
|||||||
Reference in New Issue
Block a user