Fixes secret only adding game rules, not starting them (#11005)
This commit is contained in:
53
Content.IntegrationTests/Tests/GameRules/SecretStartsTest.cs
Normal file
53
Content.IntegrationTests/Tests/GameRules/SecretStartsTest.cs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Content.Server.GameTicking;
|
||||||
|
using Content.Server.GameTicking.Rules;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
|
namespace Content.IntegrationTests.Tests.GameRules;
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public sealed class SecretStartsTest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Tests that when secret is started, all of the game rules it successfully adds are also started.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public async Task TestSecretStarts()
|
||||||
|
{
|
||||||
|
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings()
|
||||||
|
{
|
||||||
|
NoClient = true,
|
||||||
|
Dirty = true,
|
||||||
|
});
|
||||||
|
|
||||||
|
var server = pairTracker.Pair.Server;
|
||||||
|
await server.WaitIdleAsync();
|
||||||
|
var protoMan = server.ResolveDependency<IPrototypeManager>();
|
||||||
|
var gameTicker = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<GameTicker>();
|
||||||
|
|
||||||
|
await server.WaitAssertion(() =>
|
||||||
|
{
|
||||||
|
gameTicker.StartGameRule(protoMan.Index<GameRulePrototype>("Secret"));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Wait three ticks for any random update loops that might happen
|
||||||
|
await server.WaitRunTicks(3);
|
||||||
|
|
||||||
|
await server.WaitAssertion(() =>
|
||||||
|
{
|
||||||
|
foreach (var rule in gameTicker.AddedGameRules)
|
||||||
|
{
|
||||||
|
Assert.That(gameTicker.StartedGameRules.Contains(rule));
|
||||||
|
}
|
||||||
|
|
||||||
|
// End all rules
|
||||||
|
gameTicker.ClearGameRules();
|
||||||
|
});
|
||||||
|
|
||||||
|
await pairTracker.CleanReturnAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -41,6 +41,7 @@ public sealed class StartEndGameRulesTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
Assert.That(gameTicker.AddedGameRules, Has.Count.EqualTo(rules.Count));
|
Assert.That(gameTicker.AddedGameRules, Has.Count.EqualTo(rules.Count));
|
||||||
|
Assert.That(gameTicker.AddedGameRules, Has.Count.EqualTo(gameTicker.StartedGameRules.Count));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Wait three ticks for any random update loops that might happen
|
// Wait three ticks for any random update loops that might happen
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public sealed class SecretRuleSystem : GameRuleSystem
|
|||||||
|
|
||||||
foreach (var rule in _prototypeManager.Index<GamePresetPrototype>(preset).Rules)
|
foreach (var rule in _prototypeManager.Index<GamePresetPrototype>(preset).Rules)
|
||||||
{
|
{
|
||||||
_ticker.AddGameRule(_prototypeManager.Index<GameRulePrototype>(rule));
|
_ticker.StartGameRule(_prototypeManager.Index<GameRulePrototype>(rule));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user