Fix maploading once and for all. (#7501)

This commit is contained in:
Moony
2022-04-15 16:35:58 -05:00
committed by GitHub
parent cdfde3edf1
commit 4d70395d11
8 changed files with 217 additions and 135 deletions

View File

@@ -64,7 +64,7 @@ namespace Content.IntegrationTests.Tests.Body
MetabolizerSystem metaSys = default;
MapId mapId;
IMapGrid grid = null;
GridId? grid = null;
SharedBodyComponent body = default;
EntityUid human = default;
GridAtmosphereComponent relevantAtmos = default;
@@ -75,7 +75,7 @@ namespace Content.IntegrationTests.Tests.Body
await server.WaitPost(() =>
{
mapId = mapManager.CreateMap();
grid = mapLoader.LoadBlueprint(mapId, testMapName);
grid = mapLoader.LoadBlueprint(mapId, testMapName).gridId;
});
Assert.NotNull(grid, $"Test blueprint {testMapName} not found.");
@@ -94,11 +94,12 @@ namespace Content.IntegrationTests.Tests.Body
await server.WaitAssertion(() =>
{
var coords = new Vector2(0.5f, -1f);
var coordinates = new EntityCoordinates(grid.GridEntityId, coords);
var geid = mapManager.GetGridEuid(grid.Value);
var coordinates = new EntityCoordinates(geid, coords);
human = entityManager.SpawnEntity("HumanBodyDummy", coordinates);
respSys = EntitySystem.Get<RespiratorSystem>();
metaSys = EntitySystem.Get<MetabolizerSystem>();
relevantAtmos = entityManager.GetComponent<GridAtmosphereComponent>(grid.GridEntityId);
relevantAtmos = entityManager.GetComponent<GridAtmosphereComponent>(geid);
startingMoles = GetMapMoles();
Assert.True(entityManager.TryGetComponent(human, out body));
@@ -140,7 +141,7 @@ namespace Content.IntegrationTests.Tests.Body
var entityManager = server.ResolveDependency<IEntityManager>();
MapId mapId;
IMapGrid grid = null;
GridId? grid = null;
RespiratorComponent respirator = null;
EntityUid human = default;
@@ -149,7 +150,7 @@ namespace Content.IntegrationTests.Tests.Body
await server.WaitPost(() =>
{
mapId = mapManager.CreateMap();
grid = mapLoader.LoadBlueprint(mapId, testMapName);
grid = mapLoader.LoadBlueprint(mapId, testMapName).gridId;
});
Assert.NotNull(grid, $"Test blueprint {testMapName} not found.");
@@ -157,7 +158,8 @@ namespace Content.IntegrationTests.Tests.Body
await server.WaitAssertion(() =>
{
var center = new Vector2(0.5f, -1.5f);
var coordinates = new EntityCoordinates(grid.GridEntityId, center);
var geid = mapManager.GetGridEuid(grid.Value);
var coordinates = new EntityCoordinates(geid, center);
human = entityManager.SpawnEntity("HumanBodyDummy", coordinates);
Assert.True(entityManager.HasComponent<SharedBodyComponent>(human));

View File

@@ -59,15 +59,15 @@ public sealed class FluidSpill : ContentIntegrationTest
var spillSystem = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<SpillableSystem>();
var gameTiming = server.ResolveDependency<IGameTiming>();
MapId mapId;
IMapGrid? grid = null;
GridId? gridid = null;
await server.WaitPost(() =>
{
mapId = mapManager.CreateMap();
grid = mapLoader.LoadBlueprint(mapId, SpillMapsYml)!;
gridid = mapLoader.LoadBlueprint(mapId, SpillMapsYml).gridId;
});
if (grid == null)
if (gridid == null)
{
Assert.Fail($"Test blueprint {SpillMapsYml} not found.");
return;
@@ -75,6 +75,7 @@ public sealed class FluidSpill : ContentIntegrationTest
await server.WaitAssertion(() =>
{
var grid = mapManager.GetGrid(gridid.Value);
var solution = new Solution("Water", FixedPoint2.New(100));
var tileRef = grid.GetTileRef(_origin);
var puddle = spillSystem.SpillAt(tileRef, solution, "PuddleSmear");
@@ -87,6 +88,7 @@ public sealed class FluidSpill : ContentIntegrationTest
server.Assert(() =>
{
var grid = mapManager.GetGrid(gridid.Value);
var puddle = GetPuddle(entityManager, grid, _origin);
Assert.That(puddle, Is.Not.Null);
@@ -118,15 +120,15 @@ public sealed class FluidSpill : ContentIntegrationTest
var spillSystem = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<SpillableSystem>();
var gameTiming = server.ResolveDependency<IGameTiming>();
MapId mapId;
IMapGrid? grid = null;
GridId? gridId = null;
await server.WaitPost(() =>
{
mapId = mapManager.CreateMap();
grid = mapLoader.LoadBlueprint(mapId, SpillMapsYml)!;
gridId = mapLoader.LoadBlueprint(mapId, SpillMapsYml).gridId;
});
if (grid == null)
if (gridId == null)
{
Assert.Fail($"Test blueprint {SpillMapsYml} not found.");
return;
@@ -135,14 +137,14 @@ public sealed class FluidSpill : ContentIntegrationTest
await server.WaitAssertion(() =>
{
var solution = new Solution("Water", FixedPoint2.New(20.01));
var grid = mapManager.GetGrid(gridId.Value);
var tileRef = grid.GetTileRef(_origin);
var puddle = spillSystem.SpillAt(tileRef, solution, "PuddleSmear");
Assert.That(puddle, Is.Not.Null);
});
if (grid == null)
if (gridId == null)
{
Assert.Fail($"Test blueprint {SpillMapsYml} not found.");
return;
@@ -153,6 +155,7 @@ public sealed class FluidSpill : ContentIntegrationTest
server.Assert(() =>
{
var grid = mapManager.GetGrid(gridId.Value);
var puddle = GetPuddle(entityManager, grid, _origin);
Assert.That(puddle, Is.Not.Null);
Assert.That(puddle!.CurrentVolume, Is.EqualTo(FixedPoint2.New(20)));

View File

@@ -28,8 +28,8 @@ namespace Content.IntegrationTests.Tests
// TODO: Un-hardcode the grid Id for this test.
mapLoader.SaveBlueprint(new GridId(1), "save load save 1.yml");
var mapId = mapManager.CreateMap();
var grid = mapLoader.LoadBlueprint(mapId, "save load save 1.yml");
mapLoader.SaveBlueprint(grid!.Index, "save load save 2.yml");
var grid = mapLoader.LoadBlueprint(mapId, "save load save 1.yml").gridId;
mapLoader.SaveBlueprint(grid!.Value, "save load save 2.yml");
});
await server.WaitIdleAsync();
@@ -83,7 +83,7 @@ namespace Content.IntegrationTests.Tests
var mapLoader = server.ResolveDependency<IMapLoader>();
var mapManager = server.ResolveDependency<IMapManager>();
IMapGrid grid = default;
GridId? grid = default;
// Load saltern.yml as uninitialized map, and save it to ensure it's up to date.
server.Post(() =>
@@ -91,8 +91,8 @@ namespace Content.IntegrationTests.Tests
var mapId = mapManager.CreateMap();
mapManager.AddUninitializedMap(mapId);
mapManager.SetMapPaused(mapId, true);
grid = mapLoader.LoadBlueprint(mapId, "Maps/saltern.yml");
mapLoader.SaveBlueprint(grid.Index, "load save ticks save 1.yml");
grid = mapLoader.LoadBlueprint(mapId, "Maps/saltern.yml").gridId;
mapLoader.SaveBlueprint(grid!.Value, "load save ticks save 1.yml");
});
// Run 5 ticks.
@@ -100,7 +100,7 @@ namespace Content.IntegrationTests.Tests
server.Post(() =>
{
mapLoader.SaveBlueprint(grid.Index, "/load save ticks save 2.yml");
mapLoader.SaveBlueprint(grid!.Value, "/load save ticks save 2.yml");
});
await server.WaitIdleAsync();