Turns GameTicker into an EntitySystem. (#4197)
* GameTicker turned into an EntitySystem * Turns ClientGameTicker into an EntitySystem, turn NetMessages into events * Change event names to be more consistent with the rest. * YAML linter uses the dummy gameticker CVar override. * Fix game ticker initialization order * Dummy ticker won't spawn players. * Fix character creation test
This commit is contained in:
committed by
GitHub
parent
15fb554c28
commit
d3a611164b
@@ -5,10 +5,12 @@ using Content.Client.Parallax.Managers;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.IoC;
|
||||
using Content.Shared.CCVar;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Robust.Server.Maps;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
@@ -57,7 +59,7 @@ namespace Content.IntegrationTests
|
||||
|
||||
// Connecting to Discord is a massive waste of time.
|
||||
// Basically just makes the CI logs a mess.
|
||||
options.CVarOverrides["discord.enabled"] = "false";
|
||||
options.CVarOverrides[CVars.DiscordEnabled.Name] = "false";
|
||||
|
||||
// Avoid preloading textures in tests.
|
||||
options.CVarOverrides.TryAdd(CVars.TexturePreloadingEnabled.Name, "false");
|
||||
@@ -112,16 +114,9 @@ namespace Content.IntegrationTests
|
||||
protected ServerIntegrationInstance StartServerDummyTicker(ServerIntegrationOptions options = null)
|
||||
{
|
||||
options ??= new ServerIntegrationOptions();
|
||||
options.BeforeStart += () =>
|
||||
{
|
||||
IoCManager.Resolve<IModLoader>().SetModuleBaseCallbacks(new ServerModuleTestingCallbacks
|
||||
{
|
||||
ServerBeforeIoC = () =>
|
||||
{
|
||||
IoCManager.Register<IGameTicker, DummyGameTicker>(true);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Dummy game ticker.
|
||||
options.CVarOverrides[CCVars.GameDummyTicker.Name] = "true";
|
||||
|
||||
return StartServer(options);
|
||||
}
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.GameTicking.Rules;
|
||||
using Content.Server.Mind;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.IntegrationTests
|
||||
{
|
||||
public class DummyGameTicker : GameTickerBase, IGameTicker
|
||||
{
|
||||
public GameRunLevel RunLevel { get; } = GameRunLevel.InRound;
|
||||
|
||||
public MapId DefaultMap { get; } = MapId.Nullspace;
|
||||
public GridId DefaultGridId { get; } = GridId.Invalid;
|
||||
|
||||
public event Action<GameRunLevelChangedEventArgs> OnRunLevelChanged
|
||||
{
|
||||
add { }
|
||||
remove { }
|
||||
}
|
||||
|
||||
public event Action<GameRuleAddedEventArgs> OnRuleAdded
|
||||
{
|
||||
add{ }
|
||||
remove { }
|
||||
}
|
||||
|
||||
public void Update(FrameEventArgs frameEventArgs)
|
||||
{
|
||||
}
|
||||
|
||||
public void RestartRound()
|
||||
{
|
||||
}
|
||||
|
||||
public void StartRound(bool force = false)
|
||||
{
|
||||
}
|
||||
|
||||
public void EndRound(string roundEnd)
|
||||
{
|
||||
}
|
||||
|
||||
public void Respawn(IPlayerSession targetPlayer)
|
||||
{
|
||||
}
|
||||
|
||||
public bool OnGhostAttempt(Mind mind, bool canReturnGlobal)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void MakeObserve(IPlayerSession player)
|
||||
{
|
||||
}
|
||||
|
||||
public void MakeJoinGame(IPlayerSession player, string? jobId)
|
||||
{
|
||||
}
|
||||
|
||||
public void ToggleReady(IPlayerSession player, bool ready)
|
||||
{
|
||||
}
|
||||
|
||||
public void ToggleDisallowLateJoin(bool disallowLateJoin)
|
||||
{
|
||||
}
|
||||
|
||||
public EntityCoordinates GetLateJoinSpawnPoint() => EntityCoordinates.Invalid;
|
||||
public EntityCoordinates GetJobSpawnPoint(string jobId) => EntityCoordinates.Invalid;
|
||||
public EntityCoordinates GetObserverSpawnPoint() => EntityCoordinates.Invalid;
|
||||
|
||||
public void EquipStartingGear(IEntity entity, StartingGearPrototype startingGear, HumanoidCharacterProfile? profile)
|
||||
{
|
||||
}
|
||||
|
||||
public T AddGameRule<T>() where T : GameRule, new()
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
public bool HasGameRule(string? type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool HasGameRule(Type? type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void RemoveGameRule(GameRule rule)
|
||||
{
|
||||
}
|
||||
|
||||
public IEnumerable<GameRule> ActiveGameRules { get; } = Array.Empty<GameRule>();
|
||||
|
||||
public bool TryGetPreset(string name, [NotNullWhen(true)] out Type? type)
|
||||
{
|
||||
type = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetStartPreset(Type type, bool force = false)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetStartPreset(string name, bool force = false)
|
||||
{
|
||||
}
|
||||
|
||||
public bool DelayStart(TimeSpan time)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool PauseStart(bool pause = true)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TogglePause()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public Dictionary<string, int> GetAvailablePositions()
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,9 @@ namespace Content.IntegrationTests.Tests.Commands
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
var gameTicker = server.ResolveDependency<IGameTicker>();
|
||||
var configManager = server.ResolveDependency<IConfigurationManager>();
|
||||
var entityManager = server.ResolveDependency<IEntityManager>();
|
||||
var gameTicker = entityManager.EntitySysManager.GetEntitySystem<GameTicker>();
|
||||
|
||||
await server.WaitRunTicks(30);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.GameTicking.Rules;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.GameRules
|
||||
@@ -25,7 +26,7 @@ namespace Content.IntegrationTests.Tests.GameRules
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
var sGameTicker = server.ResolveDependency<IGameTicker>();
|
||||
var sGameTicker = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<GameTicker>();
|
||||
var sGameTiming = server.ResolveDependency<IGameTiming>();
|
||||
|
||||
RuleMaxTimeRestart maxTimeRule = null;
|
||||
|
||||
@@ -13,6 +13,7 @@ using Content.Shared.Preferences;
|
||||
using NUnit.Framework;
|
||||
using Robust.Client.State;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Lobby
|
||||
@@ -32,7 +33,7 @@ namespace Content.IntegrationTests.Tests.Lobby
|
||||
var clientPrefManager = client.ResolveDependency<IClientPreferencesManager>();
|
||||
|
||||
var serverConfig = server.ResolveDependency<IConfigurationManager>();
|
||||
var serverTicker = server.ResolveDependency<IGameTicker>();
|
||||
var serverTicker = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<GameTicker>();
|
||||
var serverPrefManager = server.ResolveDependency<IServerPreferencesManager>();
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
@@ -40,12 +41,16 @@ namespace Content.IntegrationTests.Tests.Lobby
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
serverConfig.SetCVar(CCVars.GameDummyTicker, false);
|
||||
serverConfig.SetCVar(CCVars.GameLobbyEnabled, true);
|
||||
serverTicker.RestartRound();
|
||||
});
|
||||
|
||||
Assert.That(serverTicker.RunLevel, Is.EqualTo(GameRunLevel.PreRoundLobby));
|
||||
|
||||
// Need to run them in sync to receive the messages.
|
||||
await RunTicksSync(client, server, 1);
|
||||
|
||||
await WaitUntil(client, () => clientStateManager.CurrentState is LobbyState, maxTicks: 60);
|
||||
|
||||
Assert.NotNull(clientNetManager.ServerChannel);
|
||||
|
||||
@@ -36,8 +36,8 @@ namespace Content.IntegrationTests.Tests
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
var gameTicker = server.ResolveDependency<IGameTicker>();
|
||||
var entitySystemManager = server.ResolveDependency<IEntitySystemManager>();
|
||||
var gameTicker = entitySystemManager.GetEntitySystem<GameTicker>();
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.GameTicking;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.IntegrationTests.Tests
|
||||
@@ -15,7 +16,7 @@ namespace Content.IntegrationTests.Tests
|
||||
|
||||
server.Post(() =>
|
||||
{
|
||||
IoCManager.Resolve<IGameTicker>().RestartRound();
|
||||
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<GameTicker>().RestartRound();
|
||||
});
|
||||
|
||||
await RunTicksSync(client, server, 10);
|
||||
|
||||
Reference in New Issue
Block a user