/// <summary>
        /// Docks 2 ports together and assumes it is valid.
        /// </summary>
        private void Dock(DockingComponent dockA, DockingComponent dockB)
        {
            Logger.DebugS("docking", $"Docking between {dockA.Owner} and {dockB.Owner}");

            // https://gamedev.stackexchange.com/questions/98772/b2distancejoint-with-frequency-equal-to-0-vs-b2weldjoint

            // We could also potentially use a prismatic joint? Depending if we want clamps that can extend or whatever

            var dockAXform = EntityManager.GetComponent <TransformComponent>(dockA.Owner);
            var dockBXform = EntityManager.GetComponent <TransformComponent>(dockB.Owner);

            var gridA = _mapManager.GetGrid(dockAXform.GridID).GridEntityId;
            var gridB = _mapManager.GetGrid(dockBXform.GridID).GridEntityId;

            SharedJointSystem.LinearStiffness(
                2f,
                0.7f,
                EntityManager.GetComponent <PhysicsComponent>(gridA).Mass,
                EntityManager.GetComponent <PhysicsComponent>(gridB).Mass,
                out var stiffness,
                out var damping);

            // These need playing around with
            // Could also potentially have collideconnected false and stiffness 0 but it was a bit more suss???

            var joint = _jointSystem.GetOrCreateWeldJoint(gridA, gridB, DockingJoint + dockA.Owner);

            var gridAXform = EntityManager.GetComponent <TransformComponent>(gridA);
            var gridBXform = EntityManager.GetComponent <TransformComponent>(gridB);

            var anchorA = dockAXform.LocalPosition + dockAXform.LocalRotation.ToWorldVec() / 2f;
            var anchorB = dockBXform.LocalPosition + dockBXform.LocalRotation.ToWorldVec() / 2f;

            joint.LocalAnchorA     = anchorA;
            joint.LocalAnchorB     = anchorB;
            joint.ReferenceAngle   = (float)(gridBXform.WorldRotation - gridAXform.WorldRotation);
            joint.CollideConnected = true;
            joint.Stiffness        = stiffness;
            joint.Damping          = damping;

            dockA.DockedWith = dockB.Owner;
            dockB.DockedWith = dockA.Owner;
            dockA.DockJoint  = joint;
            dockB.DockJoint  = joint;

            if (TryComp(dockA.Owner, out ServerDoorComponent? doorA))
            {
                doorA.ChangeAirtight = false;
                doorA.Open();
            }

            if (TryComp(dockB.Owner, out ServerDoorComponent? doorB))
            {
                doorB.ChangeAirtight = false;
                doorB.Open();
            }

            var msg = new DockEvent
            {
                DockA    = dockA,
                DockB    = dockB,
                GridAUid = gridA,
                GridBUid = gridB,
            };

            EntityManager.EventBus.RaiseLocalEvent(dockA.Owner, msg, false);
            EntityManager.EventBus.RaiseLocalEvent(dockB.Owner, msg, false);
            EntityManager.EventBus.RaiseEvent(EventSource.Local, msg);
        }
        /// <summary>
        /// Docks 2 ports together and assumes it is valid.
        /// </summary>
        public void Dock(DockingComponent dockA, DockingComponent dockB)
        {
            if (dockB.Owner.GetHashCode() < dockA.Owner.GetHashCode())
            {
                (dockA, dockB) = (dockB, dockA);
            }

            _sawmill.Debug($"Docking between {dockA.Owner} and {dockB.Owner}");

            // https://gamedev.stackexchange.com/questions/98772/b2distancejoint-with-frequency-equal-to-0-vs-b2weldjoint

            // We could also potentially use a prismatic joint? Depending if we want clamps that can extend or whatever
            var dockAXform = EntityManager.GetComponent <TransformComponent>(dockA.Owner);
            var dockBXform = EntityManager.GetComponent <TransformComponent>(dockB.Owner);

            DebugTools.Assert(dockAXform.GridUid != null);
            DebugTools.Assert(dockBXform.GridUid != null);
            var gridA = dockAXform.GridUid !.Value;
            var gridB = dockBXform.GridUid !.Value;

            SharedJointSystem.LinearStiffness(
                2f,
                0.7f,
                EntityManager.GetComponent <PhysicsComponent>(gridA).Mass,
                EntityManager.GetComponent <PhysicsComponent>(gridB).Mass,
                out var stiffness,
                out var damping);

            // These need playing around with
            // Could also potentially have collideconnected false and stiffness 0 but it was a bit more suss???
            WeldJoint joint;

            // Pre-existing joint so use that.
            if (dockA.DockJointId != null)
            {
                DebugTools.Assert(dockB.DockJointId == dockA.DockJointId);
                joint = _jointSystem.GetOrCreateWeldJoint(gridA, gridB, dockA.DockJointId);
            }
            else
            {
                joint = _jointSystem.GetOrCreateWeldJoint(gridA, gridB, DockingJoint + dockA.Owner);
            }

            var gridAXform = EntityManager.GetComponent <TransformComponent>(gridA);
            var gridBXform = EntityManager.GetComponent <TransformComponent>(gridB);

            var anchorA = dockAXform.LocalPosition + dockAXform.LocalRotation.ToWorldVec() / 2f;
            var anchorB = dockBXform.LocalPosition + dockBXform.LocalRotation.ToWorldVec() / 2f;

            joint.LocalAnchorA     = anchorA;
            joint.LocalAnchorB     = anchorB;
            joint.ReferenceAngle   = (float)(gridBXform.WorldRotation - gridAXform.WorldRotation);
            joint.CollideConnected = true;
            joint.Stiffness        = stiffness;
            joint.Damping          = damping;

            dockA.DockedWith = dockB.Owner;
            dockB.DockedWith = dockA.Owner;

            dockA.DockJoint   = joint;
            dockA.DockJointId = joint.ID;

            dockB.DockJoint   = joint;
            dockB.DockJointId = joint.ID;

            if (TryComp <AirlockComponent>(dockA.Owner, out var airlockA))
            {
                airlockA.SetBoltsWithAudio(true);
            }

            if (TryComp <AirlockComponent>(dockB.Owner, out var airlockB))
            {
                airlockB.SetBoltsWithAudio(true);
            }

            if (TryComp(dockA.Owner, out DoorComponent? doorA))
            {
                doorA.ChangeAirtight = false;
                _doorSystem.StartOpening(doorA.Owner, doorA);
            }

            if (TryComp(dockB.Owner, out DoorComponent? doorB))
            {
                doorB.ChangeAirtight = false;
                _doorSystem.StartOpening(doorB.Owner, doorB);
            }

            var msg = new DockEvent
            {
                DockA    = dockA,
                DockB    = dockB,
                GridAUid = gridA,
                GridBUid = gridB,
            };

            EntityManager.EventBus.RaiseLocalEvent(dockA.Owner, msg, false);
            EntityManager.EventBus.RaiseLocalEvent(dockB.Owner, msg, false);
            EntityManager.EventBus.RaiseEvent(EventSource.Local, msg);
        }