void RigidBody_ContactPointCallback(ref MyPhysics.MyContactPointEvent value) { if (this.MarkedForClose || !Entity.Physics.Enabled || m_closeAfterSimulation) { return; } Sandbox.ModAPI.IMyEntity other = GetOtherEntity(ref value.ContactPointEvent); if (Sync.IsServer) { if (other is MyCubeGrid && MySession.Static.DestructibleBlocks) { DestroyGrid(ref value, other as MyCubeGrid); } else if (other is MyCharacter) { (other as MyCharacter).DoDamage(50 * Entity.PositionComp.Scale.Value, MyDamageType.Environment, true); } else if (other is MyFloatingObject) { (other as MyFloatingObject).DoDamage(100 * Entity.PositionComp.Scale.Value, MyDamageType.Deformation, true); } else if (other is MyMeteor) { m_closeAfterSimulation = true; (other.GameLogic as MyMeteorGameLogic).m_closeAfterSimulation = true; } } if (other is MyVoxelMap) { CreateCrater(value, other as MyVoxelMap); } }
/// <summary> /// Called by constraint owner /// </summary> protected virtual void OnConstraintRemoved(GridLinkTypeEnum type, Sandbox.ModAPI.IMyEntity detachedEntity) { var detachedGrid = detachedEntity as MyCubeGrid; if (detachedGrid != null) { MyCubeGridGroups.Static.BreakLink(type, EntityId, CubeGrid, detachedGrid); } }
/// <summary> /// Called by constraint owner /// </summary> protected virtual void OnConstraintAdded(GridLinkTypeEnum type, Sandbox.ModAPI.IMyEntity attachedEntity) { var attachedGrid = attachedEntity as MyCubeGrid; if (attachedGrid != null) { // This crashes when connector (or anything else) connects to two things at the same time MyCubeGridGroups.Static.CreateLink(type, EntityId, CubeGrid, attachedGrid); } }