public void DrawDebugSteamNetGrid() { if (!DebugViewSettings.drawPowerNetGrid) { return; } if (Current.ProgramState != ProgramState.Playing) { return; } if (this.map != Find.CurrentMap) { return; } Rand.PushState(); foreach (IntVec3 c in Find.CameraDriver.CurrentViewRect.ClipInsideMap(this.map)) { SteamNet steamNet = this.netGrid[this.map.cellIndices.CellToIndex(c)]; if (steamNet != null) { Rand.Seed = steamNet.GetHashCode(); CellRenderer.RenderCell(c, Rand.Value); } } Rand.PopState(); }
public void RegisterSteamNet(SteamNet newNet) { allNets.Add(newNet); newNet.steamNetManager = this; map.GetComponent <SteamNetGrid>().Notify_SteamNetCreated(newNet); SteamNetMaker.UpdateVisualLinkagesFor(newNet); }
private void TryDestroyNetAt(IntVec3 cell) { if (!cell.InBounds(map)) { return; } SteamNet steamNet = map.GetComponent <SteamNetGrid>().TransmittedSteamNetAt(cell); if (steamNet != null) { DeleteSteamNet(steamNet); } }
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 Notify_SteamNetCreated(SteamNet newNet) { if (this.steamNetCells.ContainsKey(newNet)) { Log.Warning("Net " + newNet + " is already registered in SteamNetGrid."); this.steamNetCells.Remove(newNet); } List <IntVec3> list = new List <IntVec3>(); this.steamNetCells.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 steam nets on the same cell (", k, ", ", j, "). First transmitters: ", newNet.transmitters[0].parent.LabelCap, " and ", (!this.netGrid[num].transmitters.NullOrEmpty <CompSteam>()) ? this.netGrid[num].transmitters[0].parent.LabelCap : "[none]", "." })); } this.netGrid[num] = newNet; list.Add(new IntVec3(k, 0, j)); } } } }
public void Notify_SteamNetDeleted(SteamNet deadNet) { List <IntVec3> list; if (!this.steamNetCells.TryGetValue(deadNet, out list)) { Log.Warning("Net " + deadNet + " does not exist in SteamNetGrid's dictionary."); 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."); } } this.steamNetCells.Remove(deadNet); }
public void DeleteSteamNet(SteamNet oldNet) { allNets.Remove(oldNet); map.GetComponent <SteamNetGrid>().Notify_SteamNetDeleted(oldNet); }
public static void UpdateVisualLinkagesFor(SteamNet net) { }