Files
wwdpublic/Content.IntegrationTests/Tests/Sprite/ItemSpriteTest.cs
EctoplasmIsGood 9a65bedfc4 Salvage / Borg Tweaks (#2145)
<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->

# Description

<!--
Explain this PR in as much detail as applicable

Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->

Originally started because I wanted to add some stuff to salvage, but
ended up with me porting over whitelisted borg hands, the PKA module,
and some other stuff.

---

# Changelog

<!--
You can add an author after the `🆑` to change the name that appears
in the changelog (ex: `🆑 Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

🆑
- add: Engi borgs can now carry electronics, and medical borgs can carry
organs
- add: Salvage borgs now get a PKA module
- tweak: All mining drills have had their damage turned to piercing and
have received a moderate damage buff
- tweak: Exosuit drills now swing at the same speed as normal drills
(why were they worse???)
- tweak: The RPD and RCD modules for borg have been merged into one
- tweak: Salvage can now purchase drills from their vendor
- tweak: Salvage borgs mining module no longer contains a shovel

---------

Co-authored-by: Your Name <EctoplasmIsGood@users.noreply.github.com>
Co-authored-by: Whatstone <whatston3@gmail.com>
Co-authored-by: RatherUncreative <RatherUncreativeName@proton.me>
Co-authored-by: Aidenkrz <aiden@djkraz.com>
(cherry picked from commit ed8850e551bd9c0d533d69cad262a8743442a62a)
2025-04-04 14:51:28 +03: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();
}
}