public static CompSteam BestTransmitterForConnector(IntVec3 connectorPos, Map map, List <SteamNet> disallowedNets = null) { var cellRect = CellRect.SingleCell(connectorPos).ExpandedBy(ConnectMaxDist).ClipInsideMap(map); cellRect.ClipInsideMap(map); var num = 999999f; CompSteam result = null; for (var i = cellRect.minZ; i <= cellRect.maxZ; i++) { for (var j = cellRect.minX; j <= cellRect.maxX; j++) { var c = new IntVec3(j, 0, i); var transmitter = c.GetSteamTransmitter(map); if (transmitter != null && !transmitter.Destroyed) { var steamComp = transmitter.TryGetComp <CompSteam>(); if (steamComp != null && steamComp.TransmitsSteamNow && (transmitter.def.building == null || transmitter.def.building.allowWireConnection)) { if (disallowedNets == null || !disallowedNets.Contains(steamComp.transNet)) { var num2 = (float)(transmitter.Position - connectorPos).LengthHorizontalSquared; if (num2 < num) { num = num2; result = steamComp; } } } } } } return(result); }
private void TryCreateNetAt(IntVec3 cell) { if (!cell.InBounds(map)) { return; } if (map.GetComponent <SteamNetGrid>().TransmittedSteamNetAt(cell) == null) { Building transmitter = cell.GetSteamTransmitter(map); if (transmitter != null && transmitter.TransmitsSteamNow()) { SteamNet steamNet = SteamNetMaker.NewSteamNetStartingFrom(transmitter); RegisterSteamNet(steamNet); for (int i = 0; i < steamNet.transmitters.Count; i++) { SteamConnectionMaker.ConnectAllConnectorsToTransmitter(steamNet.transmitters[i]); } } } }