From 9754944f1138acd5873c00422431b7a3a7ada6ca Mon Sep 17 00:00:00 2001 From: "Ignaz \"Ian\" Kraft" Date: Sat, 3 Jan 2026 02:20:41 +0100 Subject: [PATCH] expanded FillLevelSpriteTest test and fixed found issues (#34165) * fix clustersoap eaten sprite * also assure that every entity with the SolutionContainerVisualsComponent has a AppearanceComponent * use the new sprite system + fix the fill for cardboard arrows and the mosin * fix merge issue --- .../Tests/FillLevelSpriteTest.cs | 80 +++++++++++++----- .../Objects/Specific/Janitorial/soap.yml | 15 ++-- .../Weapons/Guns/Projectiles/arrows.yml | 3 + .../Weapons/Throwable/scattering_grenades.yml | 1 + ...ck-fill-1.png => equipped-back-fill-1.png} | Bin .../Guns/Snipers/bolt_gun_wood.rsi/meta.json | 2 +- 6 files changed, 73 insertions(+), 28 deletions(-) rename Resources/Textures/Objects/Weapons/Guns/Snipers/bolt_gun_wood.rsi/{equipped-backpack-fill-1.png => equipped-back-fill-1.png} (100%) diff --git a/Content.IntegrationTests/Tests/FillLevelSpriteTest.cs b/Content.IntegrationTests/Tests/FillLevelSpriteTest.cs index 37e777fa8c..99354e16c1 100644 --- a/Content.IntegrationTests/Tests/FillLevelSpriteTest.cs +++ b/Content.IntegrationTests/Tests/FillLevelSpriteTest.cs @@ -1,5 +1,7 @@ using System.Linq; +using Content.Shared.Chemistry; using Content.Shared.Chemistry.Components; +using Content.Shared.Prototypes; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.Prototypes; @@ -13,14 +15,17 @@ namespace Content.IntegrationTests.Tests; public sealed class FillLevelSpriteTest { private static readonly string[] HandStateNames = ["left", "right"]; + private static readonly string[] EquipStateNames = ["back", "suitstorage"]; [Test] public async Task FillLevelSpritesExist() { - await using var pair = await PoolManager.GetServerClient(); + await using var pair = await PoolManager.GetServerClient(new PoolSettings { Connected = true }); var client = pair.Client; var protoMan = client.ResolveDependency(); var componentFactory = client.ResolveDependency(); + var entMan = client.ResolveDependency(); + var spriteSystem = client.System(); await client.WaitAssertion(() => { @@ -31,39 +36,70 @@ public sealed class FillLevelSpriteTest .OrderBy(p => p.ID) .ToList(); - foreach (var proto in protos) + Assert.Multiple(() => { - Assert.That(proto.TryGetComponent(out var visuals, componentFactory)); - Assert.That(proto.TryGetComponent(out var sprite, componentFactory)); - - var rsi = sprite.BaseRSI; - - // Test base sprite fills - if (!string.IsNullOrEmpty(visuals.FillBaseName)) + foreach (var proto in protos) { - for (var i = 1; i <= visuals.MaxFillLevels; i++) + Assert.That(proto.TryGetComponent(out var visuals, componentFactory)); + Assert.That(proto.TryGetComponent(out var sprite, componentFactory)); + if (!proto.HasComponent(componentFactory)) { - 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}!"); + Assert.Fail(@$"{proto.ID} has SolutionContainerVisualsComponent but no AppearanceComponent."); } - } - // Test inhand sprite fills - if (!string.IsNullOrEmpty(visuals.InHandsFillBaseName)) - { - for (var i = 1; i <= visuals.InHandsMaxFillLevels; i++) + // Test base sprite fills + if (!string.IsNullOrEmpty(visuals.FillBaseName) && visuals.MaxFillLevels > 0) { - foreach (var handname in HandStateNames) + var entity = entMan.Spawn(proto.ID); + if (!spriteSystem.LayerMapTryGet(entity, SolutionContainerLayers.Fill, out var fillLayerId, false)) + { + Assert.Fail(@$"{proto.ID} has SolutionContainerVisualsComponent but no fill layer map."); + } + if (!spriteSystem.TryGetLayer(entity, fillLayerId, out var fillLayer, false)) + { + Assert.Fail(@$"{proto.ID} somehow lost a layer."); + } + var rsi = fillLayer.ActualRsi; + + for (var i = 1; i <= visuals.MaxFillLevels; i++) { - var state = $"inhand-{handname}{visuals.InHandsFillBaseName}{i}"; + var state = $"{visuals.FillBaseName}{i}"; Assert.That(rsi.TryGetState(state, out _), @$"{proto.ID} has SolutionContainerVisualsComponent with - InHandsMaxFillLevels = {visuals.InHandsMaxFillLevels}, but {rsi.Path} doesn't have state {state}!"); + MaxFillLevels = {visuals.MaxFillLevels}, but {rsi.Path} doesn't have state {state}!"); } + } + // Test inhand sprite fills + if (!string.IsNullOrEmpty(visuals.InHandsFillBaseName) && visuals.InHandsMaxFillLevels > 0) + { + var rsi = sprite.BaseRSI; + 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}!"); + } + } + } + + // Test equipped sprite fills + if (!string.IsNullOrEmpty(visuals.EquippedFillBaseName) && visuals.EquippedMaxFillLevels > 0) + { + var rsi = sprite.BaseRSI; + for (var i = 1; i <= visuals.EquippedMaxFillLevels; i++) + { + foreach (var equipName in EquipStateNames) + { + var state = $"equipped-{equipName}{visuals.EquippedFillBaseName}{i}"; + Assert.That(rsi.TryGetState(state, out _), @$"{proto.ID} has SolutionContainerVisualsComponent with + EquippedMaxFillLevels = {visuals.EquippedMaxFillLevels}, but {rsi.Path} doesn't have state {state}!"); + } + } } } - } + }); }); await pair.CleanReturnAsync(); diff --git a/Resources/Prototypes/Entities/Objects/Specific/Janitorial/soap.yml b/Resources/Prototypes/Entities/Objects/Specific/Janitorial/soap.yml index e4cfd8d347..69eff77aeb 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Janitorial/soap.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Janitorial/soap.yml @@ -156,16 +156,18 @@ description: A tiny piece of syndicate soap. categories: [ HideSpawnMenu ] components: - - type: Sprite - layers: - - state: syndie-soaplet - type: SolutionContainerManager solutions: soap: - maxVol: 10 + maxVol: 1.5 # 50 / 30 = 1.666 reagents: - ReagentId: SoapReagent - Quantity: 10 + Quantity: 1.5 + - type: SolutionContainerVisuals + maxFillLevels: 0 + - type: Sprite + layers: + - state: syndie-soaplet - type: Slippery - type: StepTrigger intersectRatio: 0.04 @@ -196,6 +198,9 @@ path: "/Audio/Effects/Fluids/splat.ogg" params: volume: -8 + - type: Residue + residueAdjective: residue-slippery + residueColor: residue-red - type: entity parent: BaseSoap diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/arrows.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/arrows.yml index 0a577b51db..d61b78f1ed 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/arrows.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/arrows.yml @@ -201,6 +201,9 @@ color: brown - state: tip color: brown + - state: solution1 + map: ["enum.SolutionContainerLayers.Fill"] + visible: false - type: Projectile damage: types: diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Throwable/scattering_grenades.yml b/Resources/Prototypes/Entities/Objects/Weapons/Throwable/scattering_grenades.yml index 6bff4fbd44..627835ddd3 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Throwable/scattering_grenades.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Throwable/scattering_grenades.yml @@ -146,6 +146,7 @@ sprite: Objects/Specific/Janitorial/soap.rsi layers: - state: syndie-4 + map: ["enum.SolutionContainerLayers.Fill"] - type: ScatteringGrenade fillPrototype: SoapletSyndie capacity: 30 diff --git a/Resources/Textures/Objects/Weapons/Guns/Snipers/bolt_gun_wood.rsi/equipped-backpack-fill-1.png b/Resources/Textures/Objects/Weapons/Guns/Snipers/bolt_gun_wood.rsi/equipped-back-fill-1.png similarity index 100% rename from Resources/Textures/Objects/Weapons/Guns/Snipers/bolt_gun_wood.rsi/equipped-backpack-fill-1.png rename to Resources/Textures/Objects/Weapons/Guns/Snipers/bolt_gun_wood.rsi/equipped-back-fill-1.png diff --git a/Resources/Textures/Objects/Weapons/Guns/Snipers/bolt_gun_wood.rsi/meta.json b/Resources/Textures/Objects/Weapons/Guns/Snipers/bolt_gun_wood.rsi/meta.json index c9436ead7b..7c9dbbe119 100644 --- a/Resources/Textures/Objects/Weapons/Guns/Snipers/bolt_gun_wood.rsi/meta.json +++ b/Resources/Textures/Objects/Weapons/Guns/Snipers/bolt_gun_wood.rsi/meta.json @@ -53,7 +53,7 @@ "directions": 4 }, { - "name": "equipped-backpack-fill-1", + "name": "equipped-back-fill-1", "directions": 4 }, { -- 2.52.0