public static void ConnectAllConnectorsToTransmitter(CompPipe newTransmitter) { foreach (CompPipe compPipe in PipeConnectionMaker.PotentialConnectorsForTransmitter(newTransmitter)) { if (compPipe.connectParent == null) { compPipe.ConnectToTransmitter(newTransmitter, false); } } }
private void TryCreateNetAt(IntVec3 cell) { if (!cell.InBounds(this.map)) { return; } if (this.map.GetComponent <PipeNetGrid>().TransmittedPowerNetAt(cell) == null) { Building transmitter = GetPipeTransmitter(cell, this.map); //Log.Message(transmitter.ToString()); if (transmitter != null && GetPipeTransmission(transmitter)) { NutrientPipeNet pipeNet = PipeNetMaker.NewPowerNetStartingFrom(transmitter); this.RegisterPowerNet(pipeNet); for (int i = 0; i < pipeNet.transmitters.Count; i++) { PipeConnectionMaker.ConnectAllConnectorsToTransmitter(pipeNet.transmitters[i]); } } } }
public void UpdatePipeNetsAndConnections_First() { int count = this.delayedActions.Count; for (int i = 0; i < count; i++) { DelayedAction delayedAction = this.delayedActions[i]; DelayedActionType type = this.delayedActions[i].type; if (type != DelayedActionType.RegisterTransmitter) { if (type == DelayedActionType.DeregisterTransmitter) { this.TryDestroyNetAt(delayedAction.position); PipeConnectionMaker.DisconnectAllFromTransmitterAndSetWantConnect(delayedAction.compPipe, this.map); delayedAction.compPipe.ResetPowerVars(); } } else if (delayedAction.position == delayedAction.compPipe.parent.Position) { ThingWithComps parent = delayedAction.compPipe.parent; if (this.map.GetComponent <PipeNetGrid>().TransmittedPowerNetAt(parent.Position) != null) { Log.Warning(string.Concat(new object[] { "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." }), false); } delayedAction.compPipe.SetUpPowerVars(); foreach (IntVec3 current in GenAdj.CellsAdjacentCardinal(parent)) { this.TryDestroyNetAt(current); } } } for (int j = 0; j < count; j++) { DelayedAction delayedAction2 = this.delayedActions[j]; if ((delayedAction2.type == DelayedActionType.RegisterTransmitter && delayedAction2.position == delayedAction2.compPipe.parent.Position) || delayedAction2.type == DelayedActionType.DeregisterTransmitter) { this.TryCreateNetAt(delayedAction2.position); foreach (IntVec3 current2 in GenAdj.CellsAdjacentCardinal(delayedAction2.position, delayedAction2.rotation, delayedAction2.compPipe.parent.def.size)) { this.TryCreateNetAt(current2); } } } for (int k = 0; k < count; k++) { DelayedAction delayedAction3 = this.delayedActions[k]; DelayedActionType type2 = this.delayedActions[k].type; if (type2 != DelayedActionType.RegisterConnector) { if (type2 == DelayedActionType.DeregisterConnector) { PipeConnectionMaker.DisconnectFromPowerNet(delayedAction3.compPipe); delayedAction3.compPipe.ResetPowerVars(); } } else if (delayedAction3.position == delayedAction3.compPipe.parent.Position) { delayedAction3.compPipe.SetUpPowerVars(); PipeConnectionMaker.TryConnectToAnyPowerNet(delayedAction3.compPipe, null); } } this.delayedActions.RemoveRange(0, count); if (DebugViewSettings.drawPower) { this.DrawDebugPowerNets(); } }