2022-01-05 00:19:23 -08:00
|
|
|
using System.Threading.Tasks;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.Gravity;
|
|
|
|
|
using Content.Server.Gravity.EntitySystems;
|
2020-11-09 20:22:19 -08:00
|
|
|
using Content.Shared.Alert;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Coordinates;
|
2020-10-30 02:38:21 +01:00
|
|
|
using NUnit.Framework;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-03 14:17:01 +01:00
|
|
|
using Robust.Shared.IoC;
|
2020-10-30 02:38:21 +01:00
|
|
|
using Robust.Shared.Map;
|
|
|
|
|
|
|
|
|
|
namespace Content.IntegrationTests.Tests.Gravity
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
[TestOf(typeof(WeightlessSystem))]
|
|
|
|
|
[TestOf(typeof(GravityGeneratorComponent))]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class WeightlessStatusTests : ContentIntegrationTest
|
2020-10-30 02:38:21 +01:00
|
|
|
{
|
2021-02-09 22:04:47 +01:00
|
|
|
private const string Prototypes = @"
|
2020-11-18 15:30:36 +01:00
|
|
|
- type: entity
|
|
|
|
|
name: HumanDummy
|
|
|
|
|
id: HumanDummy
|
|
|
|
|
components:
|
2020-12-13 14:28:20 -08:00
|
|
|
- type: Alerts
|
2021-11-02 01:12:55 +01:00
|
|
|
- type: entity
|
|
|
|
|
name: GravityGeneratorDummy
|
|
|
|
|
id: GravityGeneratorDummy
|
|
|
|
|
components:
|
|
|
|
|
- type: GravityGenerator
|
|
|
|
|
chargeRate: 1000000000 # Set this really high so it discharges in a single tick.
|
|
|
|
|
activePower: 500
|
|
|
|
|
- type: ApcPowerReceiver
|
|
|
|
|
needsPower: false
|
|
|
|
|
- type: UserInterface
|
2020-11-18 15:30:36 +01:00
|
|
|
";
|
2020-10-30 02:38:21 +01:00
|
|
|
[Test]
|
|
|
|
|
public async Task WeightlessStatusTest()
|
|
|
|
|
{
|
2021-04-04 13:00:58 +02:00
|
|
|
var options = new ServerContentIntegrationOption {ExtraPrototypes = Prototypes};
|
2020-11-18 15:30:36 +01:00
|
|
|
var server = StartServer(options);
|
2020-10-30 02:38:21 +01:00
|
|
|
|
|
|
|
|
await server.WaitIdleAsync();
|
|
|
|
|
|
|
|
|
|
var mapManager = server.ResolveDependency<IMapManager>();
|
|
|
|
|
var entityManager = server.ResolveDependency<IEntityManager>();
|
2022-01-05 00:19:23 -08:00
|
|
|
var alertsSystem = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<AlertsSystem>();
|
2020-10-30 02:38:21 +01:00
|
|
|
|
2021-12-05 18:09:01 +01:00
|
|
|
EntityUid human = default;
|
2020-10-30 02:38:21 +01:00
|
|
|
|
|
|
|
|
await server.WaitAssertion(() =>
|
|
|
|
|
{
|
2021-11-06 11:49:59 +01:00
|
|
|
var grid = GetMainGrid(mapManager);
|
2020-10-30 02:38:21 +01:00
|
|
|
var coordinates = grid.ToCoordinates();
|
2020-11-18 15:30:36 +01:00
|
|
|
human = entityManager.SpawnEntity("HumanDummy", coordinates);
|
2020-10-30 02:38:21 +01:00
|
|
|
|
2022-01-05 00:19:23 -08:00
|
|
|
Assert.True(entityManager.TryGetComponent(human, out AlertsComponent alerts));
|
2020-10-30 02:38:21 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Let WeightlessSystem and GravitySystem tick
|
|
|
|
|
await server.WaitRunTicks(1);
|
|
|
|
|
|
|
|
|
|
await server.WaitAssertion(() =>
|
|
|
|
|
{
|
|
|
|
|
// No gravity without a gravity generator
|
2022-01-05 00:19:23 -08:00
|
|
|
Assert.True(alertsSystem.IsShowingAlert(human, AlertType.Weightless));
|
2020-10-30 02:38:21 +01:00
|
|
|
|
2021-12-08 12:43:38 +01:00
|
|
|
entityManager.SpawnEntity("GravityGeneratorDummy", entityManager.GetComponent<TransformComponent>(human).Coordinates);
|
2020-10-30 02:38:21 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Let WeightlessSystem and GravitySystem tick
|
|
|
|
|
await server.WaitRunTicks(1);
|
|
|
|
|
|
|
|
|
|
await server.WaitAssertion(() =>
|
|
|
|
|
{
|
2022-01-05 00:19:23 -08:00
|
|
|
Assert.False(alertsSystem.IsShowingAlert(human, AlertType.Weightless));
|
2020-10-30 02:38:21 +01:00
|
|
|
|
2021-11-02 01:12:55 +01:00
|
|
|
// TODO: Re-add gravity generator breaking when Vera is done with construction stuff.
|
|
|
|
|
/*
|
2020-10-30 02:38:21 +01:00
|
|
|
// Disable the gravity generator
|
|
|
|
|
var args = new BreakageEventArgs {Owner = human};
|
2021-11-02 01:12:55 +01:00
|
|
|
// gravityGenerator.OnBreak(args);
|
|
|
|
|
*/
|
2020-10-30 02:38:21 +01:00
|
|
|
});
|
|
|
|
|
|
2021-11-02 01:12:55 +01:00
|
|
|
/*await server.WaitRunTicks(1);
|
2020-10-30 02:38:21 +01:00
|
|
|
|
|
|
|
|
await server.WaitAssertion(() =>
|
|
|
|
|
{
|
2021-02-06 14:32:48 +01:00
|
|
|
Assert.True(alerts.IsShowingAlert(AlertType.Weightless));
|
2021-11-02 01:12:55 +01:00
|
|
|
});*/
|
2020-10-30 02:38:21 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|