Refactor Game Modes (#5857)
This commit is contained in:
committed by
GitHub
parent
d1a1ee3cbe
commit
f4d8ec1b35
@@ -4,12 +4,14 @@ using Content.Server.GameTicking;
|
||||
using Content.Server.GameTicking.Rules;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.GameRules
|
||||
{
|
||||
[TestFixture]
|
||||
[TestOf(typeof(RuleMaxTimeRestart))]
|
||||
[TestOf(typeof(MaxTimeRestartRuleSystem))]
|
||||
public class RuleMaxTimeRestartTest : ContentIntegrationTest
|
||||
{
|
||||
[Test]
|
||||
@@ -19,7 +21,9 @@ namespace Content.IntegrationTests.Tests.GameRules
|
||||
{
|
||||
CVarOverrides =
|
||||
{
|
||||
["game.lobbyenabled"] = "true"
|
||||
["game.lobbyenabled"] = "true",
|
||||
["game.dummyticker"] = "false",
|
||||
["game.defaultpreset"] = "", // No preset.
|
||||
}
|
||||
};
|
||||
var server = StartServer(options);
|
||||
@@ -27,16 +31,15 @@ namespace Content.IntegrationTests.Tests.GameRules
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
var sGameTicker = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<GameTicker>();
|
||||
var maxTimeMaxTimeRestartRuleSystem = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<MaxTimeRestartRuleSystem>();
|
||||
var sGameTiming = server.ResolveDependency<IGameTiming>();
|
||||
|
||||
RuleMaxTimeRestart maxTimeRule = null;
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
Assert.That(sGameTicker.RunLevel, Is.EqualTo(GameRunLevel.PreRoundLobby));
|
||||
|
||||
maxTimeRule = sGameTicker.AddGameRule<RuleMaxTimeRestart>();
|
||||
maxTimeRule.RoundMaxTime = TimeSpan.FromSeconds(3);
|
||||
sGameTicker.AddGameRule(IoCManager.Resolve<IPrototypeManager>().Index<GameRulePrototype>(maxTimeMaxTimeRestartRuleSystem.Prototype));
|
||||
maxTimeMaxTimeRestartRuleSystem.RoundMaxTime = TimeSpan.FromSeconds(3);
|
||||
|
||||
sGameTicker.StartRound();
|
||||
});
|
||||
@@ -46,7 +49,7 @@ namespace Content.IntegrationTests.Tests.GameRules
|
||||
Assert.That(sGameTicker.RunLevel, Is.EqualTo(GameRunLevel.InRound));
|
||||
});
|
||||
|
||||
var ticks = sGameTiming.TickRate * (int) Math.Ceiling(maxTimeRule.RoundMaxTime.TotalSeconds * 1.1f);
|
||||
var ticks = sGameTiming.TickRate * (int) Math.Ceiling(maxTimeMaxTimeRestartRuleSystem.RoundMaxTime.TotalSeconds * 1.1f);
|
||||
await server.WaitRunTicks(ticks);
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
@@ -54,7 +57,7 @@ namespace Content.IntegrationTests.Tests.GameRules
|
||||
Assert.That(sGameTicker.RunLevel, Is.EqualTo(GameRunLevel.PostRound));
|
||||
});
|
||||
|
||||
ticks = sGameTiming.TickRate * (int) Math.Ceiling(maxTimeRule.RoundEndDelay.TotalSeconds * 1.1f);
|
||||
ticks = sGameTiming.TickRate * (int) Math.Ceiling(maxTimeMaxTimeRestartRuleSystem.RoundEndDelay.TotalSeconds * 1.1f);
|
||||
await server.WaitRunTicks(ticks);
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
|
||||
Reference in New Issue
Block a user