private void CreateConstraint(MyShipConnector otherConnector) { var posA = ConstraintPositionInGridSpace(); var posB = otherConnector.ConstraintPositionInGridSpace(); var axisA = ConstraintAxisGridSpace(); var axisB = -otherConnector.ConstraintAxisGridSpace(); CreateConstraintNosync(otherConnector, ref posA, ref posB, ref axisA, ref axisB); MySyncShipConnector.AnnounceApproach(this, otherConnector); }
private void CreateConstraintInit(MyShipConnector otherConnector) { var posA = ConstraintPositionInGridSpace(); var posB = otherConnector.ConstraintPositionInGridSpace(); var axisA = ConstraintAxisGridSpace(); var axisB = -otherConnector.ConstraintAxisGridSpace(); CreateConstraintNosync(otherConnector, ref posA, ref posB, ref axisA, ref axisB); }
private void CreateConstraintNosync(MyShipConnector otherConnector) { Debug.Assert(IsMaster, "Constraints should be created only master (entity with higher EntityId)"); var posA = ConstraintPositionInGridSpace(); var posB = otherConnector.ConstraintPositionInGridSpace(); var axisA = ConstraintAxisGridSpace(); var axisB = -otherConnector.ConstraintAxisGridSpace(); var data = new HkHingeConstraintData(); data.SetInBodySpace(posA, posB, axisA, axisB, CubeGrid.Physics, otherConnector.CubeGrid.Physics); var data2 = new HkMalleableConstraintData(); data2.SetData(data); data.ClearHandle(); data = null; data2.Strength = GetEffectiveStrength(otherConnector); var newConstraint = new HkConstraint(CubeGrid.Physics.RigidBody, otherConnector.CubeGrid.Physics.RigidBody, data2); SetConstraint(otherConnector, newConstraint); otherConnector.SetConstraint(this, newConstraint); AddConstraint(newConstraint); }