mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-11 19:31:12 +03:00
* Axes the easy IMapManager references * Axes the references to unported (obsolete) IMapManager methods * Converts salvageruler command to a LocalizedEntityCommand so it can use SharedMapSystem * Removes IMapManager from GameTicker This required axing the map nuke during restart, but that should be fine? Maps are entities so EntityManager.FlushEntities should delete them all and that's the preceding line * submodule update(?) --------- Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
114 lines
4.1 KiB
C#
114 lines
4.1 KiB
C#
#nullable enable
|
|
using Content.IntegrationTests.Fixtures;
|
|
using Content.Server.Fluids.EntitySystems;
|
|
using Content.Server.Spreader;
|
|
using Content.Shared.Chemistry.Components;
|
|
using Content.Shared.FixedPoint;
|
|
using Content.Shared.Fluids.Components;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Map.Components;
|
|
using Robust.Shared.Maths;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.IntegrationTests.Tests.Fluids;
|
|
|
|
[TestFixture]
|
|
[TestOf(typeof(SpreaderSystem))]
|
|
public sealed class FluidSpill : GameTest
|
|
{
|
|
private static PuddleComponent? GetPuddle(IEntityManager entityManager, Entity<MapGridComponent> mapGrid, Vector2i pos)
|
|
{
|
|
return GetPuddleEntity(entityManager, mapGrid, pos)?.Comp;
|
|
}
|
|
|
|
private static Entity<PuddleComponent>? GetPuddleEntity(IEntityManager entityManager, Entity<MapGridComponent> mapGrid, Vector2i pos)
|
|
{
|
|
var mapSys = entityManager.System<SharedMapSystem>();
|
|
foreach (var uid in mapSys.GetAnchoredEntities(mapGrid, mapGrid.Comp, pos))
|
|
{
|
|
if (entityManager.TryGetComponent(uid, out PuddleComponent? puddleComponent))
|
|
return (uid, puddleComponent);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
[Test]
|
|
public async Task SpillCorner()
|
|
{
|
|
var pair = Pair;
|
|
var server = pair.Server;
|
|
var entityManager = server.ResolveDependency<IEntityManager>();
|
|
var puddleSystem = server.System<PuddleSystem>();
|
|
var mapSystem = server.System<SharedMapSystem>();
|
|
var gameTiming = server.ResolveDependency<IGameTiming>();
|
|
EntityUid gridId = default;
|
|
|
|
/*
|
|
In this test, if o is spillage puddle and # are walls, we want to ensure all tiles are empty (`.`)
|
|
. . .
|
|
# . .
|
|
o # .
|
|
*/
|
|
await server.WaitPost(() =>
|
|
{
|
|
mapSystem.CreateMap(out var mapId);
|
|
var grid = mapSystem.CreateGridEntity(mapId);
|
|
gridId = grid.Owner;
|
|
|
|
for (var x = 0; x < 3; x++)
|
|
{
|
|
for (var y = 0; y < 3; y++)
|
|
{
|
|
mapSystem.SetTile(grid, new Vector2i(x, y), new Tile(1));
|
|
}
|
|
}
|
|
|
|
entityManager.SpawnEntity("WallReinforced", mapSystem.GridTileToLocal(grid, grid.Comp, new Vector2i(0, 1)));
|
|
entityManager.SpawnEntity("WallReinforced", mapSystem.GridTileToLocal(grid, grid.Comp, new Vector2i(1, 0)));
|
|
});
|
|
|
|
|
|
var puddleOrigin = new Vector2i(0, 0);
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
var grid = entityManager.GetComponent<MapGridComponent>(gridId);
|
|
var solution = new Solution("Blood", FixedPoint2.New(100));
|
|
var tileRef = mapSystem.GetTileRef(gridId, grid, puddleOrigin);
|
|
#pragma warning disable NUnit2045 // Interdependent tests
|
|
Assert.That(puddleSystem.TrySpillAt(tileRef, solution, out _), Is.True);
|
|
Assert.That(GetPuddle(entityManager, (gridId, grid), puddleOrigin), Is.Not.Null);
|
|
#pragma warning restore NUnit2045
|
|
});
|
|
|
|
var sTimeToWait = (int) Math.Ceiling(2f * gameTiming.TickRate);
|
|
await server.WaitRunTicks(sTimeToWait);
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
var grid = entityManager.GetComponent<MapGridComponent>(gridId);
|
|
var puddle = GetPuddleEntity(entityManager, (gridId, grid), puddleOrigin);
|
|
|
|
#pragma warning disable NUnit2045 // Interdependent tests
|
|
Assert.That(puddle, Is.Not.Null);
|
|
Assert.That(puddleSystem.CurrentVolume(puddle!.Value.Owner, puddle), Is.EqualTo(FixedPoint2.New(100)));
|
|
#pragma warning restore NUnit2045
|
|
|
|
for (var x = 0; x < 3; x++)
|
|
{
|
|
for (var y = 0; y < 3; y++)
|
|
{
|
|
if (x == 0 && y == 0 || x == 0 && y == 1 || x == 1 && y == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var newPos = new Vector2i(x, y);
|
|
var sidePuddle = GetPuddle(entityManager, (gridId, grid), newPos);
|
|
Assert.That(sidePuddle, Is.Null);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|