Merge remote-tracking branch 'upstream/master' into 20-10-30-admins
This commit is contained in:
@@ -20,7 +20,7 @@ using Robust.Shared.Maths;
|
||||
namespace Content.IntegrationTests.Tests.Body
|
||||
{
|
||||
[TestFixture]
|
||||
[TestOf(typeof(LungBehaviorComponent))]
|
||||
[TestOf(typeof(LungBehavior))]
|
||||
public class LungTest : ContentIntegrationTest
|
||||
{
|
||||
[Test]
|
||||
@@ -39,7 +39,7 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
var human = entityManager.SpawnEntity("HumanMob_Content", MapCoordinates.Nullspace);
|
||||
|
||||
Assert.That(human.TryGetComponent(out IBody body));
|
||||
Assert.That(body.TryGetMechanismBehaviors(out List<LungBehaviorComponent> lungs));
|
||||
Assert.That(body.TryGetMechanismBehaviors(out List<LungBehavior> lungs));
|
||||
Assert.That(lungs.Count, Is.EqualTo(1));
|
||||
Assert.That(human.TryGetComponent(out BloodstreamComponent bloodstream));
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
human = entityManager.SpawnEntity("HumanMob_Content", coordinates);
|
||||
|
||||
Assert.True(human.TryGetComponent(out IBody body));
|
||||
Assert.True(body.HasMechanismBehavior<LungBehaviorComponent>());
|
||||
Assert.True(body.HasMechanismBehavior<LungBehavior>());
|
||||
Assert.True(human.TryGetComponent(out metabolism));
|
||||
Assert.False(metabolism.Suffocating);
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#nullable enable
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.GameObjects.Components.Body.Behavior;
|
||||
using Content.Shared.GameObjects.Components.Body;
|
||||
using Content.Shared.GameObjects.Components.Body.Behavior;
|
||||
using Content.Shared.GameObjects.Components.Body.Mechanism;
|
||||
using Content.Shared.GameObjects.Components.Body.Part;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -18,14 +18,11 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
[TestOf(typeof(SharedBodyComponent))]
|
||||
[TestOf(typeof(SharedBodyPartComponent))]
|
||||
[TestOf(typeof(SharedMechanismComponent))]
|
||||
[TestOf(typeof(MechanismBehaviorComponent))]
|
||||
[TestOf(typeof(MechanismBehavior))]
|
||||
public class MechanismBehaviorEventsTest : ContentIntegrationTest
|
||||
{
|
||||
[RegisterComponent]
|
||||
private class TestBehaviorComponent : MechanismBehaviorComponent
|
||||
private class TestMechanismBehavior : MechanismBehavior
|
||||
{
|
||||
public override string Name => nameof(MechanismBehaviorEventsTest) + "TestBehavior";
|
||||
|
||||
public bool WasAddedToBody;
|
||||
public bool WasAddedToPart;
|
||||
public bool WasAddedToPartInBody;
|
||||
@@ -33,8 +30,6 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
public bool WasRemovedFromPart;
|
||||
public bool WasRemovedFromPartInBody;
|
||||
|
||||
public override void Update(float frameTime) { }
|
||||
|
||||
public bool NoAdded()
|
||||
{
|
||||
return !WasAddedToBody && !WasAddedToPart && !WasAddedToPartInBody;
|
||||
@@ -111,13 +106,7 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
[Test]
|
||||
public async Task EventsTest()
|
||||
{
|
||||
var server = StartServerDummyTicker(new ServerContentIntegrationOption
|
||||
{
|
||||
ContentBeforeIoC = () =>
|
||||
{
|
||||
IoCManager.Resolve<IComponentFactory>().Register<TestBehaviorComponent>();
|
||||
}
|
||||
});
|
||||
var server = StartServerDummyTicker();
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
@@ -141,68 +130,68 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
var mechanism = centerPart!.Mechanisms.First();
|
||||
Assert.NotNull(mechanism);
|
||||
|
||||
var component = mechanism.Owner.AddComponent<TestBehaviorComponent>();
|
||||
Assert.False(component.WasAddedToBody);
|
||||
Assert.False(component.WasAddedToPart);
|
||||
Assert.That(component.WasAddedToPartInBody);
|
||||
Assert.That(component.NoRemoved);
|
||||
mechanism.EnsureBehavior<TestMechanismBehavior>(out var behavior);
|
||||
Assert.False(behavior.WasAddedToBody);
|
||||
Assert.False(behavior.WasAddedToPart);
|
||||
Assert.That(behavior.WasAddedToPartInBody);
|
||||
Assert.That(behavior.NoRemoved);
|
||||
|
||||
component.ResetAll();
|
||||
behavior.ResetAll();
|
||||
|
||||
Assert.That(component.NoAdded);
|
||||
Assert.That(component.NoRemoved);
|
||||
Assert.That(behavior.NoAdded);
|
||||
Assert.That(behavior.NoRemoved);
|
||||
|
||||
centerPart.RemoveMechanism(mechanism);
|
||||
|
||||
Assert.That(component.NoAdded);
|
||||
Assert.False(component.WasRemovedFromBody);
|
||||
Assert.False(component.WasRemovedFromPart);
|
||||
Assert.That(component.WasRemovedFromPartInBody);
|
||||
Assert.That(behavior.NoAdded);
|
||||
Assert.False(behavior.WasRemovedFromBody);
|
||||
Assert.False(behavior.WasRemovedFromPart);
|
||||
Assert.That(behavior.WasRemovedFromPartInBody);
|
||||
|
||||
component.ResetAll();
|
||||
behavior.ResetAll();
|
||||
|
||||
centerPart.TryAddMechanism(mechanism, true);
|
||||
|
||||
Assert.False(component.WasAddedToBody);
|
||||
Assert.False(component.WasAddedToPart);
|
||||
Assert.That(component.WasAddedToPartInBody);
|
||||
Assert.That(component.NoRemoved());
|
||||
Assert.False(behavior.WasAddedToBody);
|
||||
Assert.False(behavior.WasAddedToPart);
|
||||
Assert.That(behavior.WasAddedToPartInBody);
|
||||
Assert.That(behavior.NoRemoved());
|
||||
|
||||
component.ResetAll();
|
||||
behavior.ResetAll();
|
||||
|
||||
body.RemovePart(centerPart);
|
||||
|
||||
Assert.That(component.NoAdded);
|
||||
Assert.That(component.WasRemovedFromBody);
|
||||
Assert.False(component.WasRemovedFromPart);
|
||||
Assert.False(component.WasRemovedFromPartInBody);
|
||||
Assert.That(behavior.NoAdded);
|
||||
Assert.That(behavior.WasRemovedFromBody);
|
||||
Assert.False(behavior.WasRemovedFromPart);
|
||||
Assert.False(behavior.WasRemovedFromPartInBody);
|
||||
|
||||
component.ResetAll();
|
||||
behavior.ResetAll();
|
||||
|
||||
centerPart.RemoveMechanism(mechanism);
|
||||
|
||||
Assert.That(component.NoAdded);
|
||||
Assert.False(component.WasRemovedFromBody);
|
||||
Assert.That(component.WasRemovedFromPart);
|
||||
Assert.False(component.WasRemovedFromPartInBody);
|
||||
Assert.That(behavior.NoAdded);
|
||||
Assert.False(behavior.WasRemovedFromBody);
|
||||
Assert.That(behavior.WasRemovedFromPart);
|
||||
Assert.False(behavior.WasRemovedFromPartInBody);
|
||||
|
||||
component.ResetAll();
|
||||
behavior.ResetAll();
|
||||
|
||||
centerPart.TryAddMechanism(mechanism, true);
|
||||
|
||||
Assert.False(component.WasAddedToBody);
|
||||
Assert.That(component.WasAddedToPart);
|
||||
Assert.False(component.WasAddedToPartInBody);
|
||||
Assert.That(component.NoRemoved);
|
||||
Assert.False(behavior.WasAddedToBody);
|
||||
Assert.That(behavior.WasAddedToPart);
|
||||
Assert.False(behavior.WasAddedToPartInBody);
|
||||
Assert.That(behavior.NoRemoved);
|
||||
|
||||
component.ResetAll();
|
||||
behavior.ResetAll();
|
||||
|
||||
body.TryAddPart(centerSlot!, centerPart, true);
|
||||
|
||||
Assert.That(component.WasAddedToBody);
|
||||
Assert.False(component.WasAddedToPart);
|
||||
Assert.False(component.WasAddedToPartInBody);
|
||||
Assert.That(component.NoRemoved);
|
||||
Assert.That(behavior.WasAddedToBody);
|
||||
Assert.False(behavior.WasAddedToPart);
|
||||
Assert.False(behavior.WasAddedToPartInBody);
|
||||
Assert.That(behavior.NoRemoved);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ namespace Content.IntegrationTests.Tests.Buckle
|
||||
human.Transform.LocalPosition += (100, 0);
|
||||
});
|
||||
|
||||
await WaitUntil(server, () => !buckle.Buckled, maxTicks: 10);
|
||||
await WaitUntil(server, () => !buckle.Buckled, 10);
|
||||
|
||||
Assert.False(buckle.Buckled);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Interfaces.GameTicking;
|
||||
using Content.Shared;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.Interfaces.Configuration;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
@@ -31,7 +32,7 @@ namespace Content.IntegrationTests.Tests.Commands
|
||||
|
||||
server.Assert(() =>
|
||||
{
|
||||
configManager.SetCVar("game.lobbyenabled", lobbyEnabled);
|
||||
configManager.SetCVar(CCVars.GameLobbyEnabled, lobbyEnabled);
|
||||
|
||||
Assert.That(gameTicker.RunLevel, Is.EqualTo(GameRunLevel.InRound));
|
||||
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Client.GameObjects.Components.Mobs;
|
||||
using Content.Client.UserInterface;
|
||||
using Content.Server.GameObjects.Components.Mobs;
|
||||
using Content.Shared.Alert;
|
||||
using NUnit.Framework;
|
||||
using Robust.Client.Interfaces.UserInterface;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
|
||||
{
|
||||
[TestFixture]
|
||||
[TestOf(typeof(ClientAlertsComponent))]
|
||||
[TestOf(typeof(ServerAlertsComponent))]
|
||||
public class AlertsComponentTests : ContentIntegrationTest
|
||||
{
|
||||
|
||||
[Test]
|
||||
public async Task AlertsTest()
|
||||
{
|
||||
var (client, server) = await StartConnectedServerClientPair();
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
await client.WaitIdleAsync();
|
||||
|
||||
var serverPlayerManager = server.ResolveDependency<Robust.Server.Interfaces.Player.IPlayerManager>();
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
var player = serverPlayerManager.GetAllPlayers().Single();
|
||||
var playerEnt = player.AttachedEntity;
|
||||
Assert.NotNull(playerEnt);
|
||||
var alertsComponent = playerEnt.GetComponent<ServerAlertsComponent>();
|
||||
Assert.NotNull(alertsComponent);
|
||||
|
||||
// show 2 alerts
|
||||
alertsComponent.ShowAlert(AlertType.Debug1);
|
||||
alertsComponent.ShowAlert(AlertType.Debug2);
|
||||
});
|
||||
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
|
||||
var clientPlayerMgr = client.ResolveDependency<IPlayerManager>();
|
||||
var clientUIMgr = client.ResolveDependency<IUserInterfaceManager>();
|
||||
await client.WaitAssertion(() =>
|
||||
{
|
||||
|
||||
var local = clientPlayerMgr.LocalPlayer;
|
||||
Assert.NotNull(local);
|
||||
var controlled = local.ControlledEntity;
|
||||
Assert.NotNull(controlled);
|
||||
var alertsComponent = controlled.GetComponent<ClientAlertsComponent>();
|
||||
Assert.NotNull(alertsComponent);
|
||||
|
||||
// find the alertsui
|
||||
var alertsUI =
|
||||
clientUIMgr.StateRoot.Children.FirstOrDefault(c => c is AlertsUI) as AlertsUI;
|
||||
Assert.NotNull(alertsUI);
|
||||
|
||||
// we should be seeing 3 alerts - our health, and the 2 debug alerts, in a specific order.
|
||||
Assert.That(alertsUI.Grid.ChildCount, Is.EqualTo(3));
|
||||
var alertControls = alertsUI.Grid.Children.Select(c => c as AlertControl);
|
||||
var alertIDs = alertControls.Select(ac => ac.Alert.AlertType).ToArray();
|
||||
var expectedIDs = new [] {AlertType.HumanHealth, AlertType.Debug1, AlertType.Debug2};
|
||||
Assert.That(alertIDs, Is.EqualTo(expectedIDs));
|
||||
});
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
var player = serverPlayerManager.GetAllPlayers().Single();
|
||||
var playerEnt = player.AttachedEntity;
|
||||
Assert.NotNull(playerEnt);
|
||||
var alertsComponent = playerEnt.GetComponent<ServerAlertsComponent>();
|
||||
Assert.NotNull(alertsComponent);
|
||||
|
||||
alertsComponent.ClearAlert(AlertType.Debug1);
|
||||
});
|
||||
await server.WaitRunTicks(5);
|
||||
await client.WaitRunTicks(5);
|
||||
|
||||
await client.WaitAssertion(() =>
|
||||
{
|
||||
|
||||
var local = clientPlayerMgr.LocalPlayer;
|
||||
Assert.NotNull(local);
|
||||
var controlled = local.ControlledEntity;
|
||||
Assert.NotNull(controlled);
|
||||
var alertsComponent = controlled.GetComponent<ClientAlertsComponent>();
|
||||
Assert.NotNull(alertsComponent);
|
||||
|
||||
// find the alertsui
|
||||
var alertsUI =
|
||||
clientUIMgr.StateRoot.Children.FirstOrDefault(c => c is AlertsUI) as AlertsUI;
|
||||
Assert.NotNull(alertsUI);
|
||||
|
||||
// we should be seeing only 2 alerts now because one was cleared
|
||||
Assert.That(alertsUI.Grid.ChildCount, Is.EqualTo(2));
|
||||
var alertControls = alertsUI.Grid.Children.Select(c => c as AlertControl);
|
||||
var alertIDs = alertControls.Select(ac => ac.Alert.AlertType).ToArray();
|
||||
var expectedIDs = new [] {AlertType.HumanHealth, AlertType.Debug2};
|
||||
Assert.That(alertIDs, Is.EqualTo(expectedIDs));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.GameObjects.Components.Gravity;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.GameObjects.Components.Gravity;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
@@ -32,7 +33,7 @@ namespace Content.IntegrationTests.Tests.Gravity
|
||||
var tileDefinitionManager = server.ResolveDependency<ITileDefinitionManager>();
|
||||
|
||||
IEntity human = null;
|
||||
SharedStatusEffectsComponent statusEffects = null;
|
||||
SharedAlertsComponent alerts = null;
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
@@ -57,7 +58,7 @@ namespace Content.IntegrationTests.Tests.Gravity
|
||||
|
||||
human = entityManager.SpawnEntity("HumanMob_Content", coordinates);
|
||||
|
||||
Assert.True(human.TryGetComponent(out statusEffects));
|
||||
Assert.True(human.TryGetComponent(out alerts));
|
||||
});
|
||||
|
||||
// Let WeightlessSystem and GravitySystem tick
|
||||
@@ -68,7 +69,7 @@ namespace Content.IntegrationTests.Tests.Gravity
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
// No gravity without a gravity generator
|
||||
Assert.True(statusEffects.Statuses.ContainsKey(StatusEffect.Weightless));
|
||||
Assert.True(alerts.IsShowingAlert(AlertType.Weightless));
|
||||
|
||||
gravityGenerator = human.EnsureComponent<GravityGeneratorComponent>();
|
||||
});
|
||||
@@ -78,7 +79,7 @@ namespace Content.IntegrationTests.Tests.Gravity
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
Assert.False(statusEffects.Statuses.ContainsKey(StatusEffect.Weightless));
|
||||
Assert.False(alerts.IsShowingAlert(AlertType.Weightless));
|
||||
|
||||
// Disable the gravity generator
|
||||
var args = new BreakageEventArgs {Owner = human};
|
||||
@@ -89,7 +90,7 @@ namespace Content.IntegrationTests.Tests.Gravity
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
Assert.False(statusEffects.Statuses.ContainsKey(StatusEffect.Weightless));
|
||||
Assert.False(alerts.IsShowingAlert(AlertType.Weightless));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,9 +38,7 @@ namespace Content.IntegrationTests.Tests.Lobby
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
var lobbyCvar = CCVars.GameLobbyEnabled;
|
||||
serverConfig.SetCVar(lobbyCvar.Name, true);
|
||||
|
||||
serverConfig.SetCVar(CCVars.GameLobbyEnabled, true);
|
||||
serverTicker.RestartRound();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user