Remove most static IoCManager. accesses from engine. (#3466)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Pieter-Jan Briers
2022-11-15 12:00:28 +01:00
committed by GitHub
parent c26c8fb81e
commit 1646297039
88 changed files with 877 additions and 743 deletions

View File

@@ -40,8 +40,8 @@ namespace Robust.UnitTesting
public void BaseSetup()
{
// Clear state across tests.
IoCManager.InitThread();
IoCManager.Clear();
var deps = IoCManager.InitThread();
deps.Clear();
RegisterIoC();
@@ -61,7 +61,7 @@ namespace Robust.UnitTesting
assemblies.Add(AppDomain.CurrentDomain.GetAssemblyByName("Robust.Shared"));
assemblies.Add(Assembly.GetExecutingAssembly());
var configurationManager = IoCManager.Resolve<IConfigurationManagerInternal>();
var configurationManager = deps.Resolve<IConfigurationManagerInternal>();
configurationManager.Initialize(Project == UnitTestProject.Server);
@@ -79,7 +79,7 @@ namespace Robust.UnitTesting
configurationManager.LoadCVarsFromAssembly(typeof(RobustUnitTest).Assembly);
var systems = IoCManager.Resolve<IEntitySystemManager>();
var systems = deps.Resolve<IEntitySystemManager>();
// Required systems
systems.LoadExtraSystemType<EntityLookupSystem>();
@@ -99,6 +99,7 @@ namespace Robust.UnitTesting
systems.LoadExtraSystemType<Robust.Client.Physics.PhysicsSystem>();
systems.LoadExtraSystemType<Robust.Client.Debugging.DebugRayDrawingSystem>();
systems.LoadExtraSystemType<PrototypeReloadSystem>();
systems.LoadExtraSystemType<Robust.Client.Debugging.DebugPhysicsSystem>();
}
else
{
@@ -111,13 +112,14 @@ namespace Robust.UnitTesting
systems.LoadExtraSystemType<PhysicsSystem>();
systems.LoadExtraSystemType<DebugRayDrawingSystem>();
systems.LoadExtraSystemType<PrototypeReloadSystem>();
systems.LoadExtraSystemType<DebugPhysicsSystem>();
}
var entMan = IoCManager.Resolve<IEntityManager>();
var mapMan = IoCManager.Resolve<IMapManager>();
var entMan = deps.Resolve<IEntityManager>();
var mapMan = deps.Resolve<IMapManager>();
// Required components for the engine to work
var compFactory = IoCManager.Resolve<IComponentFactory>();
var compFactory = deps.Resolve<IComponentFactory>();
if (!compFactory.AllRegisteredTypes.Contains(typeof(MapComponent)))
{
@@ -163,9 +165,9 @@ namespace Robust.UnitTesting
mapMan.Initialize();
systems.Initialize();
IoCManager.Resolve<IReflectionManager>().LoadAssemblies(assemblies);
deps.Resolve<IReflectionManager>().LoadAssemblies(assemblies);
var modLoader = IoCManager.Resolve<TestingModLoader>();
var modLoader = deps.Resolve<TestingModLoader>();
modLoader.Assemblies = contentAssemblies;
modLoader.TryLoadModulesFrom(ResourcePath.Root, "");