Files
tbd-station-14/Content.IntegrationTests/Tests/Gravity/WeightlessStatusTests.cs
Princess Cheeseballs 9de76e70c7 EVENT BASED WEIGHTLESSNESS (#37971)
* Init Commit

* Typos

* Commit 2

* Save Interaction Test Mob from failing

* ssss

* Confident I've gotten all the correct prototypes

* Whoops forgot to edit those

* aaaaa

* Better solution

* Test fail fixes

* Yaml fix

* THE FINAL TEST FIX

* Final fix(?)

* whoops

* Added a WeightlessnessChangedEvent

* Check out this diff

* Wait I'm dumb

* Final optimization and don't duplicate code

* Death to IsWeightless

* File scoped namespaces

* REVIEW

* Fix test fails

* FIX TEST FAILS REAL

* A

* Commit of doom

* borgar

* We don't need to specify on map init apparently

* Fuck it

* LOAD BEARING COMMENT

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
2025-08-19 14:35:09 -04:00

94 lines
2.9 KiB
C#

using Content.Server.Gravity;
using Content.Shared.Alert;
using Content.Shared.Gravity;
using Robust.Shared.GameObjects;
namespace Content.IntegrationTests.Tests.Gravity
{
[TestFixture]
[TestOf(typeof(GravitySystem))]
[TestOf(typeof(GravityGeneratorComponent))]
public sealed class WeightlessStatusTests
{
[TestPrototypes]
private const string Prototypes = @"
- type: entity
name: HumanWeightlessDummy
id: HumanWeightlessDummy
components:
- type: Alerts
- type: Physics
bodyType: Dynamic
- type: GravityAffected
- type: entity
name: WeightlessGravityGeneratorDummy
id: WeightlessGravityGeneratorDummy
components:
- type: GravityGenerator
- type: PowerCharge
windowTitle: gravity-generator-window-title
idlePower: 50
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 pair = await PoolManager.GetServerClient();
var server = pair.Server;
var entityManager = server.ResolveDependency<IEntityManager>();
var alertsSystem = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<AlertsSystem>();
var weightlessAlert = SharedGravitySystem.WeightlessAlert;
EntityUid human = default;
var testMap = await pair.CreateTestMap();
await server.WaitAssertion(() =>
{
human = entityManager.SpawnEntity("HumanWeightlessDummy", testMap.GridCoords);
Assert.That(entityManager.TryGetComponent(human, out AlertsComponent alerts));
});
// Let WeightlessSystem and GravitySystem tick
await pair.RunTicksSync(10);
var generatorUid = EntityUid.Invalid;
await server.WaitAssertion(() =>
{
// No gravity without a gravity generator
Assert.That(alertsSystem.IsShowingAlert(human, weightlessAlert));
generatorUid = entityManager.SpawnEntity("WeightlessGravityGeneratorDummy", entityManager.GetComponent<TransformComponent>(human).Coordinates);
});
// Let WeightlessSystem and GravitySystem tick
await pair.RunTicksSync(10);
await server.WaitAssertion(() =>
{
Assert.That(alertsSystem.IsShowingAlert(human, weightlessAlert), Is.False);
// This should kill gravity
entityManager.DeleteEntity(generatorUid);
});
await pair.RunTicksSync(10);
await server.WaitAssertion(() =>
{
Assert.That(alertsSystem.IsShowingAlert(human, weightlessAlert));
});
await pair.RunTicksSync(10);
await pair.CleanReturnAsync();
}
}
}