public override string ToString() { var sb = "Inputs: "; var inputWires = InputWires; var usedInputs = new List <int>(); var inputWiresSB = ""; foreach (BigWire wire in inputWires) { if (usedInputs.Contains(wire.InputIndex)) { continue; } inputWiresSB += wire.InputIndex + ", "; usedInputs.Add(wire.InputIndex); } sb += inputWiresSB.Substring(0, inputWiresSB.Length - 2) + " | "; foreach (BigGate gate in Gates) { sb += "Gate" + Gates.IndexOf(gate) + ": " + gate.Display(Gates) + " | "; } sb += "Output: Gate" + Gates.IndexOf(OutputGate); return(sb.ToString()); }
public void ReplaceWallPoint(Vector2 oldPoint, Vector2 newPoint) { var index = Circumference.IndexOf(oldPoint); if (index >= 0) { Circumference[index] = newPoint; } var gateIndex = Gates.IndexOf(oldPoint); if (gateIndex >= 0) { Gates[gateIndex] = newPoint; } var towerIndex = Towers.IndexOf(oldPoint); if (towerIndex >= 0) { Towers[towerIndex] = newPoint; } }
private List <List <Vector2> > TidyUpRoads(List <List <Vector2> > roads) { var roadEdges = roads.SelectMany(RoadToEdges).Distinct().ToList(); var arteries = new List <List <Vector2> > (); while (roadEdges.Any()) { var edge = roadEdges[0]; roadEdges.RemoveAt(0); var attached = false; foreach (var artery in arteries) { if (artery[0].Equals(edge.B)) { artery.Insert(0, edge.A); attached = true; break; } if (artery.Last().Equals(edge.A)) { artery.Add(edge.B); attached = true; break; } } if (!attached) { arteries.Add(new List <Vector2> { edge.A, edge.B }); } } var smoothed = new List <List <Vector2> > (); foreach (var tidyRoad in arteries) { var smoothedRoad = tidyRoad.SmoothVertexList(3); for (var i = 0; i < tidyRoad.Count; i++) { var originalPoint = tidyRoad[i]; var smoothedPoint = smoothedRoad[i]; var affectedPatches = Patches.Where(p => p.Shape.Vertices.Contains(originalPoint)).ToList(); foreach (var affectedPatch in affectedPatches) { affectedPatch.Shape.ReplaceVertex(originalPoint, smoothedPoint); } if (CityWall.Circumference.Contains(originalPoint)) { CityWall.ReplaceWallPoint(originalPoint, smoothedPoint); } if (Castle.Wall.Circumference.Contains(originalPoint)) { Castle.Wall.ReplaceWallPoint(originalPoint, smoothedPoint); } var gateIndex = Gates.IndexOf(originalPoint); if (gateIndex >= 0) { Gates[gateIndex] = smoothedPoint; } } smoothed.Add(smoothedRoad); } return(smoothed); }