Un-revert #26994
This commit is contained in:
@@ -10,9 +10,8 @@ namespace Content.IntegrationTests.Pair;
|
||||
public sealed class TestMapData
|
||||
{
|
||||
public EntityUid MapUid { get; set; }
|
||||
public EntityUid GridUid { get; set; }
|
||||
public MapId MapId { get; set; }
|
||||
public MapGridComponent MapGrid { get; set; } = default!;
|
||||
public Entity<MapGridComponent> Grid;
|
||||
public MapId MapId;
|
||||
public EntityCoordinates GridCoords { get; set; }
|
||||
public MapCoordinates MapCoords { get; set; }
|
||||
public TileRef Tile { get; set; }
|
||||
@@ -21,4 +20,4 @@ public sealed class TestMapData
|
||||
public EntityUid CMapUid { get; set; }
|
||||
public EntityUid CGridUid { get; set; }
|
||||
public EntityCoordinates CGridCoords { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
@@ -14,36 +15,37 @@ public sealed partial class TestPair
|
||||
/// <summary>
|
||||
/// Creates a map, a grid, and a tile, and gives back references to them.
|
||||
/// </summary>
|
||||
public async Task<TestMapData> CreateTestMap()
|
||||
[MemberNotNull(nameof(TestMap))]
|
||||
public async Task<TestMapData> CreateTestMap(bool initialized = true, string tile = "Plating")
|
||||
{
|
||||
var mapData = new TestMapData();
|
||||
TestMap = mapData;
|
||||
await Server.WaitIdleAsync();
|
||||
var tileDefinitionManager = Server.ResolveDependency<ITileDefinitionManager>();
|
||||
|
||||
var mapData = new TestMapData();
|
||||
TestMap = mapData;
|
||||
await Server.WaitPost(() =>
|
||||
{
|
||||
mapData.MapId = Server.MapMan.CreateMap();
|
||||
mapData.MapUid = Server.MapMan.GetMapEntityId(mapData.MapId);
|
||||
var mapGrid = Server.MapMan.CreateGridEntity(mapData.MapId);
|
||||
mapData.MapGrid = mapGrid;
|
||||
mapData.GridUid = mapGrid.Owner; // Fixing this requires an engine PR.
|
||||
mapData.GridCoords = new EntityCoordinates(mapData.GridUid, 0, 0);
|
||||
var plating = tileDefinitionManager["Plating"];
|
||||
mapData.MapUid = Server.System<SharedMapSystem>().CreateMap(out mapData.MapId, runMapInit: initialized);
|
||||
mapData.Grid = Server.MapMan.CreateGridEntity(mapData.MapId);
|
||||
mapData.GridCoords = new EntityCoordinates(mapData.Grid, 0, 0);
|
||||
var plating = tileDefinitionManager[tile];
|
||||
var platingTile = new Tile(plating.TileId);
|
||||
mapData.MapGrid.SetTile(mapData.GridCoords, platingTile);
|
||||
mapData.Grid.Comp.SetTile(mapData.GridCoords, platingTile);
|
||||
mapData.MapCoords = new MapCoordinates(0, 0, mapData.MapId);
|
||||
mapData.Tile = mapData.MapGrid.GetAllTiles().First();
|
||||
mapData.Tile = mapData.Grid.Comp.GetAllTiles().First();
|
||||
});
|
||||
|
||||
TestMap = mapData;
|
||||
if (!Settings.Connected)
|
||||
return mapData;
|
||||
|
||||
await RunTicksSync(10);
|
||||
mapData.CMapUid = ToClientUid(mapData.MapUid);
|
||||
mapData.CGridUid = ToClientUid(mapData.GridUid);
|
||||
mapData.CGridUid = ToClientUid(mapData.Grid);
|
||||
mapData.CGridCoords = new EntityCoordinates(mapData.CGridUid, 0, 0);
|
||||
|
||||
TestMap = mapData;
|
||||
return mapData;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ public sealed class AddTests
|
||||
|
||||
var guid = Guid.NewGuid();
|
||||
|
||||
var testMap = await pair.CreateTestMap();
|
||||
var coordinates = testMap.GridCoords;
|
||||
await pair.CreateTestMap();
|
||||
var coordinates = pair.TestMap.GridCoords;
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
var entity = sEntities.SpawnEntity(null, coordinates);
|
||||
|
||||
@@ -212,7 +212,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
|
||||
DeviceNetworkComponent networkComponent1 = null;
|
||||
DeviceNetworkComponent networkComponent2 = null;
|
||||
WiredNetworkComponent wiredNetworkComponent = null;
|
||||
var grid = testMap.MapGrid;
|
||||
var grid = testMap.Grid.Comp;
|
||||
|
||||
var testValue = "test";
|
||||
var payload = new NetworkPayload
|
||||
|
||||
@@ -354,41 +354,18 @@ namespace Content.IntegrationTests.Tests
|
||||
|
||||
await using var pair = await PoolManager.GetServerClient();
|
||||
var server = pair.Server;
|
||||
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var entityManager = server.ResolveDependency<IEntityManager>();
|
||||
var componentFactory = server.ResolveDependency<IComponentFactory>();
|
||||
var tileDefinitionManager = server.ResolveDependency<ITileDefinitionManager>();
|
||||
var mapSystem = entityManager.System<SharedMapSystem>();
|
||||
var logmill = server.ResolveDependency<ILogManager>().GetSawmill("EntityTest");
|
||||
|
||||
Entity<MapGridComponent> grid = default!;
|
||||
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
// Create a one tile grid to stave off the grid 0 monsters
|
||||
var mapId = mapManager.CreateMap();
|
||||
|
||||
mapManager.AddUninitializedMap(mapId);
|
||||
|
||||
grid = mapManager.CreateGridEntity(mapId);
|
||||
|
||||
var tileDefinition = tileDefinitionManager["Plating"];
|
||||
var tile = new Tile(tileDefinition.TileId);
|
||||
var coordinates = new EntityCoordinates(grid.Owner, Vector2.Zero);
|
||||
|
||||
mapSystem.SetTile(grid.Owner, grid.Comp!, coordinates, tile);
|
||||
|
||||
mapManager.DoMapInitialize(mapId);
|
||||
});
|
||||
|
||||
await pair.CreateTestMap();
|
||||
await server.WaitRunTicks(5);
|
||||
var testLocation = pair.TestMap.GridCoords;
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
var testLocation = new EntityCoordinates(grid.Owner, Vector2.Zero);
|
||||
|
||||
foreach (var type in componentFactory.AllRegisteredTypes)
|
||||
{
|
||||
|
||||
@@ -46,17 +46,14 @@ namespace Content.IntegrationTests.Tests.Fluids
|
||||
var server = pair.Server;
|
||||
|
||||
var testMap = await pair.CreateTestMap();
|
||||
var grid = testMap.Grid.Comp;
|
||||
|
||||
var entitySystemManager = server.ResolveDependency<IEntitySystemManager>();
|
||||
var spillSystem = entitySystemManager.GetEntitySystem<PuddleSystem>();
|
||||
|
||||
MapGridComponent grid = null;
|
||||
|
||||
// Remove all tiles
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
grid = testMap.MapGrid;
|
||||
|
||||
foreach (var tile in grid.GetAllTiles())
|
||||
{
|
||||
grid.SetTile(tile.GridIndices, Tile.Empty);
|
||||
|
||||
@@ -989,7 +989,7 @@ public abstract partial class InteractionTest
|
||||
/// </summary>
|
||||
protected async Task AddGravity(EntityUid? uid = null)
|
||||
{
|
||||
var target = uid ?? MapData.GridUid;
|
||||
var target = uid ?? MapData.Grid;
|
||||
await Server.WaitPost(() =>
|
||||
{
|
||||
var gravity = SEntMan.EnsureComponent<GravityComponent>(target);
|
||||
|
||||
@@ -184,7 +184,7 @@ public abstract partial class InteractionTest
|
||||
await Pair.CreateTestMap();
|
||||
PlayerCoords = SEntMan.GetNetCoordinates(MapData.GridCoords.Offset(new Vector2(0.5f, 0.5f)).WithEntityId(MapData.MapUid, Transform, SEntMan));
|
||||
TargetCoords = SEntMan.GetNetCoordinates(MapData.GridCoords.Offset(new Vector2(1.5f, 0.5f)).WithEntityId(MapData.MapUid, Transform, SEntMan));
|
||||
await SetTile(Plating, grid: MapData.MapGrid);
|
||||
await SetTile(Plating, grid: MapData.Grid.Comp);
|
||||
|
||||
// Get player data
|
||||
var sPlayerMan = Server.ResolveDependency<Robust.Server.Player.IPlayerManager>();
|
||||
|
||||
@@ -31,7 +31,7 @@ public abstract class MovementTest : InteractionTest
|
||||
|
||||
for (var i = -Tiles; i <= Tiles; i++)
|
||||
{
|
||||
await SetTile(Plating, SEntMan.GetNetCoordinates(pCoords.Offset(new Vector2(i, 0))), MapData.MapGrid);
|
||||
await SetTile(Plating, SEntMan.GetNetCoordinates(pCoords.Offset(new Vector2(i, 0))), MapData.Grid.Comp);
|
||||
}
|
||||
AssertGridCount(1);
|
||||
|
||||
|
||||
@@ -38,31 +38,15 @@ public sealed class PrototypeSaveTest
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var entityMan = server.ResolveDependency<IEntityManager>();
|
||||
var prototypeMan = server.ResolveDependency<IPrototypeManager>();
|
||||
var tileDefinitionManager = server.ResolveDependency<ITileDefinitionManager>();
|
||||
var seriMan = server.ResolveDependency<ISerializationManager>();
|
||||
var compFact = server.ResolveDependency<IComponentFactory>();
|
||||
|
||||
var prototypes = new List<EntityPrototype>();
|
||||
MapGridComponent grid = default!;
|
||||
EntityUid uid;
|
||||
MapId mapId = default;
|
||||
|
||||
//Build up test environment
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
// Create a one tile grid to stave off the grid 0 monsters
|
||||
mapId = mapManager.CreateMap();
|
||||
|
||||
mapManager.AddUninitializedMap(mapId);
|
||||
|
||||
grid = mapManager.CreateGrid(mapId);
|
||||
|
||||
var tileDefinition = tileDefinitionManager["FloorSteel"]; // Wires n such disable ambiance while under the floor
|
||||
var tile = new Tile(tileDefinition.TileId);
|
||||
var coordinates = grid.Owner.ToCoordinates();
|
||||
|
||||
grid.SetTile(coordinates, tile);
|
||||
});
|
||||
await pair.CreateTestMap(false, "FloorSteel"); // Wires n such disable ambiance while under the floor
|
||||
var mapId = pair.TestMap.MapId;
|
||||
var grid = pair.TestMap.Grid;
|
||||
|
||||
await server.WaitRunTicks(5);
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public sealed class DockTest : ContentUnitTest
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
entManager.DeleteEntity(map.GridUid);
|
||||
entManager.DeleteEntity(map.Grid);
|
||||
var grid1 = mapManager.CreateGridEntity(mapId);
|
||||
var grid2 = mapManager.CreateGridEntity(mapId);
|
||||
var grid1Ent = grid1.Owner;
|
||||
@@ -104,7 +104,7 @@ public sealed class DockTest : ContentUnitTest
|
||||
// Spawn shuttle and affirm no valid docks.
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
entManager.DeleteEntity(map.GridUid);
|
||||
entManager.DeleteEntity(map.Grid);
|
||||
Assert.That(entManager.System<MapLoaderSystem>().TryLoad(otherMap.MapId, "/Maps/Shuttles/emergency.yml", out var rootUids));
|
||||
shuttle = rootUids[0];
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public sealed class TileConstructionTests : InteractionTest
|
||||
// Remove grid
|
||||
await SetTile(null);
|
||||
await SetTile(null, PlayerCoords);
|
||||
Assert.That(MapData.MapGrid.Deleted);
|
||||
Assert.That(MapData.Grid.Comp.Deleted);
|
||||
AssertGridCount(0);
|
||||
|
||||
// Place Lattice
|
||||
@@ -70,7 +70,7 @@ public sealed class TileConstructionTests : InteractionTest
|
||||
// Remove grid
|
||||
await SetTile(null);
|
||||
await SetTile(null, PlayerCoords);
|
||||
Assert.That(MapData.MapGrid.Deleted);
|
||||
Assert.That(MapData.Grid.Comp.Deleted);
|
||||
AssertGridCount(0);
|
||||
|
||||
// Space -> Lattice
|
||||
|
||||
Reference in New Issue
Block a user