ECSatize AlertsSystem (#5559)

This commit is contained in:
Acruid
2022-01-05 00:19:23 -08:00
committed by GitHub
parent 36d4de5e61
commit 5b1cd2dd96
59 changed files with 1069 additions and 1038 deletions

View File

@@ -1,20 +1,17 @@
using System.Linq;
using System.Threading.Tasks;
using Content.Client.Alerts;
using Content.Client.Alerts.UI;
using Content.Server.Alert;
using Content.Shared.Alert;
using NUnit.Framework;
using Robust.Client.UserInterface;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Server.Player;
using Robust.Shared.IoC;
namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
{
[TestFixture]
[TestOf(typeof(ClientAlertsComponent))]
[TestOf(typeof(ServerAlertsComponent))]
[TestOf(typeof(AlertsComponent))]
public class AlertsComponentTests : ContentIntegrationTest
{
[Test]
@@ -26,17 +23,18 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
await client.WaitIdleAsync();
var serverPlayerManager = server.ResolveDependency<IPlayerManager>();
var alertsSystem = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<AlertsSystem>();
await server.WaitAssertion(() =>
{
var playerEnt = serverPlayerManager.Sessions.Single().AttachedEntity.GetValueOrDefault();
Assert.That(playerEnt != default);
var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ServerAlertsComponent>(playerEnt);
var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<AlertsComponent>(playerEnt);
Assert.NotNull(alertsComponent);
// show 2 alerts
alertsComponent.ShowAlert(AlertType.Debug1);
alertsComponent.ShowAlert(AlertType.Debug2);
alertsSystem.ShowAlert(alertsComponent.Owner, AlertType.Debug1, null, null);
alertsSystem.ShowAlert(alertsComponent.Owner, AlertType.Debug2, null, null);
});
await server.WaitRunTicks(5);
@@ -51,7 +49,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
Assert.NotNull(local);
var controlled = local.ControlledEntity;
Assert.NotNull(controlled);
var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ClientAlertsComponent>(controlled.Value);
var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<AlertsComponent>(controlled.Value);
Assert.NotNull(alertsComponent);
// find the alertsui
@@ -71,10 +69,10 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
{
var playerEnt = serverPlayerManager.Sessions.Single().AttachedEntity.GetValueOrDefault();
Assert.That(playerEnt, Is.Not.EqualTo(default));
var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ServerAlertsComponent>(playerEnt);
var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<AlertsComponent>(playerEnt);
Assert.NotNull(alertsComponent);
alertsComponent.ClearAlert(AlertType.Debug1);
alertsSystem.ClearAlert(alertsComponent.Owner, AlertType.Debug1);
});
await server.WaitRunTicks(5);
await client.WaitRunTicks(5);
@@ -86,7 +84,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
Assert.NotNull(local);
var controlled = local.ControlledEntity;
Assert.NotNull(controlled);
var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<ClientAlertsComponent>(controlled.Value);
var alertsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<AlertsComponent>(controlled.Value);
Assert.NotNull(alertsComponent);
// find the alertsui

View File

@@ -1,4 +1,4 @@
using System.Threading.Tasks;
using System.Threading.Tasks;
using Content.Server.Gravity;
using Content.Server.Gravity.EntitySystems;
using Content.Shared.Alert;
@@ -42,9 +42,9 @@ namespace Content.IntegrationTests.Tests.Gravity
var mapManager = server.ResolveDependency<IMapManager>();
var entityManager = server.ResolveDependency<IEntityManager>();
var alertsSystem = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<AlertsSystem>();
EntityUid human = default;
SharedAlertsComponent alerts = null;
await server.WaitAssertion(() =>
{
@@ -52,7 +52,7 @@ namespace Content.IntegrationTests.Tests.Gravity
var coordinates = grid.ToCoordinates();
human = entityManager.SpawnEntity("HumanDummy", coordinates);
Assert.True(entityManager.TryGetComponent(human, out alerts));
Assert.True(entityManager.TryGetComponent(human, out AlertsComponent alerts));
});
// Let WeightlessSystem and GravitySystem tick
@@ -61,7 +61,7 @@ namespace Content.IntegrationTests.Tests.Gravity
await server.WaitAssertion(() =>
{
// No gravity without a gravity generator
Assert.True(alerts.IsShowingAlert(AlertType.Weightless));
Assert.True(alertsSystem.IsShowingAlert(human, AlertType.Weightless));
entityManager.SpawnEntity("GravityGeneratorDummy", entityManager.GetComponent<TransformComponent>(human).Coordinates);
});
@@ -71,7 +71,7 @@ namespace Content.IntegrationTests.Tests.Gravity
await server.WaitAssertion(() =>
{
Assert.False(alerts.IsShowingAlert(AlertType.Weightless));
Assert.False(alertsSystem.IsShowingAlert(human, AlertType.Weightless));
// TODO: Re-add gravity generator breaking when Vera is done with construction stuff.
/*