mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* Physics worlds * Paul's a good boy * Build working * Ingame and not lagging to hell * Why didn't you commit ahhhhh * Hard collisions working * Solver parity * Decent broadphase work done * BroadPhase outline done * BroadPhase working * waiting for pvs * Fix static PVS AABB * Stop static bodies from awakening * Optimise a bunch of stuff * Even more broadphase stuff * I'm fucking stupid * Optimise fixture updates * Collision solver start * Building * A is for Argumentative * Fix contact caching island flags * Circle shapes actually workeded * Damping * DS2 consumables only * Slightly more stable * Even slightlier more stablier * VV your heart out * Initial joint support * 90% of joints I just wanted to push as I'd scream if I lost progress * JOINT PURGATORY * Joints barely functional lmao * Okay these joints slightly more functional * Remove station FrictionJoint * Also that * Some Box2D ports * Cleanup mass * Edge shape * Active contacts * Fix active contacts * Optimise active contacts even more * Boxes be stacking * I would die for smug oh my fucking god * In which everything is fixed * Distance joints working LETS GO * Remove frequency on distancejoint * Fix some stuff and break joints * Crashing fixed mehbeh * ICollideSpecial and more resilience * auto-clear * showbb vera * Slap that TODO in there * Fix restartround crash * Random fixes * Fix fixture networking * Add intersection method for broadphase * Fix contacts * Licenses done * Optimisations * Fix wall clips * Config caching for island * allocations optimisations * Optimise casts * Optimise events queue for physics * Contact manager optimisations * Optimise controllers * Sloth joint or something idk * Controller graph * Remove content cvar * Random cleanup * Finally remove VirtualController * Manifold structs again * Optimise this absolute retardation * Optimise * fix license * Cleanup physics interface * AHHHHHHHHHHHHH * Fix collisions again * snivybus * Fix potential nasty manifold bug * Tests go snivy * Disable prediction for now * Spans * Fix ShapeTypes * fixes * ch ch changeesss * Kinematic idea * Prevent static bodies from waking * Pass WorldAABB to MoveEvent * Fix collisions * manifold structs fucking WOOORRKKKINNGGG * Better pushing * Fix merge ickies * Optimise MoveEvents * Use event for collisions performance * Fix content tests * Do not research tests * Fix most conflicts * Paul's trying to kill me * Maybe collisions work idk * Make us whole again * Smug is also trying to kill me * nani * shitty collisions * Settling * Do not research collisions * SHIP IT * Fix joints * PVS moment * Fix other assert * Fix locker collisions * serializable sleeptime * Aether2D contacts * Physics is no longer crashing (and burning) * Add to the TODO list Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
171 lines
5.3 KiB
C#
171 lines
5.3 KiB
C#
using Moq;
|
|
using NUnit.Framework;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Server.Physics;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Maths;
|
|
using Robust.Shared.Physics.Broadphase;
|
|
|
|
namespace Robust.UnitTesting.Shared.Map
|
|
{
|
|
[TestFixture, TestOf(typeof(MapManager))]
|
|
class MapManager_Tests : RobustUnitTest
|
|
{
|
|
public override UnitTestProject Project => UnitTestProject.Server;
|
|
|
|
protected override void OverrideIoC()
|
|
{
|
|
base.OverrideIoC();
|
|
var mock = new Mock<IEntitySystemManager>();
|
|
var broady = new BroadPhaseSystem();
|
|
var physics = new PhysicsSystem();
|
|
mock.Setup(m => m.GetEntitySystem<SharedBroadPhaseSystem>()).Returns(broady);
|
|
mock.Setup(m => m.GetEntitySystem<SharedPhysicsSystem>()).Returns(physics);
|
|
|
|
IoCManager.RegisterInstance<IEntitySystemManager>(mock.Object, true);
|
|
}
|
|
|
|
[OneTimeSetUp]
|
|
public void OneTimeSetup()
|
|
{
|
|
var compMan = IoCManager.Resolve<IComponentManager>();
|
|
compMan.Initialize();
|
|
|
|
var mapMan = IoCManager.Resolve<IMapManager>();
|
|
mapMan.Initialize();
|
|
}
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
var mapMan = IoCManager.Resolve<IMapManager>();
|
|
mapMan.Startup();
|
|
}
|
|
|
|
[TearDown]
|
|
public void TearDown()
|
|
{
|
|
var mapMan = IoCManager.Resolve<IMapManager>();
|
|
mapMan.Shutdown();
|
|
}
|
|
|
|
/// <summary>
|
|
/// When the map manager is restarted, the maps are deleted.
|
|
/// </summary>
|
|
[Test]
|
|
public void Restart_ExistingMap_IsRemoved()
|
|
{
|
|
var mapMan = IoCManager.Resolve<IMapManager>();
|
|
|
|
var mapID = new MapId(11);
|
|
mapMan.CreateMap(mapID);
|
|
|
|
mapMan.Restart();
|
|
|
|
Assert.That(mapMan.MapExists(mapID), Is.False);
|
|
}
|
|
|
|
/// <summary>
|
|
/// When the map manager is restarted, the grids are removed.
|
|
/// </summary>
|
|
[Test]
|
|
public void Restart_ExistingGrid_IsRemoved()
|
|
{
|
|
var mapMan = IoCManager.Resolve<IMapManager>();
|
|
|
|
var mapID = new MapId(11);
|
|
var gridId = new GridId(7);
|
|
mapMan.CreateMap(mapID);
|
|
mapMan.CreateGrid(mapID, gridId);
|
|
|
|
mapMan.Restart();
|
|
|
|
Assert.That(mapMan.GridExists(gridId), Is.False);
|
|
}
|
|
|
|
/// <summary>
|
|
/// When the map manager is restarted, Nullspace is recreated.
|
|
/// </summary>
|
|
[Test]
|
|
public void Restart_NullspaceMap_IsEmptied()
|
|
{
|
|
var mapMan = IoCManager.Resolve<IMapManager>();
|
|
var entMan = IoCManager.Resolve<IEntityManager>();
|
|
|
|
mapMan.CreateNewMapEntity(MapId.Nullspace);
|
|
|
|
var oldEntity = (Entity)entMan.CreateEntityUninitialized(null, MapCoordinates.Nullspace);
|
|
oldEntity.InitializeComponents();
|
|
|
|
mapMan.Restart();
|
|
|
|
Assert.That(mapMan.MapExists(MapId.Nullspace), Is.True);
|
|
Assert.That(mapMan.GridExists(GridId.Invalid), Is.False);
|
|
Assert.That(oldEntity.Deleted, Is.True);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// When using SetMapEntity, the existing entities on the map are removed, and the new map entity gets a IMapComponent.
|
|
/// </summary>
|
|
[Test]
|
|
public void SetMapEntity_WithExistingEntity_ExistingEntityDeleted()
|
|
{
|
|
// Arrange
|
|
var mapID = new MapId(11);
|
|
var mapMan = IoCManager.Resolve<IMapManager>();
|
|
var entMan = IoCManager.Resolve<IEntityManager>();
|
|
|
|
mapMan.CreateMap(new MapId(7));
|
|
mapMan.CreateMap(mapID);
|
|
var oldMapEntity = mapMan.GetMapEntity(mapID);
|
|
var newMapEntity = entMan.CreateEntityUninitialized(null, new MapCoordinates(Vector2.Zero, new MapId(7)));
|
|
|
|
// Act
|
|
mapMan.SetMapEntity(mapID, newMapEntity);
|
|
|
|
// Assert
|
|
Assert.That(oldMapEntity.Deleted);
|
|
Assert.That(newMapEntity.HasComponent<IMapComponent>());
|
|
|
|
var mapComp = newMapEntity.GetComponent<IMapComponent>();
|
|
Assert.That(mapComp.WorldMap == mapID);
|
|
}
|
|
|
|
/// <summary>
|
|
/// After creating a new map entity for nullspace, you can spawn entities into nullspace like any other map.
|
|
/// </summary>
|
|
[Test]
|
|
public void SpawnEntityAt_IntoNullspace_Success()
|
|
{
|
|
// Arrange
|
|
var mapMan = IoCManager.Resolve<IMapManager>();
|
|
var entMan = IoCManager.Resolve<IEntityManager>();
|
|
|
|
mapMan.CreateNewMapEntity(MapId.Nullspace);
|
|
|
|
// Act
|
|
var newEntity = entMan.SpawnEntity(null, MapCoordinates.Nullspace);
|
|
|
|
// Assert
|
|
Assert.That(newEntity.Transform.MapID, Is.EqualTo(MapId.Nullspace));
|
|
}
|
|
|
|
[Test]
|
|
public void Restart_MapEntity_IsRemoved()
|
|
{
|
|
var mapMan = IoCManager.Resolve<IMapManager>();
|
|
|
|
var entity = mapMan.CreateNewMapEntity(MapId.Nullspace);
|
|
|
|
mapMan.Restart();
|
|
|
|
Assert.That(mapMan.MapExists(MapId.Nullspace), Is.True);
|
|
Assert.That(entity.Deleted, Is.True);
|
|
Assert.That(mapMan.GetMapEntityId(MapId.Nullspace), Is.EqualTo(EntityUid.Invalid));
|
|
}
|
|
}
|
|
}
|