示例#1
0
        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);
            }
        }
示例#2
0
 public void RemoveStar(Star star)
 {
     Stars.Remove(star);
 }