internal void Detach() { if (m_constraint == null) { return; } Debug.Assert(m_constraint != null); Debug.Assert(m_topGrid != null); Debug.Assert(m_topBlock != null); var tmpTopGrid = m_topGrid; m_fixedData.Dispose(); m_fixedData = null; CubeGrid.Physics.RemoveConstraint(m_constraint); m_constraint.Dispose(); m_constraint = null; m_topGrid = null; if (m_topBlock != null) { m_topBlock.Detach(); } tmpTopGrid.OnPhysicsChanged -= CubeGrid_OnPhysicsChanged; m_conveyorEndpoint.Detach(m_topBlock.ConveyorEndpoint as MyAttachableConveyorEndpoint); m_topBlock = null; OnConstraintRemoved(GridLinkTypeEnum.Physical, tmpTopGrid); OnConstraintRemoved(GridLinkTypeEnum.Logical, tmpTopGrid); UpdateText(); }
internal void Detach(bool updateGroups = true) { if (m_constraint == null) { return; } Debug.Assert(m_constraint != null); Debug.Assert(m_topGrid != null); Debug.Assert(m_topBlock != null); var tmpTopGrid = m_topGrid; if (m_constraint.InWorld && (m_constraint.ConstraintData as HkBreakableConstraintData).getIsBroken(m_constraint)) { m_topBlockId = 0; } m_fixedData.Dispose(); m_fixedData = null; CubeGrid.Physics.RemoveConstraint(m_constraint); m_constraint.Dispose(); m_constraint = null; m_topGrid = null; if (m_topBlock != null) { m_topBlock.Detach(); } m_conveyorEndpoint.Detach(m_topBlock.ConveyorEndpoint as MyAttachableConveyorEndpoint); m_topBlock = null; if (updateGroups) { OnConstraintRemoved(GridLinkTypeEnum.Physical, tmpTopGrid); OnConstraintRemoved(GridLinkTypeEnum.Logical, tmpTopGrid); } // Try to reattach, if the block will still live next frame. This fixes missing attachments when splitting grids }