mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Freeze event bus dictionaries (#4727)
* Make component factory use frozen collections * Fix integration tests * Also freeze _entTraitDict * A * I love integration test setup logic * Re-add public method * Freeze event bus * Remove per-component dictionary lookup on EntAddComponent * release notes + fix test jank * Fix merge * fix tests * Shutdown
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using NUnit.Framework;
|
||||
using Robust.Client.ComponentTrees;
|
||||
@@ -39,6 +38,33 @@ namespace Robust.UnitTesting
|
||||
[Parallelizable]
|
||||
public abstract partial class RobustUnitTest
|
||||
{
|
||||
protected virtual Type[]? ExtraComponents => null;
|
||||
private static Type[] _components = new []
|
||||
{
|
||||
typeof(EyeComponent),
|
||||
typeof(MapComponent),
|
||||
typeof(MapGridComponent),
|
||||
typeof(ContainerManagerComponent),
|
||||
typeof(MetaDataComponent),
|
||||
typeof(TransformComponent),
|
||||
typeof(PhysicsComponent),
|
||||
typeof(PhysicsMapComponent),
|
||||
typeof(BroadphaseComponent),
|
||||
typeof(FixturesComponent),
|
||||
typeof(JointComponent),
|
||||
typeof(GridTreeComponent),
|
||||
typeof(MovedGridsComponent),
|
||||
typeof(JointRelayTargetComponent),
|
||||
typeof(OccluderComponent),
|
||||
typeof(OccluderTreeComponent),
|
||||
typeof(SpriteTreeComponent),
|
||||
typeof(LightTreeComponent),
|
||||
typeof(CollisionWakeComponent),
|
||||
typeof(CollideOnAnchorComponent),
|
||||
typeof(Gravity2DComponent),
|
||||
typeof(ActorComponent)
|
||||
};
|
||||
|
||||
public virtual UnitTestProject Project => UnitTestProject.Server;
|
||||
|
||||
[OneTimeSetUp]
|
||||
@@ -122,6 +148,7 @@ namespace Robust.UnitTesting
|
||||
systems.LoadExtraSystemType<DebugRayDrawingSystem>();
|
||||
systems.LoadExtraSystemType<PrototypeReloadSystem>();
|
||||
systems.LoadExtraSystemType<DebugPhysicsSystem>();
|
||||
systems.LoadExtraSystemType<MapLoaderSystem>();
|
||||
systems.LoadExtraSystemType<InputSystem>();
|
||||
systems.LoadExtraSystemType<PvsOverrideSystem>();
|
||||
systems.LoadExtraSystemType<MapSystem>();
|
||||
@@ -133,117 +160,11 @@ namespace Robust.UnitTesting
|
||||
// Required components for the engine to work
|
||||
// Why are we still here? Just to suffer? Why can't we just use [RegisterComponent] magic?
|
||||
// TODO End Suffering.
|
||||
// suffering has been alleviated, but still present
|
||||
var compFactory = deps.Resolve<IComponentFactory>();
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(EyeComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<EyeComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(MapComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<MapComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(MapGridComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<MapGridComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(ContainerManagerComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<ContainerManagerComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(MetaDataComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<MetaDataComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(TransformComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<TransformComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(PhysicsComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<PhysicsComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(PhysicsMapComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<PhysicsMapComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(BroadphaseComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<BroadphaseComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(FixturesComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<FixturesComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(JointComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<JointComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(GridTreeComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<GridTreeComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(MovedGridsComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<MovedGridsComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(JointRelayTargetComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<JointRelayTargetComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(OccluderComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<OccluderComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(OccluderTreeComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<OccluderTreeComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(SpriteTreeComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<SpriteTreeComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(LightTreeComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<LightTreeComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(Gravity2DComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<Gravity2DComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(CollisionWakeComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<CollisionWakeComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(CollideOnAnchorComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<CollideOnAnchorComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(ActorComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<ActorComponent>();
|
||||
}
|
||||
compFactory.RegisterTypes(_components);
|
||||
if (ExtraComponents != null)
|
||||
compFactory.RegisterTypes(ExtraComponents);
|
||||
|
||||
deps.Resolve<IParallelManagerInternal>().Initialize();
|
||||
|
||||
@@ -252,7 +173,7 @@ namespace Robust.UnitTesting
|
||||
entMan.Initialize();
|
||||
// RobustUnitTest is complete hot garbage.
|
||||
// This makes EventTables ignore *all* the screwed up component abuse it causes.
|
||||
entMan.EventBus.OnlyCallOnRobustUnitTestISwearToGodPleaseSomebodyKillThisNightmare();
|
||||
entMan.EventBus.OnlyCallOnRobustUnitTestISwearToGodPleaseSomebodyKillThisNightmare(); // The nightmare never ends
|
||||
mapMan.Initialize();
|
||||
systems.Initialize();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user