mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-07 16:36:52 +02:00
* Move MapManager queries to SharedMapSystem Moves all variants of FindGridsIntersecting/TryFindGridAt to SharedMapSystem Hollows out the MapManager methods and converts them into relays to SharedMapSystem * Move CreateGrid to SharedMapSystem Moves the functionality for CreateGrid and its variants to SharedMapSystem Hollows out the MapManager methods and converts them into relays for the SharedMapSystem methods Obsoletes them too Also moves over the GetAllMapGrids and GetAllGrids methods * Move RaiseOnTileChanged to SharedMapSystem Also moves the SuppressOnTileChanged flag member to SharedMapSystem Hollows out and obsoletes the MapManager versions * Move default value constants to SharedMapSystem * Converts map pausing events into LocalizedEntityCommands * Move MapManager related delegates/structs to SharedMapSystem Moves the GridCreationOptions struct to the same namespace as SharedMapSystem and converts it into a record struct Move the GridCallback delegates to the same namespace as SharedMapSystem * Move CullDeletionHistory to SharedMapSystem Well, that was less painful than I thought it would be * Actually obsolete the NetworkedMapManager method * Rename file * Doc comments for new SharedMapSystem methods * Doc comment * Doc comments * Fix access * Purge all references to IMapManagerInternal * Cull easy IMapManager references * The rest * Purge IMapManager * Private internal FindGridsIntersecting method * please die * 41 * notes --------- Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
78 lines
3.0 KiB
C#
78 lines
3.0 KiB
C#
using System.Numerics;
|
|
using System.Threading.Tasks;
|
|
using NUnit.Framework;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Maths;
|
|
using Robust.Shared.Physics;
|
|
using Robust.Shared.Physics.Collision.Shapes;
|
|
using Robust.Shared.Physics.Components;
|
|
using Robust.Shared.Physics.Dynamics;
|
|
using Robust.Shared.Physics.Dynamics.Joints;
|
|
using Robust.Shared.Physics.Systems;
|
|
|
|
namespace Robust.UnitTesting.Shared.Physics;
|
|
|
|
[TestFixture]
|
|
internal sealed class JointDeletion_Test : RobustIntegrationTest
|
|
{
|
|
[Test]
|
|
public async Task JointDeletionTest()
|
|
{
|
|
var server = StartServer();
|
|
await server.WaitIdleAsync();
|
|
|
|
var entManager = server.ResolveDependency<IEntityManager>();
|
|
var susManager = server.ResolveDependency<IEntitySystemManager>();
|
|
var jointSystem = susManager.GetEntitySystem<SharedJointSystem>();
|
|
var broadphase = susManager.GetEntitySystem<SharedBroadphaseSystem>();
|
|
var fixSystem = susManager.GetEntitySystem<FixtureSystem>();
|
|
var physicsSystem = susManager.GetEntitySystem<SharedPhysicsSystem>();
|
|
|
|
DistanceJoint joint = default!;
|
|
EntityUid ent1;
|
|
EntityUid ent2 = default!;
|
|
PhysicsComponent body1;
|
|
PhysicsComponent body2 = default!;
|
|
EntityUid mapEnt = default!;
|
|
MapId mapId = default!;
|
|
|
|
await server.WaitPost(() =>
|
|
{
|
|
mapEnt = entManager.System<SharedMapSystem>().CreateMap(out mapId);
|
|
ent1 = entManager.SpawnEntity(null, new MapCoordinates(Vector2.Zero, mapId));
|
|
ent2 = entManager.SpawnEntity(null, new MapCoordinates(Vector2.One, mapId));
|
|
|
|
body1 = entManager.AddComponent<PhysicsComponent>(ent1);
|
|
body2 = entManager.AddComponent<PhysicsComponent>(ent2);
|
|
var manager1 = entManager.EnsureComponent<FixturesComponent>(ent1);
|
|
var manager2 = entManager.EnsureComponent<FixturesComponent>(ent2);
|
|
entManager.AddComponent<CollisionWakeComponent>(ent2);
|
|
|
|
physicsSystem.SetBodyType(ent1, BodyType.Dynamic, manager: manager1, body: body1);
|
|
physicsSystem.SetBodyType(ent2, BodyType.Dynamic, manager: manager2, body: body2);
|
|
physicsSystem.SetCanCollide(ent1, true, manager: manager1, body: body1);
|
|
physicsSystem.SetCanCollide(ent2, true, manager: manager2, body: body2);
|
|
var shape = new PolygonShape();
|
|
shape.SetAsBox(0.5f, 0.5f);
|
|
|
|
fixSystem.CreateFixture(ent2, "fix1", new Fixture(shape, 0, 0, false), manager: manager2, body: body2);
|
|
|
|
joint = jointSystem.CreateDistanceJoint(ent1, ent2, id: "distance-joint");
|
|
joint.CollideConnected = false;
|
|
});
|
|
|
|
await server.WaitRunTicks(1);
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
Assert.That(joint.Enabled);
|
|
physicsSystem.SetAwake((ent2, body2), false);
|
|
Assert.That(!body2.Awake);
|
|
|
|
entManager.DeleteEntity(ent2);
|
|
broadphase.FindNewContacts();
|
|
});
|
|
}
|
|
}
|