private MyShipConnector FindOtherConnector() { BoundingSphereD sphere = new BoundingSphereD(ConnectionPosition, m_detectorRadius); sphere = sphere.Transform(CubeGrid.PositionComp.WorldMatrix); var connector = TryFindConnectorInGrid(ref sphere, CubeGrid, this); if (connector != null) return connector; foreach (var entity in m_detectedGrids) { Debug.Assert(entity is MyCubeGrid); if (!(entity is MyCubeGrid)) continue; var grid = entity as MyCubeGrid; if (grid == this.CubeGrid) continue; connector = TryFindConnectorInGrid(ref sphere, grid, this); if (connector != null) return connector; } return null; }
private MyShipConnector FindOtherConnector(long? otherConnectorId = null) { MyShipConnector connector = null; BoundingSphereD sphere = new BoundingSphereD(ConnectionPosition, m_detectorRadius); if (otherConnectorId.HasValue) { MyEntities.TryGetEntityById<MyShipConnector>(otherConnectorId.Value, out connector); } else { sphere = sphere.Transform(CubeGrid.PositionComp.WorldMatrix); connector = TryFindConnectorInGrid(ref sphere, CubeGrid, this); } if (connector != null) return connector; foreach (var entity in m_detectedGrids) { if (entity.MarkedForClose) continue; Debug.Assert(entity is MyCubeGrid); if (!(entity is MyCubeGrid)) continue; var grid = entity as MyCubeGrid; if (grid == this.CubeGrid) continue; connector = TryFindConnectorInGrid(ref sphere, grid, this); if (connector != null) return connector; } return null; }