Files
Delta-v/Content.IntegrationTests/Tests/Sprite/ItemSpriteTest.cs
T
0f3edc0b39 port better borgs from frontier (#3110)
* BetterBorgs: droppable, swappable cyborg item interactions (#2766)

* WIP: droppable, swappable, insertable cyborg items

* Half-baked borg HandPlaceholderComponent

* cyborg: sprite representation for empty slots

* nullable prototype

---------

Co-authored-by: Dvir <39403717+dvir001@users.noreply.github.com>

* BorgSystem: check droppable items for duped mods (#2887)

* BorgSystem: check droppable items for duped mods

* Cache item comparer

* BorgSystem: Unremoveable after equip (#2854)

* raise interaction events to add fibers to things

---------

Co-authored-by: Whatstone <166147148+whatston3@users.noreply.github.com>
Co-authored-by: Dvir <39403717+dvir001@users.noreply.github.com>
Co-authored-by: deltanedas <@deltanedas:kde.org>
2025-03-04 12:10:32 +00:00

66 lines
2.5 KiB
C#

#nullable enable
using System.Collections.Generic;
using Content.Shared.Item;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
namespace Content.IntegrationTests.Tests.Sprite;
/// <summary>
/// This test checks that all items have a visible sprite. The general rationale is that all items can be picked up
/// by players, thus they need to be visible and have a sprite that can be rendered on screen and in their hands GUI.
/// This has nothing to do with in-hand sprites.
/// </summary>
/// <remarks>
/// If a prototype fails this test, its probably either because it:
/// - Should be marked abstract
/// - inherits from BaseItem despite not being an item
/// - Shouldn't have an item component
/// - Is missing the required sprite information.
/// If none of the abveo are true, it might need to be added to the list of ignored components, see
/// <see cref="Ignored"/>
/// </remarks>
[TestFixture]
public sealed class PrototypeSaveTest
{
private static readonly HashSet<string> Ignored = new()
{
// The only prototypes that should get ignored are those that REQUIRE setup to get a sprite. At that point it is
// the responsibility of the spawner to ensure that a valid sprite is set.
"VirtualItem",
"HandPlaceholder" // Frontier
};
[Test]
public async Task AllItemsHaveSpritesTest()
{
var settings = new PoolSettings() { Connected = true }; // client needs to be in-game
await using var pair = await PoolManager.GetServerClient(settings);
List<EntityPrototype> badPrototypes = [];
await pair.Client.WaitPost(() =>
{
foreach (var (proto, _) in pair.GetPrototypesWithComponent<ItemComponent>(Ignored))
{
var dummy = pair.Client.EntMan.Spawn(proto.ID);
pair.Client.EntMan.RunMapInit(dummy, pair.Client.MetaData(dummy));
var spriteComponent = pair.Client.EntMan.GetComponentOrNull<SpriteComponent>(dummy);
if (spriteComponent?.Icon == null)
badPrototypes.Add(proto);
pair.Client.EntMan.DeleteEntity(dummy);
}
});
Assert.Multiple(() =>
{
foreach (var proto in badPrototypes)
{
Assert.Fail($"Item prototype has no sprite: {proto.ID}. It should probably either be marked as abstract, not be an item, or have a valid sprite");
}
});
await pair.CleanReturnAsync();
}
}