Gamerule Entities, Take 2 (#15765)

This commit is contained in:
Nemanja
2023-04-25 20:23:14 -04:00
committed by GitHub
parent 08ccb5367e
commit 59349b1b9b
124 changed files with 3102 additions and 4344 deletions

View File

@@ -1,17 +1,14 @@
using System;
using System;
using System.Linq;
using System.Threading.Tasks;
using Content.Server.GameTicking;
using Content.Server.GameTicking.Rules;
using Content.Shared.CCVar;
using NUnit.Framework;
using Robust.Shared.Configuration;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
namespace Content.IntegrationTests.Tests.GameRules;
[TestFixture]
public sealed class StartEndGameRulesTest
{
@@ -28,24 +25,20 @@ public sealed class StartEndGameRulesTest
});
var server = pairTracker.Pair.Server;
await server.WaitIdleAsync();
var protoMan = server.ResolveDependency<IPrototypeManager>();
var gameTicker = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<GameTicker>();
var cfg = server.ResolveDependency<IConfigurationManager>();
Assert.That(cfg.GetCVar(CCVars.DisableGridFill), Is.False);
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
@@ -55,7 +48,7 @@ public sealed class StartEndGameRulesTest
{
// End all rules
gameTicker.ClearGameRules();
Assert.That(!gameTicker.AddedGameRules.Any());
Assert.That(!gameTicker.GetAddedGameRules().Any());
});
await pairTracker.CleanReturnAsync();