Sprite fixes (#2213)
Test still needs more checks that filepaths are valid but I think I got most of the current issues. Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
62
Content.IntegrationTests/Tests/AI/SpriteTest.cs
Normal file
62
Content.IntegrationTests/Tests/AI/SpriteTest.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
#nullable enable
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Client.Interfaces.ResourceManagement;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.AI
|
||||
{
|
||||
[TestFixture]
|
||||
public sealed class SpriteTest : ContentIntegrationTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Test RSIs and textures are valid
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestSpritePaths()
|
||||
{
|
||||
var (client, server) = await StartConnectedServerClientPair();
|
||||
await client.WaitIdleAsync();
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
var resc = client.ResolveDependency<IResourceCache>();
|
||||
var entityManager = client.ResolveDependency<IEntityManager>();
|
||||
var mapManager = client.ResolveDependency<IMapManager>();
|
||||
var prototypeManager = client.ResolveDependency<IPrototypeManager>();
|
||||
|
||||
await client.WaitIdleAsync();
|
||||
|
||||
client.Assert(() =>
|
||||
{
|
||||
var mapId = mapManager.CreateMap();
|
||||
string filePath;
|
||||
var map = mapManager.GetMapEntity(mapId);
|
||||
|
||||
foreach (var proto in prototypeManager.EnumeratePrototypes<EntityPrototype>())
|
||||
{
|
||||
if (proto.Abstract || !proto.Components.ContainsKey("Sprite"))
|
||||
continue;
|
||||
|
||||
var entity = entityManager.SpawnEntity(proto.ID, map.Transform.MapPosition);
|
||||
var spriteComponent = entity.GetComponent<ISpriteComponent>();
|
||||
|
||||
foreach (var layer in spriteComponent.AllLayers)
|
||||
{
|
||||
|
||||
if (layer.RsiState != null && layer.Rsi != null)
|
||||
{
|
||||
filePath = layer.Rsi.Path + "/" + layer.RsiState + ".png";
|
||||
Assert.That(resc.ContentFileExists(filePath), $"Unable to find {filePath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
await client.WaitIdleAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user