Make destructible test more reliable (#9425)

This commit is contained in:
wrexbe
2022-07-05 08:02:24 -07:00
committed by GitHub
parent 4f3e4fc9ab
commit 8c4e17eef3
4 changed files with 6 additions and 8 deletions

View File

@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Content.Client.IoC; using Content.Client.IoC;
using Content.Client.Parallax.Managers; using Content.Client.Parallax.Managers;
using Content.IntegrationTests.Tests; using Content.IntegrationTests.Tests;
using Content.IntegrationTests.Tests.Destructible;
using Content.IntegrationTests.Tests.DeviceNetwork; using Content.IntegrationTests.Tests.DeviceNetwork;
using Content.IntegrationTests.Tests.Interaction.Click; using Content.IntegrationTests.Tests.Interaction.Click;
using Content.IntegrationTests.Tests.Networking; using Content.IntegrationTests.Tests.Networking;
@@ -106,6 +107,7 @@ public static class PoolManager
IoCManager.Resolve<IEntitySystemManager>() IoCManager.Resolve<IEntitySystemManager>()
.LoadExtraSystemType<InteractionSystemTests.TestInteractionSystem>(); .LoadExtraSystemType<InteractionSystemTests.TestInteractionSystem>();
IoCManager.Resolve<IEntitySystemManager>().LoadExtraSystemType<DeviceNetworkTestSystem>(); IoCManager.Resolve<IEntitySystemManager>().LoadExtraSystemType<DeviceNetworkTestSystem>();
IoCManager.Resolve<IEntitySystemManager>().LoadExtraSystemType<TestDestructibleListenerSystem>();
IoCManager.Resolve<ILogManager>().GetSawmill("loc").Level = LogLevel.Error; IoCManager.Resolve<ILogManager>().GetSawmill("loc").Level = LogLevel.Error;
}; };

View File

@@ -39,6 +39,7 @@ namespace Content.IntegrationTests.Tests.Destructible
sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleDamageTypeEntityId, coordinates); sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleDamageTypeEntityId, coordinates);
sDamageableComponent = IoCManager.Resolve<IEntityManager>().GetComponent<DamageableComponent>(sDestructibleEntity); sDamageableComponent = IoCManager.Resolve<IEntityManager>().GetComponent<DamageableComponent>(sDestructibleEntity);
sTestThresholdListenerSystem = sEntitySystemManager.GetEntitySystem<TestDestructibleListenerSystem>(); sTestThresholdListenerSystem = sEntitySystemManager.GetEntitySystem<TestDestructibleListenerSystem>();
sTestThresholdListenerSystem.ThresholdsReached.Clear();
sDamageableSystem = sEntitySystemManager.GetEntitySystem<DamageableSystem>(); sDamageableSystem = sEntitySystemManager.GetEntitySystem<DamageableSystem>();
}); });

View File

@@ -36,6 +36,7 @@ namespace Content.IntegrationTests.Tests.Destructible
sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleDestructionEntityId, coordinates); sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleDestructionEntityId, coordinates);
sTestThresholdListenerSystem = sEntitySystemManager.GetEntitySystem<TestDestructibleListenerSystem>(); sTestThresholdListenerSystem = sEntitySystemManager.GetEntitySystem<TestDestructibleListenerSystem>();
sTestThresholdListenerSystem.ThresholdsReached.Clear();
}); });
await server.WaitAssertion(() => await server.WaitAssertion(() =>

View File

@@ -1,9 +1,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using Content.Server.Destructible; using Content.Server.Destructible;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Content.Shared.Module;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.Reflection;
namespace Content.IntegrationTests.Tests.Destructible namespace Content.IntegrationTests.Tests.Destructible
{ {
@@ -11,19 +10,14 @@ namespace Content.IntegrationTests.Tests.Destructible
/// This is just a system for testing destructible thresholds. Whenever any threshold is reached, this will add that /// This is just a system for testing destructible thresholds. Whenever any threshold is reached, this will add that
/// threshold to a list for checking during testing. /// threshold to a list for checking during testing.
/// </summary> /// </summary>
[Reflect(false)]
public sealed class TestDestructibleListenerSystem : EntitySystem public sealed class TestDestructibleListenerSystem : EntitySystem
{ {
[Dependency] private readonly IModuleManager _modManager;
public readonly List<DamageThresholdReached> ThresholdsReached = new(); public readonly List<DamageThresholdReached> ThresholdsReached = new();
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
if (_modManager.IsClientModule)
return;
SubscribeLocalEvent<DestructibleComponent, DamageThresholdReached>(AddThresholdsToList); SubscribeLocalEvent<DestructibleComponent, DamageThresholdReached>(AddThresholdsToList);
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart); SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart);
} }