Added a test for the MagazineVisualsComponent and fixed found issues (#34491)
This commit is contained in:
committed by
GitHub
parent
834e11a482
commit
6d1cdd8639
70
Content.IntegrationTests/Tests/MagazineVisualsSpriteTest.cs
Normal file
70
Content.IntegrationTests/Tests/MagazineVisualsSpriteTest.cs
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Content.Client.Weapons.Ranged.Components;
|
||||||
|
using Content.Shared.Prototypes;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
|
namespace Content.IntegrationTests.Tests;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests all entity prototypes with the MagazineVisualsComponent.
|
||||||
|
/// </summary>
|
||||||
|
[TestFixture]
|
||||||
|
public sealed class MagazineVisualsSpriteTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public async Task MagazineVisualsSpritesExist()
|
||||||
|
{
|
||||||
|
await using var pair = await PoolManager.GetServerClient();
|
||||||
|
var client = pair.Client;
|
||||||
|
var protoMan = client.ResolveDependency<IPrototypeManager>();
|
||||||
|
var componentFactory = client.ResolveDependency<IComponentFactory>();
|
||||||
|
|
||||||
|
await client.WaitAssertion(() =>
|
||||||
|
{
|
||||||
|
foreach (var proto in protoMan.EnumeratePrototypes<EntityPrototype>())
|
||||||
|
{
|
||||||
|
if (proto.Abstract || pair.IsTestPrototype(proto))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!proto.TryGetComponent<MagazineVisualsComponent>(out var visuals, componentFactory))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Assert.That(proto.TryGetComponent<SpriteComponent>(out var sprite, componentFactory),
|
||||||
|
@$"{proto.ID} has MagazineVisualsComponent but no SpriteComponent.");
|
||||||
|
Assert.That(proto.HasComponent<AppearanceComponent>(componentFactory),
|
||||||
|
@$"{proto.ID} has MagazineVisualsComponent but no AppearanceComponent.");
|
||||||
|
|
||||||
|
var toTest = new List<(int, string)>();
|
||||||
|
if (sprite.LayerMapTryGet(GunVisualLayers.Mag, out var magLayerId))
|
||||||
|
toTest.Add((magLayerId, ""));
|
||||||
|
if (sprite.LayerMapTryGet(GunVisualLayers.MagUnshaded, out var magUnshadedLayerId))
|
||||||
|
toTest.Add((magUnshadedLayerId, "-unshaded"));
|
||||||
|
|
||||||
|
Assert.That(toTest, Is.Not.Empty,
|
||||||
|
@$"{proto.ID} has MagazineVisualsComponent but no Mag or MagUnshaded layer map.");
|
||||||
|
|
||||||
|
var start = visuals.ZeroVisible ? 0 : 1;
|
||||||
|
foreach (var (id, midfix) in toTest)
|
||||||
|
{
|
||||||
|
Assert.That(sprite.TryGetLayer(id, out var layer));
|
||||||
|
var rsi = layer.ActualRsi;
|
||||||
|
for (var i = start; i < visuals.MagSteps; i++)
|
||||||
|
{
|
||||||
|
var state = $"{visuals.MagState}{midfix}-{i}";
|
||||||
|
Assert.That(rsi.TryGetState(state, out _),
|
||||||
|
@$"{proto.ID} has MagazineVisualsComponent with MagSteps = {visuals.MagSteps}, but {rsi.Path} doesn't have state {state}!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// MagSteps includes the 0th step, so sometimes people are off by one.
|
||||||
|
var extraState = $"{visuals.MagState}{midfix}-{visuals.MagSteps}";
|
||||||
|
Assert.That(rsi.TryGetState(extraState, out _), Is.False,
|
||||||
|
@$"{proto.ID} has MagazineVisualsComponent with MagSteps = {visuals.MagSteps}, but more states exist!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await pair.CleanReturnAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -91,6 +91,10 @@
|
|||||||
capacity: 99
|
capacity: 99
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Weapons/Guns/Ammunition/Magazine/CaselessRifle/10x24.rsi
|
sprite: Objects/Weapons/Guns/Ammunition/Magazine/CaselessRifle/10x24.rsi
|
||||||
|
- type: MagazineVisuals
|
||||||
|
magState: mag
|
||||||
|
steps: 8
|
||||||
|
zeroVisible: false
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: MagazinePistolCaselessRifle
|
id: MagazinePistolCaselessRifle
|
||||||
|
|||||||
@@ -80,6 +80,8 @@
|
|||||||
layers:
|
layers:
|
||||||
- state: base
|
- state: base
|
||||||
map: ["enum.GunVisualLayers.Base"]
|
map: ["enum.GunVisualLayers.Base"]
|
||||||
|
- state: mag-1
|
||||||
|
map: ["enum.GunVisualLayers.Mag"]
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: MagazineLightRiflePractice
|
id: MagazineLightRiflePractice
|
||||||
@@ -146,6 +148,6 @@
|
|||||||
sprite: Objects/Weapons/Guns/Ammunition/Magazine/LightRifle/pk_box.rsi
|
sprite: Objects/Weapons/Guns/Ammunition/Magazine/LightRifle/pk_box.rsi
|
||||||
- type: MagazineVisuals
|
- type: MagazineVisuals
|
||||||
magState: mag
|
magState: mag
|
||||||
steps: 7
|
steps: 8
|
||||||
zeroVisible: false
|
zeroVisible: false
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
|
|||||||
@@ -59,6 +59,8 @@
|
|||||||
layers:
|
layers:
|
||||||
- state: base
|
- state: base
|
||||||
map: ["enum.GunVisualLayers.Base"]
|
map: ["enum.GunVisualLayers.Base"]
|
||||||
|
- state: mag-1
|
||||||
|
map: ["enum.GunVisualLayers.Mag"]
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: MagazineMagnum
|
id: MagazineMagnum
|
||||||
@@ -129,6 +131,8 @@
|
|||||||
layers:
|
layers:
|
||||||
- state: base
|
- state: base
|
||||||
map: ["enum.GunVisualLayers.Base"]
|
map: ["enum.GunVisualLayers.Base"]
|
||||||
|
- state: mag-1
|
||||||
|
map: ["enum.GunVisualLayers.Mag"]
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: MagazineMagnumSubMachineGun
|
id: MagazineMagnumSubMachineGun
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
map: ["enum.GunVisualLayers.Mag"]
|
map: ["enum.GunVisualLayers.Mag"]
|
||||||
- type: MagazineVisuals
|
- type: MagazineVisuals
|
||||||
magState: mag
|
magState: mag
|
||||||
steps: 5
|
steps: 6
|
||||||
zeroVisible: false
|
zeroVisible: false
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
|
|
||||||
@@ -162,6 +162,8 @@
|
|||||||
layers:
|
layers:
|
||||||
- state: base
|
- state: base
|
||||||
map: ["enum.GunVisualLayers.Base"]
|
map: ["enum.GunVisualLayers.Base"]
|
||||||
|
- state: mag-1
|
||||||
|
map: ["enum.GunVisualLayers.Mag"]
|
||||||
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
@@ -212,6 +214,8 @@
|
|||||||
layers:
|
layers:
|
||||||
- state: base
|
- state: base
|
||||||
map: ["enum.GunVisualLayers.Base"]
|
map: ["enum.GunVisualLayers.Base"]
|
||||||
|
- state: mag-1
|
||||||
|
map: ["enum.GunVisualLayers.Mag"]
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: MagazinePistolHighCapacity
|
id: MagazinePistolHighCapacity
|
||||||
@@ -273,6 +277,8 @@
|
|||||||
layers:
|
layers:
|
||||||
- state: base
|
- state: base
|
||||||
map: ["enum.GunVisualLayers.Base"]
|
map: ["enum.GunVisualLayers.Base"]
|
||||||
|
- state: mag-1
|
||||||
|
map: ["enum.GunVisualLayers.Mag"]
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: MagazinePistolSubMachineGunPractice
|
id: MagazinePistolSubMachineGunPractice
|
||||||
|
|||||||
@@ -59,6 +59,8 @@
|
|||||||
layers:
|
layers:
|
||||||
- state: base
|
- state: base
|
||||||
map: ["enum.GunVisualLayers.Base"]
|
map: ["enum.GunVisualLayers.Base"]
|
||||||
|
- state: mag-1
|
||||||
|
map: ["enum.GunVisualLayers.Mag"]
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: MagazineRifleIncendiary
|
id: MagazineRifleIncendiary
|
||||||
|
|||||||
@@ -51,6 +51,11 @@
|
|||||||
layers:
|
layers:
|
||||||
- state: base
|
- state: base
|
||||||
map: [ "enum.GunVisualLayers.Base" ]
|
map: [ "enum.GunVisualLayers.Base" ]
|
||||||
|
# TODO: This is actually a issue with all the speed loaders:
|
||||||
|
# You can mix different ammo types, but it will always
|
||||||
|
# use the one it was printed for.
|
||||||
|
- state: base-6
|
||||||
|
map: [ "enum.GunVisualLayers.Mag" ]
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: SpeedLoaderMagnumIncendiary
|
id: SpeedLoaderMagnumIncendiary
|
||||||
|
|||||||
@@ -23,11 +23,6 @@
|
|||||||
- type: Battery
|
- type: Battery
|
||||||
maxCharge: 1000
|
maxCharge: 1000
|
||||||
startingCharge: 1000
|
startingCharge: 1000
|
||||||
- type: MagazineVisuals
|
|
||||||
magState: mag
|
|
||||||
steps: 5
|
|
||||||
zeroVisible: false
|
|
||||||
- type: Appearance
|
|
||||||
- type: StaticPrice
|
- type: StaticPrice
|
||||||
price: 500
|
price: 500
|
||||||
|
|
||||||
@@ -160,6 +155,11 @@
|
|||||||
- state: mag-unshaded-4
|
- state: mag-unshaded-4
|
||||||
map: ["enum.GunVisualLayers.MagUnshaded"]
|
map: ["enum.GunVisualLayers.MagUnshaded"]
|
||||||
shader: unshaded
|
shader: unshaded
|
||||||
|
- type: MagazineVisuals
|
||||||
|
magState: mag
|
||||||
|
steps: 5
|
||||||
|
zeroVisible: false
|
||||||
|
- type: Appearance
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
sprite: Objects/Weapons/Guns/Battery/makeshift.rsi
|
sprite: Objects/Weapons/Guns/Battery/makeshift.rsi
|
||||||
- type: HitscanBatteryAmmoProvider
|
- type: HitscanBatteryAmmoProvider
|
||||||
@@ -212,6 +212,11 @@
|
|||||||
- state: mag-unshaded-4
|
- state: mag-unshaded-4
|
||||||
map: ["enum.GunVisualLayers.MagUnshaded"]
|
map: ["enum.GunVisualLayers.MagUnshaded"]
|
||||||
shader: unshaded
|
shader: unshaded
|
||||||
|
- type: MagazineVisuals
|
||||||
|
magState: mag
|
||||||
|
steps: 5
|
||||||
|
zeroVisible: false
|
||||||
|
- type: Appearance
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
sprite: Objects/Weapons/Guns/Battery/laser_gun.rsi
|
sprite: Objects/Weapons/Guns/Battery/laser_gun.rsi
|
||||||
- type: Gun
|
- type: Gun
|
||||||
@@ -250,6 +255,11 @@
|
|||||||
- state: mag-unshaded-4
|
- state: mag-unshaded-4
|
||||||
map: ["enum.GunVisualLayers.MagUnshaded"]
|
map: ["enum.GunVisualLayers.MagUnshaded"]
|
||||||
shader: unshaded
|
shader: unshaded
|
||||||
|
- type: MagazineVisuals
|
||||||
|
magState: mag
|
||||||
|
steps: 5
|
||||||
|
zeroVisible: false
|
||||||
|
- type: Appearance
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
sprite: Objects/Weapons/Guns/Battery/pulse_pistol.rsi
|
sprite: Objects/Weapons/Guns/Battery/pulse_pistol.rsi
|
||||||
- type: Gun
|
- type: Gun
|
||||||
@@ -279,6 +289,11 @@
|
|||||||
- state: mag-unshaded-4
|
- state: mag-unshaded-4
|
||||||
map: ["enum.GunVisualLayers.MagUnshaded"]
|
map: ["enum.GunVisualLayers.MagUnshaded"]
|
||||||
shader: unshaded
|
shader: unshaded
|
||||||
|
- type: MagazineVisuals
|
||||||
|
magState: mag
|
||||||
|
steps: 5
|
||||||
|
zeroVisible: false
|
||||||
|
- type: Appearance
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
sprite: Objects/Weapons/Guns/Battery/pulse_carbine.rsi
|
sprite: Objects/Weapons/Guns/Battery/pulse_carbine.rsi
|
||||||
- type: Gun
|
- type: Gun
|
||||||
@@ -310,6 +325,11 @@
|
|||||||
- state: mag-unshaded-4
|
- state: mag-unshaded-4
|
||||||
map: ["enum.GunVisualLayers.MagUnshaded"]
|
map: ["enum.GunVisualLayers.MagUnshaded"]
|
||||||
shader: unshaded
|
shader: unshaded
|
||||||
|
- type: MagazineVisuals
|
||||||
|
magState: mag
|
||||||
|
steps: 5
|
||||||
|
zeroVisible: false
|
||||||
|
- type: Appearance
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
sprite: Objects/Weapons/Guns/Battery/pulse_rifle.rsi
|
sprite: Objects/Weapons/Guns/Battery/pulse_rifle.rsi
|
||||||
- type: Gun
|
- type: Gun
|
||||||
@@ -337,6 +357,11 @@
|
|||||||
- state: mag-unshaded-4
|
- state: mag-unshaded-4
|
||||||
map: ["enum.GunVisualLayers.MagUnshaded"]
|
map: ["enum.GunVisualLayers.MagUnshaded"]
|
||||||
shader: unshaded
|
shader: unshaded
|
||||||
|
- type: MagazineVisuals
|
||||||
|
magState: mag
|
||||||
|
steps: 5
|
||||||
|
zeroVisible: false
|
||||||
|
- type: Appearance
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
sprite: Objects/Weapons/Guns/Battery/laser_cannon.rsi
|
sprite: Objects/Weapons/Guns/Battery/laser_cannon.rsi
|
||||||
- type: Gun
|
- type: Gun
|
||||||
@@ -507,6 +532,7 @@
|
|||||||
magState: mag
|
magState: mag
|
||||||
steps: 5
|
steps: 5
|
||||||
zeroVisible: true
|
zeroVisible: true
|
||||||
|
- type: Appearance
|
||||||
- type: StaticPrice
|
- type: StaticPrice
|
||||||
price: 260
|
price: 260
|
||||||
|
|
||||||
@@ -711,11 +737,6 @@
|
|||||||
- type: BatterySelfRecharger
|
- type: BatterySelfRecharger
|
||||||
autoRecharge: true
|
autoRecharge: true
|
||||||
autoRechargeRate: 40
|
autoRechargeRate: 40
|
||||||
- type: MagazineVisuals
|
|
||||||
magState: mag
|
|
||||||
steps: 5
|
|
||||||
zeroVisible: true
|
|
||||||
- type: Appearance
|
|
||||||
- type: StaticPrice
|
- type: StaticPrice
|
||||||
price: 750
|
price: 750
|
||||||
|
|
||||||
@@ -733,6 +754,11 @@
|
|||||||
- state: mag-unshaded-4
|
- state: mag-unshaded-4
|
||||||
map: ["enum.GunVisualLayers.MagUnshaded"]
|
map: ["enum.GunVisualLayers.MagUnshaded"]
|
||||||
shader: unshaded
|
shader: unshaded
|
||||||
|
- type: MagazineVisuals
|
||||||
|
magState: mag
|
||||||
|
steps: 5
|
||||||
|
zeroVisible: false
|
||||||
|
- type: Appearance
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
sprite: Objects/Weapons/Guns/Battery/energy_shotgun.rsi
|
sprite: Objects/Weapons/Guns/Battery/energy_shotgun.rsi
|
||||||
- type: Gun
|
- type: Gun
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
sprite: Objects/Weapons/Guns/HMGs/minigun.rsi
|
sprite: Objects/Weapons/Guns/HMGs/minigun.rsi
|
||||||
layers:
|
layers:
|
||||||
- state: icon
|
- state: icon
|
||||||
map: ["enum.GunVisualLayers.Base"]
|
|
||||||
- type: Item
|
- type: Item
|
||||||
sprite: Objects/Weapons/Guns/HMGs/minigun.rsi
|
sprite: Objects/Weapons/Guns/HMGs/minigun.rsi
|
||||||
- type: Gun
|
- type: Gun
|
||||||
@@ -41,11 +40,6 @@
|
|||||||
- type: BallisticAmmoProvider
|
- type: BallisticAmmoProvider
|
||||||
proto: CartridgeMinigun
|
proto: CartridgeMinigun
|
||||||
capacity: 1000
|
capacity: 1000
|
||||||
- type: MagazineVisuals
|
|
||||||
magState: mag
|
|
||||||
steps: 4
|
|
||||||
zeroVisible: true
|
|
||||||
- type: Appearance
|
|
||||||
- type: ContainerContainer
|
- type: ContainerContainer
|
||||||
containers:
|
containers:
|
||||||
ballistic-ammo: !type:Container
|
ballistic-ammo: !type:Container
|
||||||
|
|||||||
@@ -117,7 +117,7 @@
|
|||||||
path: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg
|
path: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg
|
||||||
- type: MagazineVisuals
|
- type: MagazineVisuals
|
||||||
magState: mag
|
magState: mag
|
||||||
steps: 1
|
steps: 2
|
||||||
zeroVisible: true
|
zeroVisible: true
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user