private void TryManualReconnect() { if (lastManualReconnector != this) { recentlyConnectedNets.Clear(); lastManualReconnector = this; } if (SteamNet != null) { recentlyConnectedNets.Add(SteamNet); } var compSteam = SteamConnectionMaker.BestTransmitterForConnector(parent.Position, parent.Map, recentlyConnectedNets); if (compSteam == null) { recentlyConnectedNets.Clear(); compSteam = SteamConnectionMaker.BestTransmitterForConnector(parent.Position, parent.Map); } if (compSteam != null) { SteamConnectionMaker.DisconnectFromSteamNet(this); ConnectToTransmitter(compSteam); for (var i = 0; i < 5; i++) { MoteMaker.ThrowMetaPuff(compSteam.parent.Position.ToVector3Shifted(), compSteam.parent.Map); } parent.Map.mapDrawer.MapMeshDirty(parent.Position, MapMeshFlag.PowerGrid); parent.Map.mapDrawer.MapMeshDirty(parent.Position, MapMeshFlag.Things); } }
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]); } } } }
public void UpdateSteamNetsAndConnections_First() { int count = delayedActions.Count; for (int i = 0; i < count; i++) { DelayedAction delayedAction = delayedActions[i]; DelayedActionType type = delayedActions[i].type; if (type != DelayedActionType.RegisterTransmitter) { if (type == DelayedActionType.DeregisterTransmitter) { TryDestroyNetAt(delayedAction.position); SteamConnectionMaker.DisconnectAllFromTransmitterAndSetWantConnect(delayedAction.CompSteam, map); delayedAction.CompSteam.ResetSteamVars(); } } else if (delayedAction.position == delayedAction.CompSteam.parent.Position) { ThingWithComps parent = delayedAction.CompSteam.parent; if (map.GetComponent <SteamNetGrid>().TransmittedSteamNetAt(parent.Position) != null) { //Log.Warning(string.Concat("Tried to register trasmitter ", parent, " at ", parent.Position, ", but there is already a power net here. There can't be two transmitters on the same cell.")); } delayedAction.CompSteam.SetUpSteamVars(); foreach (IntVec3 cell in GenAdj.CellsAdjacentCardinal(parent)) { TryDestroyNetAt(cell); } } } for (int j = 0; j < count; j++) { DelayedAction delayedAction2 = delayedActions[j]; if ((delayedAction2.type == DelayedActionType.RegisterTransmitter && delayedAction2.position == delayedAction2.CompSteam.parent.Position) || delayedAction2.type == DelayedActionType.DeregisterTransmitter) { TryCreateNetAt(delayedAction2.position); foreach (IntVec3 cell2 in GenAdj.CellsAdjacentCardinal(delayedAction2.position, delayedAction2.rotation, delayedAction2.CompSteam.parent.def.size)) { TryCreateNetAt(cell2); } } } for (int k = 0; k < count; k++) { DelayedAction delayedAction3 = delayedActions[k]; DelayedActionType type2 = delayedActions[k].type; if (type2 != DelayedActionType.RegisterConnector) { if (type2 == DelayedActionType.DeregisterConnector) { SteamConnectionMaker.DisconnectFromSteamNet(delayedAction3.CompSteam); delayedAction3.CompSteam.ResetSteamVars(); } } else if (delayedAction3.position == delayedAction3.CompSteam.parent.Position) { delayedAction3.CompSteam.SetUpSteamVars(); SteamConnectionMaker.TryConnectToAnySteamNet(delayedAction3.CompSteam, null); } } delayedActions.RemoveRange(0, count); if (DebugViewSettings.drawPower) { DrawDebugSteamNets(); } }