public Constellation WithLines(int Index, List <int> HRNums) { for (int i = 0; i < HRNums.Count - 1; i++) { Star s1 = physics.StarDictionary[HRNums[i]]; Star s2 = physics.StarDictionary[HRNums[i + 1]]; if (!Stars.Contains(s1)) { Stars.Add(s1); } if (!Stars.Contains(s2)) { Stars.Add(s2); } switch (Index) { case 0: normalShape.AddLine(new Line(s1.Position, s2.Position)); break; case 1: altShape.AddLine(new Line(s1.Position, s2.Position)); break; } StarPairs.Add(new Tuple <Star, Star>(s1, s2)); } return(this); }
public void RecalculateConstellationPoints(ViewportFoV reference, bool calculateConnections) { // calculate all star positions for the constellation once and add them to the star collection for drawing if they're visible foreach (var star in constellation.Stars) { var starPosition = star.Coords.XYProjection(reference); star.Position = new PointF((float)starPosition.X, (float)starPosition.Y); var isInBounds = !reference.IsOutOfViewportBounds(star.Position); var contains = Stars.Contains(star); if (isInBounds && !contains) { Stars.Add(star); } else if (!isInBounds && contains) { Stars.Remove(star); } } if (calculateConnections) { // now we check what lines are visible in the fov and only add those connections as well foreach (var starConnection in constellation.StarConnections) { var isInBounds = !(reference.IsOutOfViewportBounds(starConnection.Item1.Position) && reference.IsOutOfViewportBounds(starConnection.Item2.Position)); var contains = Points.Contains(starConnection); if (isInBounds && !contains) { Points.Add(starConnection); } else if (!isInBounds && contains) { Points.Remove(starConnection); } } var p = constellationCenter.XYProjection(reference); CenterPoint = new PointF((float)p.X, (float)p.Y); } }