Gets rid of all ComponentManager usages. (#4707)
This commit is contained in:
committed by
GitHub
parent
7953e5b962
commit
0be5ff829b
@@ -5,21 +5,20 @@ using Robust.Shared.Exceptions;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Reflection;
|
||||
|
||||
namespace Content.Benchmarks
|
||||
{
|
||||
public class ComponentManagerGetAllComponents
|
||||
public class EntityManagerGetAllComponents
|
||||
{
|
||||
private readonly List<IEntity> _entities = new();
|
||||
|
||||
private IComponentManager _componentManager;
|
||||
private IEntityManager _entityManager;
|
||||
|
||||
[Params(5000)] public int N { get; set; }
|
||||
|
||||
public static void TestRun()
|
||||
{
|
||||
var x = new ComponentManagerGetAllComponents
|
||||
var x = new EntityManagerGetAllComponents
|
||||
{
|
||||
N = 500
|
||||
};
|
||||
@@ -33,13 +32,11 @@ namespace Content.Benchmarks
|
||||
// Initialize component manager.
|
||||
IoCManager.InitThread();
|
||||
|
||||
IoCManager.Register<IComponentManager, EntityManager>();
|
||||
IoCManager.Register<IEntityManager, EntityManager>();
|
||||
IoCManager.Register<IRuntimeLog, RuntimeLog>();
|
||||
IoCManager.Register<ILogManager, LogManager>();
|
||||
IoCManager.Register<IDynamicTypeFactory, DynamicTypeFactory>();
|
||||
IoCManager.Register<IEntitySystemManager, EntitySystemManager>();
|
||||
var entityManager = new Mock<IEntityManager>().Object;
|
||||
IoCManager.RegisterInstance<IEntityManager>(entityManager);
|
||||
IoCManager.RegisterInstance<IReflectionManager>(new Mock<IReflectionManager>().Object);
|
||||
|
||||
var dummyReg = new Mock<IComponentRegistration>();
|
||||
@@ -56,16 +53,14 @@ namespace Content.Benchmarks
|
||||
IoCManager.RegisterInstance<IComponentFactory>(componentFactory.Object);
|
||||
|
||||
IoCManager.BuildGraph();
|
||||
_componentManager = IoCManager.Resolve<IComponentManager>();
|
||||
_componentManager.Initialize();
|
||||
_entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
_entityManager.Initialize();
|
||||
|
||||
// Initialize N entities with one component.
|
||||
for (var i = 0; i < N; i++)
|
||||
{
|
||||
var entity = new Entity(entityManager, new EntityUid(i + 1));
|
||||
_entities.Add(entity);
|
||||
|
||||
_componentManager.AddComponent<DummyComponent>(entity);
|
||||
var entity = _entityManager.SpawnEntity(null, EntityCoordinates.Invalid);
|
||||
_entityManager.AddComponent<DummyComponent>(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +69,7 @@ namespace Content.Benchmarks
|
||||
{
|
||||
var count = 0;
|
||||
|
||||
foreach (var _ in _componentManager.EntityQuery<DummyComponent>(true))
|
||||
foreach (var _ in _entityManager.EntityQuery<DummyComponent>(true))
|
||||
{
|
||||
count += 1;
|
||||
}
|
||||
@@ -87,7 +82,7 @@ namespace Content.Benchmarks
|
||||
{
|
||||
var count = 0;
|
||||
|
||||
_componentManager.TryGetComponent(default, out DummyComponent _);
|
||||
_entityManager.TryGetComponent(default, out DummyComponent _);
|
||||
|
||||
return count;
|
||||
}
|
||||
Reference in New Issue
Block a user