Gamerule Entities (#15513)

This commit is contained in:
Nemanja
2023-04-24 01:20:51 -04:00
committed by GitHub
parent 8943c2a10e
commit 39cc02b8f9
124 changed files with 3097 additions and 4342 deletions

View File

@@ -2,14 +2,11 @@
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 StartEndGameRulesTest
{
@@ -26,22 +23,18 @@ public sealed class StartEndGameRulesTest
});
var server = pairTracker.Pair.Server;
await server.WaitIdleAsync();
var protoMan = server.ResolveDependency<IPrototypeManager>();
var gameTicker = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<GameTicker>();
await server.WaitAssertion(() =>
{
var rules = protoMan.EnumeratePrototypes<GameRulePrototype>().ToList();
var rules = gameTicker.GetAllGameRulePrototypes().ToList();
rules.Sort((x, y) => string.Compare(x.ID, y.ID, StringComparison.Ordinal));
// Start all rules
foreach (var rule in rules)
{
gameTicker.StartGameRule(rule);
gameTicker.StartGameRule(rule.ID);
}
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
@@ -51,7 +44,7 @@ public sealed class StartEndGameRulesTest
{
// End all rules
gameTicker.ClearGameRules();
Assert.That(!gameTicker.AddedGameRules.Any());
Assert.That(!gameTicker.GetAddedGameRules().Any());
});
await pairTracker.CleanReturnAsync();