From 2a1798ff4c002ddcaabc66bd7fd6e86d36ebbff8 Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Tue, 28 Feb 2023 11:12:24 -0500 Subject: [PATCH] salvage bounds test (#13793) --- Content.IntegrationTests/Tests/SalvageTest.cs | 42 +++++++++++++++++++ Resources/Prototypes/Maps/salvage.yml | 30 ++++++------- 2 files changed, 57 insertions(+), 15 deletions(-) create mode 100644 Content.IntegrationTests/Tests/SalvageTest.cs diff --git a/Content.IntegrationTests/Tests/SalvageTest.cs b/Content.IntegrationTests/Tests/SalvageTest.cs new file mode 100644 index 0000000000..6263c89ecf --- /dev/null +++ b/Content.IntegrationTests/Tests/SalvageTest.cs @@ -0,0 +1,42 @@ +using System.Threading.Tasks; +using Content.Server.Salvage; +using NUnit.Framework; +using Robust.Server.GameObjects; +using Robust.Shared.GameObjects; +using Robust.Shared.Map; +using Robust.Shared.Map.Components; +using Robust.Shared.Prototypes; + +namespace Content.IntegrationTests.Tests +{ + [TestFixture] + public sealed class SalvageTest + { + [Test] + public async Task SalvageGridBoundsTest() + { + await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true}); + var server = pairTracker.Pair.Server; + await server.WaitIdleAsync(); + + var mapMan = server.ResolveDependency(); + var protoManager = server.ResolveDependency(); + var entManager = server.ResolveDependency(); + var mapLoader = server.ResolveDependency().GetEntitySystem(); + + await server.WaitAssertion(() => + { + foreach (var salvage in protoManager.EnumeratePrototypes()) + { + var mapId = mapMan.CreateMap(); + mapLoader.TryLoad(mapId, salvage.MapPath.ToString(), out var rootUids); + Assert.That(rootUids is { Count: 1 }, $"Salvage map {salvage.ID} does not have a single grid"); + var grid = rootUids[0]; + Assert.That(entManager.TryGetComponent(grid, out var gridComp), $"Salvage {salvage.ID}'s grid does not have GridComponent."); + Assert.That(gridComp.LocalAABB, Is.EqualTo(salvage.Bounds), $"Salvage {salvage.ID}'s bounds {gridComp.LocalAABB} are not equal to the bounds on the prototype {salvage.Bounds}"); + } + }); + await pairTracker.CleanReturnAsync(); + } + } +} diff --git a/Resources/Prototypes/Maps/salvage.yml b/Resources/Prototypes/Maps/salvage.yml index 3b76d33993..a78a944e98 100644 --- a/Resources/Prototypes/Maps/salvage.yml +++ b/Resources/Prototypes/Maps/salvage.yml @@ -9,37 +9,37 @@ id: Small1 name: "Small / Engineering Storage 1" mapPath: /Maps/Salvage/small-1.yml - bounds: "-2.5,-3.5,3.5,3.5" + bounds: "-3,-4,3,3" - type: salvageMap id: Small2 name: "Small / Gaming Nook 1" mapPath: /Maps/Salvage/small-2.yml - bounds: "-3.5,-3.5,3.5,3.5" + bounds: "-4,-4,3,3" - type: salvageMap id: Small-ship-1 name: "Small / Ship 1 (Pill)" mapPath: /Maps/Salvage/small-ship-1.yml - bounds: "-1.5,-0.5,2.5,1.5" + bounds: "-2,-1,2,1" - type: salvageMap id: Small3 name: "Small / Laundromat 1" mapPath: /Maps/Salvage/small-3.yml - bounds: "-3.5,-3.5,2.5,3.5" + bounds: "-4,-4,2,3" - type: salvageMap id: SmallAISurveyDrone name: "Small / AI Survey Drone" mapPath: /Maps/Salvage/small-ai-survey-drone.yml - bounds: "-3.5,-3.5,3.5,3.5" + bounds: "-4,-4,3,3" - type: salvageMap id: Small4 name: "Small / Bar Salvage" mapPath: /Maps/Salvage/small-4.yml - bounds: "-3.5,-3.5,3.5,3.5" + bounds: "-4,-4,3,3" # Small - Asteroids @@ -47,7 +47,7 @@ id: SmallA1 name: "Small / Asteroid 1 Plasmafire" mapPath: /Maps/Salvage/small-a-1.yml - bounds: "-3.5,-3.5,3.5,3.5" + bounds: "-4,-4,3,3" # "Medium"-class maps - Max size square: 15x15, indicated size: 7.5 @@ -55,37 +55,37 @@ id: Medium1 name: "Medium / Plasma-Trapped Cache 1" mapPath: /Maps/Salvage/medium-1.yml - bounds: "-7.5,-7.5,7.5,7.5" + bounds: "-8,-8,7,7" - type: salvageMap id: MediumVault1 name: "Medium / Vault 1" mapPath: /Maps/Salvage/medium-vault-1.yml - bounds: "-7.5,-7.5,7.5,7.5" + bounds: "-8,-8,7,7" - type: salvageMap id: MediumOrchestra name: "Medium / Silent Orchestra" mapPath: /Maps/Salvage/medium-silent-orchestra.yml - bounds: "-7.5,-7.5,7.5,7.5" + bounds: "-8,-8,7,7" - type: salvageMap id: MediumLibraryWreck name: "Medium / Abandoned Library" mapPath: /Maps/Salvage/medium-library.yml - bounds: "-8.5,-8.5,6.5,7.5" + bounds: "-9,-9,6,7" - type: salvageMap id: MediumCargoWreck name: "Medium / Cargo Department Wreck" mapPath: /Maps/Salvage/cargo-1.yml - bounds: "-5.5,-5.5,5.5,9.5" + bounds: "-6,-6,5,9" - type: salvageMap id: MediumPirateWreck name: "Medium / Pirate Barge Fragment" mapPath: /Maps/Salvage/medium-pirate.yml - bounds: "-3.5,-9.5,6.5,7.5" + bounds: "-4,-10,6,7" - type: salvageMap id: TickColony @@ -109,13 +109,13 @@ id: MediumShuttleWreck name: "Medium / Ruined Emergency Shuttle" mapPath: /Maps/Salvage/medium-ruined-emergency-shuttle.yml - bounds: "-8.5,-8.5,8.5,8.5" + bounds: "-6,-9,5,8" - type: salvageMap id: mediumPetHospital name: "Medium / Pet and Bear Hospital" mapPath: /Maps/Salvage/medium-pet-hospital.yml - bounds: "-5.5,-8.5,5.5,8.5" + bounds: "-2,-14,16,2" - type: salvageMap id: MediumCrashedShuttle