public void RegisterPowerNet(NutrientPipeNet newNet) { this.allNets.Add(newNet); newNet.pipeNetManager = this; this.map.GetComponent <PipeNetGrid>().Notify_PowerNetCreated(newNet); PipeNetMaker.UpdateVisualLinkagesFor(newNet); }
public void DrawDebugPowerNetGrid() { if (!DebugViewSettings.drawPowerNetGrid) { return; } if (Current.ProgramState != ProgramState.Playing) { return; } if (this.map != Find.CurrentMap) { return; } Rand.PushState(); foreach (IntVec3 current in Find.CameraDriver.CurrentViewRect.ClipInsideMap(this.map)) { NutrientPipeNet powerNet = this.netGrid[this.map.cellIndices.CellToIndex(current)]; if (powerNet != null) { Rand.Seed = powerNet.GetHashCode(); CellRenderer.RenderCell(current, Rand.Value); } } Rand.PopState(); }
public void ConnectToTransmitter(CompPipe transmitter, bool reconnectingAfterLoading = false) { if (this.connectParent != null && (!reconnectingAfterLoading || this.connectParent != transmitter)) { Log.Error(string.Concat(new object[] { "Tried to connect ", this, " to transmitter ", transmitter, " but it's already connected to ", this.connectParent, "." }), false); return; } this.connectParent = transmitter; if (this.connectParent.connectChildren == null) { this.connectParent.connectChildren = new List <CompPipe>(); } transmitter.connectChildren.Add(this); NutrientPipeNet pipeNet = this.NutrientPipeNet; if (pipeNet != null) { pipeNet.RegisterConnector(this); } }
public virtual void ResetPowerVars() { this.transNet = null; this.connectParent = null; this.connectChildren = null; CompPipe.recentlyConnectedNets.Clear(); CompPipe.lastManualReconnector = null; }
private void TryDestroyNetAt(IntVec3 cell) { if (!cell.InBounds(this.map)) { return; } NutrientPipeNet powerNet = this.map.GetComponent <PipeNetGrid>().TransmittedPowerNetAt(cell); if (powerNet != null) { this.DeletePowerNet(powerNet); } }
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 Notify_PowerNetCreated(NutrientPipeNet newNet) { if (this.powerNetCells.ContainsKey(newNet)) { Log.Warning("Net " + newNet + " is already registered in PowerNetGrid.", false); this.powerNetCells.Remove(newNet); } List <IntVec3> list = new List <IntVec3>(); this.powerNetCells.Add(newNet, list); for (int i = 0; i < newNet.transmitters.Count; i++) { CellRect cellRect = newNet.transmitters[i].parent.OccupiedRect(); for (int j = cellRect.minZ; j <= cellRect.maxZ; j++) { for (int k = cellRect.minX; k <= cellRect.maxX; k++) { int num = this.map.cellIndices.CellToIndex(k, j); if (this.netGrid[num] != null) { /*Log.Warning(string.Concat(new object[] * { * "Two power nets on the same cell (", * k, * ", ", * j, * "). First transmitters: ", * newNet.transmitters[0].parent.LabelCap, * " and ", * (!this.netGrid[num].transmitters.NullOrEmpty<CompPipe>()) ? this.netGrid[num].transmitters[0].parent.LabelCap : "[none]", * "." * }), false);*/ } this.netGrid[num] = newNet; list.Add(new IntVec3(k, 0, j)); } } } }
public void Notify_PowerNetDeleted(NutrientPipeNet deadNet) { List <IntVec3> list; if (!this.powerNetCells.TryGetValue(deadNet, out list)) { Log.Warning("Net " + deadNet + " does not exist in PowerNetGrid's dictionary.", false); return; } for (int i = 0; i < list.Count; i++) { int num = this.map.cellIndices.CellToIndex(list[i]); if (this.netGrid[num] == deadNet) { this.netGrid[num] = null; } else { Log.Warning("Multiple nets on the same cell " + list[i] + ". This is probably a result of an earlier error.", false); } } this.powerNetCells.Remove(deadNet); }
public static void UpdateVisualLinkagesFor(NutrientPipeNet net) { }
public void DeletePowerNet(NutrientPipeNet oldNet) { this.allNets.Remove(oldNet); this.map.GetComponent <PipeNetGrid>().Notify_PowerNetDeleted(oldNet); }