Files
tbd-station-14/Content.IntegrationTests/Tests/Gravity/WeightlessStatusTests.cs
metalgearsloth bfac53e7bc Per-map parallax support (#9786)
* Per-map parallax support

* Comments for future sloth

* c

* bet

* Fix exception

* VV support

* Fix parallax

* mem

* weightless sounds

* Gravity stuff

* placeholder coz im too lazy to stash don't @ me son

* decent clouds

* sky

* Fast parallax

* Imagine spelling

* Loicense

* perish

* Fix weightless status

Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
2022-07-25 00:10:23 -05:00

93 lines
3.0 KiB
C#

using System.Threading.Tasks;
using Content.Server.Gravity;
using Content.Server.Gravity.EntitySystems;
using Content.Shared.Alert;
using Content.Shared.Coordinates;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
namespace Content.IntegrationTests.Tests.Gravity
{
[TestFixture]
[TestOf(typeof(GravitySystem))]
[TestOf(typeof(GravityGeneratorComponent))]
public sealed class WeightlessStatusTests
{
private const string Prototypes = @"
- type: entity
name: HumanDummy
id: HumanDummy
components:
- type: Alerts
- type: Physics
bodyType: Dynamic
- 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
";
[Test]
public async Task WeightlessStatusTest()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true, ExtraPrototypes = Prototypes});
var server = pairTracker.Pair.Server;
var entityManager = server.ResolveDependency<IEntityManager>();
var alertsSystem = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<AlertsSystem>();
EntityUid human = default;
var testMap = await PoolManager.CreateTestMap(pairTracker);
await server.WaitAssertion(() =>
{
human = entityManager.SpawnEntity("HumanDummy", testMap.GridCoords);
Assert.True(entityManager.TryGetComponent(human, out AlertsComponent alerts));
});
// Let WeightlessSystem and GravitySystem tick
await PoolManager.RunTicksSync(pairTracker.Pair, 10);
var generatorUid = EntityUid.Invalid;
await server.WaitAssertion(() =>
{
// No gravity without a gravity generator
Assert.True(alertsSystem.IsShowingAlert(human, AlertType.Weightless));
generatorUid = entityManager.SpawnEntity("GravityGeneratorDummy", entityManager.GetComponent<TransformComponent>(human).Coordinates);
});
// Let WeightlessSystem and GravitySystem tick
await PoolManager.RunTicksSync(pairTracker.Pair, 10);
await server.WaitAssertion(() =>
{
Assert.False(alertsSystem.IsShowingAlert(human, AlertType.Weightless));
// This should kill gravity
entityManager.DeleteEntity(generatorUid);
});
await PoolManager.RunTicksSync(pairTracker.Pair, 10);
await server.WaitAssertion(() =>
{
Assert.True(alertsSystem.IsShowingAlert(human, AlertType.Weightless));
});
await PoolManager.RunTicksSync(pairTracker.Pair, 10);
await pairTracker.CleanReturnAsync();
}
}
}