2021-12-05 04:18:30 +01:00
|
|
|
using Content.Server.Fluids.EntitySystems;
|
2021-09-06 15:49:44 +02:00
|
|
|
using Content.Shared.Chemistry.Components;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Coordinates;
|
2021-11-03 16:48:03 -07:00
|
|
|
using Content.Shared.FixedPoint;
|
2023-04-10 15:37:03 +10:00
|
|
|
using Content.Shared.Fluids.Components;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2020-09-02 01:31:47 +02:00
|
|
|
using Robust.Shared.Map;
|
|
|
|
|
|
|
|
|
|
namespace Content.IntegrationTests.Tests.Fluids
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
[TestOf(typeof(PuddleComponent))]
|
2022-06-19 20:22:28 -07:00
|
|
|
public sealed class PuddleTest
|
2020-09-02 01:31:47 +02:00
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public async Task TilePuddleTest()
|
|
|
|
|
{
|
2023-08-25 02:56:51 +02:00
|
|
|
await using var pair = await PoolManager.GetServerClient();
|
|
|
|
|
var server = pair.Server;
|
2020-09-02 01:31:47 +02:00
|
|
|
|
2023-08-25 04:13:11 +02:00
|
|
|
var testMap = await pair.CreateTestMap();
|
2022-06-21 07:44:19 -07:00
|
|
|
|
2024-07-02 20:01:37 -04:00
|
|
|
var spillSystem = server.System<PuddleSystem>();
|
2020-09-02 01:31:47 +02:00
|
|
|
|
2022-06-19 20:22:28 -07:00
|
|
|
await server.WaitAssertion(() =>
|
2020-09-02 01:31:47 +02:00
|
|
|
{
|
2021-11-22 18:01:51 -07:00
|
|
|
var solution = new Solution("Water", FixedPoint2.New(20));
|
2022-06-21 07:44:19 -07:00
|
|
|
var tile = testMap.Tile;
|
2022-06-19 20:22:28 -07:00
|
|
|
var gridUid = tile.GridUid;
|
|
|
|
|
var (x, y) = tile.GridIndices;
|
|
|
|
|
var coordinates = new EntityCoordinates(gridUid, x, y);
|
2021-11-06 11:49:59 +01:00
|
|
|
|
2023-07-05 21:54:25 -07:00
|
|
|
Assert.That(spillSystem.TrySpillAt(coordinates, solution, out _), Is.True);
|
2020-09-02 01:31:47 +02:00
|
|
|
});
|
2023-08-25 04:13:11 +02:00
|
|
|
await pair.RunTicksSync(5);
|
2020-09-02 01:31:47 +02:00
|
|
|
|
2023-08-25 02:56:51 +02:00
|
|
|
await pair.CleanReturnAsync();
|
2020-09-02 01:31:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public async Task SpaceNoPuddleTest()
|
|
|
|
|
{
|
2023-08-25 02:56:51 +02:00
|
|
|
await using var pair = await PoolManager.GetServerClient();
|
|
|
|
|
var server = pair.Server;
|
2021-11-06 11:49:59 +01:00
|
|
|
|
2023-08-25 04:13:11 +02:00
|
|
|
var testMap = await pair.CreateTestMap();
|
2024-07-02 20:01:37 -04:00
|
|
|
var grid = testMap.Grid;
|
2022-06-21 07:44:19 -07:00
|
|
|
|
2021-12-05 04:18:30 +01:00
|
|
|
var entitySystemManager = server.ResolveDependency<IEntitySystemManager>();
|
2024-07-02 20:01:37 -04:00
|
|
|
var spillSystem = server.System<PuddleSystem>();
|
|
|
|
|
var mapSystem = server.System<SharedMapSystem>();
|
2021-11-06 11:49:59 +01:00
|
|
|
|
|
|
|
|
// Remove all tiles
|
2022-06-19 20:22:28 -07:00
|
|
|
await server.WaitPost(() =>
|
2020-09-02 01:31:47 +02:00
|
|
|
{
|
2024-07-02 20:01:37 -04:00
|
|
|
var tiles = mapSystem.GetAllTiles(grid.Owner, grid.Comp);
|
|
|
|
|
foreach (var tile in tiles)
|
2020-09-02 01:31:47 +02:00
|
|
|
{
|
2024-07-02 20:01:37 -04:00
|
|
|
mapSystem.SetTile(grid, tile.GridIndices, Tile.Empty);
|
2020-09-02 01:31:47 +02:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2023-08-25 04:13:11 +02:00
|
|
|
await pair.RunTicksSync(5);
|
2020-09-02 01:31:47 +02:00
|
|
|
|
2022-06-19 20:22:28 -07:00
|
|
|
await server.WaitAssertion(() =>
|
2020-09-02 01:31:47 +02:00
|
|
|
{
|
2024-03-29 01:28:16 -04:00
|
|
|
var coordinates = grid.Owner.ToCoordinates();
|
2021-11-22 18:01:51 -07:00
|
|
|
var solution = new Solution("Water", FixedPoint2.New(20));
|
2023-07-05 21:54:25 -07:00
|
|
|
|
|
|
|
|
Assert.That(spillSystem.TrySpillAt(coordinates, solution, out _), Is.False);
|
2020-09-02 01:31:47 +02:00
|
|
|
});
|
|
|
|
|
|
2023-08-25 02:56:51 +02:00
|
|
|
await pair.CleanReturnAsync();
|
2020-09-02 01:31:47 +02:00
|
|
|
}
|
|
|
|
|
}
|
2021-12-08 12:43:38 +01:00
|
|
|
}
|