private void ConnectInternal(ref Matrix thisMatrix, ref Matrix otherMatrix, MyShipConnector otherConnector, bool constructor) { Debug.Assert(!m_attachableConveyorEndpoint.AlreadyAttached()); if (m_attachableConveyorEndpoint.AlreadyAttached()) m_attachableConveyorEndpoint.DetachAll(); m_attachableConveyorEndpoint.Attach(otherConnector.m_attachableConveyorEndpoint); var data = new HkFixedConstraintData(); data.SetInWorldSpace(ref thisMatrix, ref otherMatrix, ref thisMatrix); var newConstraint = new HkConstraint(CubeGrid.Physics.RigidBody, otherConnector.CubeGrid.Physics.RigidBody, data); this.Connected = true; this.Master = true; otherConnector.Connected = true; otherConnector.Master = false; if (!constructor) { this.ChangeConstraint(otherConnector, newConstraint); otherConnector.ChangeConstraint(this, newConstraint); } else { this.SetConstraint(otherConnector, newConstraint); otherConnector.SetConstraint(this, newConstraint); } AddConstraint(newConstraint); if (CubeGrid != otherConnector.CubeGrid) { this.OnConstraintAdded(GridLinkTypeEnum.Logical, otherConnector.CubeGrid); this.OnConstraintAdded(GridLinkTypeEnum.Physical, otherConnector.CubeGrid); } }